初始化配置:
//修改主機名字,無需重新開機,永久修改。
hostnamectl set-hostname ServerName
//修改網卡IP
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet #網絡類型,以太網。必須
BOOTPROTO=static #IP設定方式,靜态,必須。自動的話将static設定為dhcp
NAME=eth0 #網卡名,必須
DEVICE=eth0 #裝置名,必須
ONBOOT=yes #網卡開啟自啟動,必須
IPADDR=192.168.235.82
NETWORK=255.255.255.0
GATEWAY=192.168.235.2
DNS1=223.5.5.5
//關閉防火牆
systemctl stop firewalld
systemctl disable firewalld
//關閉圖形化的網絡管理器,CLI界面的用不到。圖形界面的可以留着
systemctl stop NetworkManager
systemctl disable NetworkManager
//關閉postfix一個電子郵件伺服器
systemctl stop postfix
systemctl disable postfix
//關閉SELinux
setenforce 0
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
cat !$
//優化遠端shell登入
sed -i 's/GSSAPIAuthentication yes/GSSAPIAuthentication no/g' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/g' /etc/ssh/sshd_config
egrep 'GSSAPIAuthentication|UseDNS' /etc/ssh/sshd_config
//修改最大打開檔案數,預設為1024
sed -i 's/#DefaultLimitNOFILE=/DefaultLimitNOFILE=102400/g' /etc/systemd/system.conf
sed -i 's/#DefaultLimitNPROC=/DefaultLimitNPROC=102400/g' /etc/systemd/system.conf
egrep 'DefaultLimitNPROC|DefaultLimitNOFILE' /etc/systemd/system.conf