需要修改/etc/security/limits.conf中的soft和hard limit,系统默认上限为1048576。
注意:如果设置数值超过上限,用户将无法登录,即使root用户设置超过上限,也会无法登录!
limits.conf默认设置为:
# End of file
root soft nofile 65535 #root soft limit
root hard nofile 65535 #root hard limit
* soft nofile 65535 #非root用户 soft limit
* hard nofile 65535 #非root用户 hard limit
修改后为:
# End of file
root soft nofile 65535
root hard nofile 65535
* soft nofile 200000
* hard nofile 200000
如果你需要更高的上限怎么办呢?这个上限是在/proc/sys/fs/nr_open中设定的,所以直接修改即可。
但直接改会报错Fsync failed,可以使用命令echo 2000000 > /proc/sys/fs/nr_open 修改。