web@ct171130:~$ netstat -altnp|grep -i close_wait|awk '{print $4}'|uniq|wc -l
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
1019
web@ct171130:~$ netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
CLOSE_WAIT 1020
ESTABLISHED 62
FIN_WAIT1 3
TIME_WAIT 1752
web@ct171130:~$ cat /proc/sys/net/ipv4/ip_local_port_range
30000 65000
web@ct171130:~$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31543
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 655360
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 31543
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
web@ct171130:~$ sysctl -a|grep keepalive
sysctl: permission denied on key 'fs.protected_hardlinks'
sysctl: permission denied on key 'fs.protected_symlinks'
sysctl: permission denied on key 'kernel.cad_pid'
sysctl: permission denied on key 'kernel.usermodehelper.bset'
sysctl: permission denied on key 'kernel.usermodehelper.inheritable'
sysctl: permission denied on key 'net.ipv4.tcp_fastopen_key'
net.ipv4.tcp_keepalive_intvl = 75 //探测间隔(秒) 总探测时间=75*9
net.ipv4.tcp_keepalive_probes = 9 //探测次数
net.ipv4.tcp_keepalive_time = 30//探测超时(秒)发送rst数据包之后超过30秒没回算超时
参考博客
分析关于close_wait过多对系统造成的影响_八阿哥的博客-CSDN博客
CLOSE_WAIT过多的解决方法_hellozhxy的博客-CSDN博客_close_wait数量过高
Linux 命令神器:lsof - 简书
tcp_keepalive的设置_走向辉煌-CSDN博客
再谈 TCP 的 CLOSE_WAIT | easyice
Linux网络tcp连接大量CLOSE_WAIT和TIME_WAIT状态的出现和解决方法