Linux(CentOS)下分析并优化TCP参数方法

阅读更多
1、从CentOS服务器监控分析看TCP状态
# netstat -ano|grep |awk -F' ' '{print $6}' |sort |uniq -c
      9 CLOSING
   1760 ESTABLISHED
    127 FIN_WAIT1
    227 FIN_WAIT2
     56 LAST_ACK
      1 LISTEN
     18 SYN_RECV
   1407 TIME_WAIT
发现:TIME_WAIT和FIN_WAIT状态连接数较多。

2、统计各状态实时超时情况,发现:
# netstat -ano|grep |grep FIN_WAIT2 |awk -F' ' '{print $8}'|awk -F/ '{print $1}' |awk -F'(' '{print $2}' |sort -nr |more
1> FIN_WAIT2当前超时为15s
14.80
14.69
14.59
2> FIN_WAIT1当前超时为120s
# netstat -ano|grep |grep FIN_WAIT1 |awk -F' ' '{print $8}'|awk -F/ '{print $1}' |awk -F'(' '{print $2}' |sort -nr |more
102.39
100.09
83.86
3> TIME_WAIT当前超时为60s
# netstat -ano|grep |grep TIME_WAIT |awk -F' ' '{print $8}'|awk -F/ '{print $1}' |awk -F'(' '{print $2}' |sort -nr |more
59.98
59.90
59.85

3、当前os参数配置如下:
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60 =>TIME_WAIT
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120 =>FIN_WAIT1
net.ipv4.tcp_fin_timeout = 15 => FIN_WAIT2
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120

4、【小结】
建议优化如下:
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 30 =>TIME_WAIT
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 15 =>FIN_WAIT1
net.ipv4.tcp_fin_timeout = 15 => FIN_WAIT2 (不调整)
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 30

你可能感兴趣的:(TCP,STATUS,CentOS)