13、内核参数优化
说明:本优化适合apache,nginx,squid多种等web应用,特殊的业务也可能需要略作调整。
1 [root@server ~]# vi /etc/sysctl.conf
2 #by sun in 20131001
3 net.ipv4.tcp_fin_timeout = 2
4 net.ipv4.tcp_tw_reuse = 1
5 net.ipv4.tcp_tw_recycle = 1
6 net.ipv4.tcp_syncookies = 1
7 net.ipv4.tcp_keepalive_time =600
8 net.ipv4.ip_local_port_range = 4000 65000
9 net.ipv4.tcp_max_syn_backlog = 16384
10 net.ipv4.tcp_max_tw_buckets = 36000
11 net.ipv4.route.gc_timeout = 100
12 net.ipv4.tcp_syn_retries = 1
13 net.ipv4.tcp_synack_retries = 1
14 net.core.somaxconn = 16384
15 net.core.netdev_max_backlog = 16384
16 net.ipv4.tcp_max_orphans = 16384
17 #一下参数是对iptables防火墙的优化,防火墙不开会有提示,可以忽略不理。
18 net.ipv4.ip_conntrack_max = 25000000
19 net.ipv4.netfilter.ip_conntrack_max = 25000000
20 net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180
21 net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120
22 net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60
23 net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120
24 [root@localhost ~]# sysctl –p #使配置文件生效提示:由于CentOS6.X系统中的模块名不是ip_conntrack,而是nf_conntrack,所以在/etc /sysctl.conf优化时,需要把net.ipv4.netfilter.ip_conntrack_max 这种老的参数,改成net.netfilter.nf_conntrack_max这样才可以。
即对防火墙的优化,在5.8上是
1 net.ipv4.ip_conntrack_max = 25000000
2 net.ipv4.netfilter.ip_conntrack_max = 25000000
3 net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180
4 net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120
5 net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60
6 net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120
1 net.ipv4.tcp_syn_retries = 1
2 net.ipv4.tcp_synack_retries = 1
3 net.ipv4.tcp_keepalive_time = 600
4 net.ipv4.tcp_keepalive_probes = 3
5 net.ipv4.tcp_keepalive_intvl =15
6 net.ipv4.tcp_retries2 = 5
7 net.ipv4.tcp_fin_timeout = 2
8 net.ipv4.tcp_max_tw_buckets = 36000
9 net.ipv4.tcp_tw_recycle = 1
10 net.ipv4.tcp_tw_reuse = 1
11 net.ipv4.tcp_max_orphans = 32768
12 net.ipv4.tcp_syncookies = 1
13 net.ipv4.tcp_max_syn_backlog = 16384
14 net.ipv4.tcp_wmem = 8192 131072 16777216
15 net.ipv4.tcp_rmem = 32768 131072 16777216
16 net.ipv4.tcp_mem = 786432 1048576 1572864
17 net.ipv4.ip_local_port_range = 1024 65000
18 net.ipv4.ip_conntrack_max = 65536
19 net.ipv4.netfilter.ip_conntrack_max=65536
20 net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=180
21 net.core.somaxconn = 16384
22 net.core.netdev_max_backlog = 16384另外,在此优化过程中可能会有报错:
1、5.8版本上
1 error: "net.ipv4.ip_conntrack_max"is an unknown key
2 error: "net.ipv4.netfilter.ip_conntrack_max"is an unknown key
3 error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_established"is an unknown key
4 error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait"is an unknown key
5 error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait"is an unknown key
6 error: "net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait"is an unknown key
2015职称计算机考试书PowerPoint2007中 .. 定价:¥45 优惠价:¥42 更多书籍 | |
2015年全国职称计算机考试教材(2007模 .. 定价:¥225 优惠价:¥213 更多书籍 |