TCP:太多的孤儿套接字是什么意思?

当我使用dmesg来查看Linux内核消息时,我看到了大量的….

TCP:太多的孤立的套接字

消息。 我的猜测是,这是在closures之后在TIME_WAIT中等待清除的套接字。 我很想知道这是否会影响在这些服务器上运行的服务。

从LARTC HOWTO:

/proc/sys/net/ipv4/tcp_max_orphans Maximal number of TCP sockets not attached to any user file handle, held by system. If this number is exceeded orphaned connections are reset immediately and warning is printed. This limit exists only to prevent simple DoS attacks, you _must_ not rely on this or lower the limit artificially, but rather increase it (probably, after increasing installed memory), if network conditions require more than default value, and tune network services to linger and kill such states more aggressively. Let me remind you again: each orphan eats up to 64K of unswappable memory. 

限制孤儿数量的function的实现在这里 。

此错误的可能原因是系统用尽了套接字内存。您可能需要增加套接字内存(net.ipv4.tcp_mem)或找出内存消耗的原因

  [root@test ~]# cat /proc/sys/net/ipv4/tcp_mem 362688 483584 725376 

所以在我的系统中,你可以看到725376(页)* 4096 = 2971140096bytes / 1024 * 1024 = 708兆字节

因此,这个708兆内存被应用程序用于发送和接收数据,以及被我的环回接口使用。如果在任何阶段该值达不到进一步的套接字,则可以使该内存从保持套接字打开的应用程序释放你可以使用netstat -antulp来确定。