Ubuntu 12.04 服务器端TCP最大连接数超过1024,要怎么设置?
发表于 : 2014-07-09 13:21
Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)
想在一个socket服务端程序中接受>=2048个客户端的socket连接, 但到了1024个后就不行了,这样设置
vi /etc/sysctl.conf
net.ipv4.ip_conntrack_max = 40960
sysctl -p
后, 报error: "net.ipv4.ip_conntrack_max" is an unknown key
请问应该要彼设置才能让TCP连接大于1024个呢?
打开FD的数量已经设置为40960, 用C写一个程序可以打开2048个文件:
/etc/security/limits.conf
root soft nofile 40960
root hard nofile 40960
vi /etc/pam.d/common-session
session required pam_limits.so
vi /etc/profile
ulimit -SHn 40960
# cat /proc/net/sockstat
sockets: used 1082
TCP: inuse 1024 orphan 0 tw 4096 alloc 1025 mem 71
UDP: inuse 1 mem 1
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0
想在一个socket服务端程序中接受>=2048个客户端的socket连接, 但到了1024个后就不行了,这样设置
vi /etc/sysctl.conf
net.ipv4.ip_conntrack_max = 40960
sysctl -p
后, 报error: "net.ipv4.ip_conntrack_max" is an unknown key
请问应该要彼设置才能让TCP连接大于1024个呢?
打开FD的数量已经设置为40960, 用C写一个程序可以打开2048个文件:
/etc/security/limits.conf
root soft nofile 40960
root hard nofile 40960
vi /etc/pam.d/common-session
session required pam_limits.so
vi /etc/profile
ulimit -SHn 40960
# cat /proc/net/sockstat
sockets: used 1082
TCP: inuse 1024 orphan 0 tw 4096 alloc 1025 mem 71
UDP: inuse 1 mem 1
UDPLITE: inuse 0
RAW: inuse 0
FRAG: inuse 0 memory 0