1. 关闭不需要的服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
service acpid off service atd stop service auditd stop service avahi-daemon stop service avahi-dnsconfd stop service bluetooth stop service conman stop service cpuspeed stop service cups stop service dnsmasq stop service dund stop service firstboot stop service hidd stop service httpd stop service ibmasm stop service ip6tables stop service irda stop service kdump stop service lm_sensors stop service mcstrans stop service messagebus stop service microcode_ctl stop service netconsole stop service netfs stop service netplugd stop service nfs stop service nfslock stop service nscd stop service ntpd stop service oddjobd stop service pand stop service pcscd stop service portmap stop service psacct stop service rdisc stop service restorecond stop service rpcgssd stop service rpcidmapd stop service rpcsvcgssd stop service saslauthd stop service sendmail stop service setroubleshoot stop service smb stop service vncserver stop service winbind stop service wpa_supplicant stop service xfs stop service ypbind stop service yum-updatesd stop chkconfig acpid off chkconfig atd off chkconfig auditd off chkconfig avahi-daemon off chkconfig avahi-dnsconfd off chkconfig bluetooth off chkconfig conman off chkconfig cpuspeed off chkconfig cups off chkconfig dnsmasq off chkconfig dund off chkconfig firstboot off chkconfig hidd off chkconfig httpd off chkconfig ibmasm off chkconfig ip6tables off chkconfig irda off chkconfig kdump off chkconfig lm_sensors off chkconfig mcstrans off chkconfig messagebus off chkconfig microcode_ctl off chkconfig netconsole off chkconfig netfs off chkconfig netplugd off chkconfig nfs off chkconfig nfslock off chkconfig nscd off chkconfig ntpd off chkconfig oddjobd off chkconfig pand off chkconfig pcscd off chkconfig portmap off chkconfig psacct off chkconfig rdisc off chkconfig restorecond off chkconfig rpcgssd off chkconfig rpcidmapd off chkconfig rpcsvcgssd off chkconfig saslauthd off chkconfig sendmail off chkconfig setroubleshoot off chkconfig smb off chkconfig vncserver off chkconfig winbind off chkconfig wpa_supplicant off chkconfig xfs off chkconfig ypbind off chkconfig yum-updatesd off |
新建a.sh文件,复制粘贴以上内容到文件中,运行sh a.sh
2. 对TCP/IP网络参数进行调整
1 2 |
echo 'net.ipv4.tcp_syncookies = 1' >> /etc/sysctl.conf sysctl -p |
3. 修改shell命令的history 记录个数
1 2 |
vim /etc/profile HISTSIZE=100 |
4. 定时校正服务器时间
1 2 3 |
yum install ntp crontab -e */5 * * * * ntpdate ntp.api.bz |
5. 停止打印服务
1 2 |
/etc/rc.d/init.d/cups stop chkconfig --list cups 确认是否关闭 |
6. 停止ipv6
1 2 3 4 5 6 |
ifconfig -a vim /etc/modprobe.conf alias net -pf -10 off alias ipv6 off echo "IPV6INIT = no " >> /etc/sysconfig/network-scripts/ifconfig-eth0 shutdown -r now |
7. 调整linux 最大文件打开数
vim /etc/rc.local
1 |
ulimit -SHn 65535 |
8. 关闭写磁盘I/0功能
vim /etc/fstab
1 |
/dev/sda5 /data/ ext3 noatime,nodiratime 0 0 |
9. 优化内核TCP参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
vim /etc/sysctl.conf net.ipv4.neigh.default.gc_stale_time = 120 net.ipv4.conf.all.rp_filter = 0 net.ipv4.conf.default.rp_filter = 0 net.ipv4.conf.default.arp_announce = 2 net.ipv4.conf.all.arp_announce = 2 net.ipv4.tcp_max_tw_buckets = 5000 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_max_syn_backlog = 20000 net.ipv4.tcp_synack_retries = 2 net.ipv4.conf.lo.arp_announce=2 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.ip_local_port_range = 1024 65000 sysctl -p |
2016年12月22日 11:52 沙发
分享的不错,谢谢
2016年12月22日 19:01 1层
@凯哥自媒体 小万的随性笔记长期更新shopex产品相关文章以及日常工作中服务器、代码相关的日常笔记,感谢您的关注,欢迎常来逛逛~~