http://blog.sina.com.cn/s/blog_69cdee7f0100yowt.html
#一台Nginx+php-fcgi的服务器做了负载均衡,在主控端发现一直在报错:
01 | #----------------------------引用文字-开始---------------------------- |
02 | Apr 19 14:48:38chengyongxu.com kernel: TCP: time wait buckettable overflow |
03 | Apr 19 14:48:44chengyongxu.com kernel: printk: 137 messagessuppressed. |
04 | Apr 19 14:48:44chengyongxu.com kernel: TCP: time wait buckettable overflow |
05 | Apr 19 14:48:52chengyongxu.com kernel: printk: 251 messagessuppressed. |
06 | Apr 19 14:48:52chengyongxu.com kernel: TCP: time wait buckettable overflow |
07 | Apr 19 14:48:53chengyongxu.com kernel: printk: 51 messages suppressed. |
08 | Apr 19 14:48:53chengyongxu.com kernel: TCP: time wait buckettable overflow |
09 | Apr 19 14:48:59chengyongxu.com kernel: printk: 119 messagessuppressed. |
10 | #----------------------------引用文字-结束---------------------------- |
#再看80端口连接状态
01 | netstat -an | grep 80 | awk '{print $6}' | sort | uniq -c | sort -rn |
02 | #----------------------------引用文字-开始---------------------------- |
12 | #----------------------------引用文字-结束---------------------------- |
#根据报错提示,需要更改net.ipv4.tcp_max_tw_buckets这个内核参数。这个参数是系统同时保持timewait套接字的最大数量。如果超过这个数字,time-wait套接字将立刻被清除并打印警告信息。这个限制仅仅是为了防止简单的DoS攻击,你绝对不能过分依靠它或者人为地减小这个值,如果网络实际需要大于缺省值,更应该增加这个值(如果增加了内存之后)。
01 | vi /etc/sysconfig/sysctl.conf |
02 | #----------------------------引用文字-开始---------------------------- |
04 | net.ipv4.tcp_max_tw_buckets = 6000 |
06 | net.ipv4.tcp_max_tw_buckets = 10000 |
07 | #----------------------------引用文字-结束---------------------------- |
12 | netstat -an | grep 80 | awk '{print $6}' | sort | uniq -c | sort -rn |
13 | #----------------------------引用文字-开始---------------------------- |
23 | #----------------------------引用文字-结束---------------------------- |
24 | netstat -an | grep 80 | awk '{print $6}' | sort | uniq -c | sort -rn |
25 | #----------------------------引用文字-开始---------------------------- |
35 | #----------------------------引用文字-结束---------------------------- |
36 | netstat -an | grep 80 | awk '{print $6}' | sort | uniq -c | sort -rn |
37 | #----------------------------引用文字-开始---------------------------- |
47 | #----------------------------引用文字-结束---------------------------- |
48 | netstat -an | grep 80 | awk '{print $6}' | sort | uniq -c | sort -rn |
49 | #----------------------------引用文字-开始---------------------------- |
59 | #----------------------------引用文字-结束---------------------------- |
#再看/var/log/messages和dmesg的信息,已经不再报错了,看来net.ipv4.tcp_max_tw_buckets=10000暂时是够用了