#netstat -an | awk '/^tcp/ {++s[$NF]}END{for (a in s) print a,s[a]}'
TIME_WAIT 75
FIN_WAIT1 18
FIN_WAIT2 23
ESTABLISHED 263
SYN_RECV 1
CLOSING 5
LAST_ACK 7
LISTEN 7
FIN_WAIT1 18
FIN_WAIT2 23
ESTABLISHED 263
SYN_RECV 1
CLOSING 5
LAST_ACK 7
LISTEN 7
CLOSEING 两边同时关闭,等待
LISTEN 监听链接请求(被动打开)
SYN_SENT 已发出SYN(主动打开)
SYN_RCVD 已发出和收到SYN;等待ACK
ESTABLISHED 已经建立连接(数据传输)
CLOSE_WAIT 收到FIN,等待应用程序关闭
FIN_WAIT_1 已经关闭,发出FIN;等待ACK和FIN
FIN_WAIT_2 已经关闭;等待FIN
LAST_ACK 收到FIN已经关闭;等待ACK
TIMIE_WAIT 主动关闭后长达2MSL的等待状态
################################################
TIME_WAIT过多减少TCP连接中TIME-WAIT sockets
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
大量的连接处于CLOSE_WAIT状态
sysctl -w net.ipv4.tcp_keepalive_time=30
sysctl -w net.ipv4.tcp_keepalive_probes=2
sysctl -w net.ipv4.tcp_keepalive_intvl=2
sysctl -w net.ipv4.tcp_keepalive_probes=2
sysctl -w net.ipv4.tcp_keepalive_intvl=2
某个TCP连接在idle 30秒后,内核发起probe.如果probe 2次(每次2秒)不成功,内核才彻底放弃,认为该连接已失效
转载于:https://blog.51cto.com/bensonzy/611224