Maison > Article > développement back-end > centos - linux下php使用curl导致大量TIME_WAIT求解决
<code>netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c 173 ESTABLISHED 43 FIN_WAIT1 20 FIN_WAIT2 5 LAST_ACK 7 LISTEN 2 SYN_RECV 3 SYN_SENT 1745 TIME_WAIT </code>
网站运行一会儿就有大量TIME_WAIT,通过netstat可以看到是php调用curl导致的
目前CURLOPT_CONNECTTIMEOUT设置为:3
CURLOPT_TIMEOUT设置为:3
网上说修改/etc/sysctl.conf,
<code>net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 30 </code>
我修改报错
<code>error: permission denied on key 'net.ipv4.tcp_tw_reuse' error: permission denied on key 'net.ipv4.tcp_tw_recycle' error: permission denied on key 'net.ipv4.tcp_fin_timeout' </code>
服务器是centos
<code>netstat -an|awk '/tcp/ {print $6}'|sort|uniq -c 173 ESTABLISHED 43 FIN_WAIT1 20 FIN_WAIT2 5 LAST_ACK 7 LISTEN 2 SYN_RECV 3 SYN_SENT 1745 TIME_WAIT </code>
网站运行一会儿就有大量TIME_WAIT,通过netstat可以看到是php调用curl导致的
目前CURLOPT_CONNECTTIMEOUT设置为:3
CURLOPT_TIMEOUT设置为:3
网上说修改/etc/sysctl.conf,
<code>net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 30 </code>
我修改报错
<code>error: permission denied on key 'net.ipv4.tcp_tw_reuse' error: permission denied on key 'net.ipv4.tcp_tw_recycle' error: permission denied on key 'net.ipv4.tcp_fin_timeout' </code>
服务器是centos
不懂PHP,仅仅针对你说的出现大量的TIME_WAIT来说,比较详细的解决方案见:http://huoding.com/2012/01/19/142
如果提示`error: permission denied on key 'net.ipv4.tcp_tw_reuse''.请'su'到root并临时关掉Selinux 'setenforce 0'
楼主,这个问题最终你是怎么解决的?我现在也遇到这种问题了。curl每次都关闭,大量请求的时候,还是出现大量的CLOSE_WAIT,ESTABLISHED,TIME_WAIT.请教下。