nofile ulimit -n 在 Ubuntu 14.04 LTS 上

sha*_*ind 6 ulimit 14.04

? sudo sysctl -a|grep file

fs.file-max = 2037581
fs.file-nr = 2784   0   2037581

? ~ cat /proc/sys/fs/file-max
2037581

? ~ cat /proc/sys/fs/file-nr
2720    0   2037581
Run Code Online (Sandbox Code Playgroud)

/etc/security/limits.conf

* hard nofile 2037581
* soft nofile 2037581
root hard nofile 2037581
root soft nofile 2037581
Run Code Online (Sandbox Code Playgroud)

/etc/pam.d/su

session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)

/etc/pam.d/common-session

session required pam_limits.so
Run Code Online (Sandbox Code Playgroud)

然后重新启动。

但是 ulimit -n 又得到了 1024。

只能 ulimit -n 4096 作为最大值

或出错

 ulimit: value exceeds hard limit
Run Code Online (Sandbox Code Playgroud)

Man*_*tha 0

如果你设置root hard nofile 65535它只会改变 root 用户限制。如果您想更改另一个用户限制,请添加该用户的用户名,例如,

sharewind hard nofile 65535 或者为用户名添加*,这将更改所有用户限制。但不建议这样做。


小智 0

我发现,如果服务是在新贵初始化脚本下启动的,则必须使用节限制来控制它!

请参阅:http ://bryanmarty.com/2012/02/10/setting-nofile-limit-upstart/