标签:
rm -rf /etc/yum.repos.d/* wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clean all yum makecache yum update
for sun in `chkconfig --list|grep 3:on|awk ‘{print $1}‘`;do chkconfig --level 3 $sun off;done
#或者
for sun in `chkconfig --list|grep 3:启用|awk ‘{print $1}‘`;do chkconfig --level 3 $sun off;done
for sun in crond rsyslog sshd network;do chkconfig --level 3 $sun on;done
for sun in crond rsyslog sshd network iptables ip6tables;do chkconfig --level 3 $sun on;done
[root@localhost ~]# vim /etc/sysctl.conf net.ipv4.ip_forward = 1 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 #可以加强对抗SYN Flood的能力 kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 net.ipv4.tcp_max_tw_buckets = 6000 net.ipv4.tcp_sack = 1 net.ipv4.tcp_window_scaling = 1 net.ipv4.tcp_rmem = 4096 87380 4194304 net.ipv4.tcp_wmem = 4096 16384 4194304 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.ip_local_port_range = 1024 65535 [root@localhost ~]# sysctl -p #使配置生效
4.1 优化Linux下的内核TCP参数以提高系统性能
netstat -n |awk ‘/^tcp/ {++S[$NF]} END{for(a in S) print a, S[a]}‘
net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog = 8192 net.ipv4.tcp_max_tw_buckets = 5000
说明:
net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 1024 65000
执行以下命令使配置生效:/sbin/sysctl -p
net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 300 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 5000 65000 kernel.shmmax = 134217728
yum install -y ntpdate crontab -e
crontab -l */5 * * * * /usr/sbin/ntpdate s2m.time.edu.cn &> /dev/null
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
重启生效,也可以不修改配置文件临时生效,但不建议这样设置,因为重启后会失效。
Port 65232 Protocol 2 PermitRootLogin no UseDNS no
cat /etc/redhat-release cat /etc/issue
#清理登陆信息
echo >/etc/redhat-release echo >/etc/issue
userdel adm userdel lp userdel sync userdel shutdown userdel halt userdel news userdel uucp userdel operator userdel games userdel gopher userdel ftp
#删除不必要的群组
groupdel adm groupdel lp groupdel news groupdel uucp groupdel games groupdel dip groupdel pppusers
#注释掉 #exec /sbin/shutdown -r now "Control-Alt-Deletepressed"
#设置自动退出终端,防止非法关闭ssh客户端造成登录进程过多,可以设置大一些,单位为秒 echo "TMOUT=3600">> /etc/profile #历史命令记录数量设置为100条 sed -i "s/HISTSIZE=1000/HISTSIZE=10/" /etc/profile #立即生效 source /etc/profile
标签:
原文地址:http://www.cnblogs.com/zuoyang/p/5983228.html