- 安装系统后,对系统进行优化
关闭防火墙
#0关闭 selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled/ /etc/selinux/config
setenforce 0
getenforce
#1 iptables
/etc/init.d/iptables
/etc/init.d/iptables
chkconfig iptables off
2 精简开机自启动服务
开机自启动
chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk'{print"chkconfig",$1,"off"}'|bash
export LANG=en
chkconfig --list|grep 3:on
03 时间同步
echo '*/5 * * * * /usr/sbin/ntpdate time.nist.g >/dev/null 2>&1' >>/var/spool/cron/root
04 加大文件描述
echo '* - nofile 65535 ' >>/etc/security/limits.conf
05 内核优化
cat >> /etc/sysctl.conf<<EOF
net.ipv4.tcp_fin_timeout =2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.ip_local_port_range = 4000 65000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retrise = 1
net.ipv4.tcp_synack_retrise = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.tcp_max_orphans = 16384
net.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_max = 25000000
net.netfilter.nf_conntrack_tcp_timeout_established = 180
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120
EOF
sysctl -p # 让内核配置生效
6 安装软件
yum install lrzsz nmap tree dos2unix nc -y
7 hosts解析
cat >/etc/hosts<<EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1. 5 lb01
172.16.1.6 lb02
172.16.1.7 web02
172.16.1.8 web01
172.16.1.9 web03
172.16.1.51 db01 db01.etiantion.org
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.61 m01
EOF