Linux内核参数基础优化
1、编辑/etc/sysctl.conf文件 [root@cs1 security]# vim /etc/sysctl.conf

2、shift+g 切换到文件最后一行,然后按键o在下一行进行编辑

3、shift insert 粘贴这些命令到文件
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_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.tcp_max_orphans = 16384
#以下参数是对iptables防火墙的优化,防火墙不开启会提示,可以忽略不理
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
此处的优化参数有参考oldboy老师的博客,优化参数需要根据实际的生产环境设置

4、然后输入sysctl-p 命令生效配置文件
[root@cs1 ~]# sysctl –p

5、网络状态查看:(6列,协议、接收的、发送的、本地的IP、外部的IP、状态)
[root@cs1 ~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 64 10.0.0.201:22 10.0.0.1:59587 ESTABLISHED
tcp 0 0 :::22 :::* LISTEN
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 4 [ ] DGRAM 10258 /dev/log
unix 2 [ ACC ] STREAM LISTENING 8060 @/com/ubuntu/upstart
unix 2 [ ] DGRAM 8461 @/org/kernel/udev/udevd
unix 2 [ ] DGRAM 14665
unix 2 [ ] DGRAM 10332
unix 3 [ ] DGRAM 8477
unix 3 [ ] DGRAM 8476
[root@cs1 ~]#
