nofile ulimit -n在Ubuntu 14.04 LTS上

➜ 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 

在/etc/security/limits.conf

 * hard nofile 2037581 * soft nofile 2037581 root hard nofile 2037581 root soft nofile 2037581 

/etc/pam.d/su中

 session required pam_limits.so 

/etc/pam.d/common-session

 session required pam_limits.so 

然后重启。

但ulimit -n再次得到1024。

只能将ulimit -n 4096作为最大值

或者有错误

  ulimit: value exceeds hard limit 

如果您设置root hard nofile 65535 ,它将只更改root用户限制。 如果要更改其他用户限制,请添加该用户的用户名,例如,

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

我发现如果服务是在upstart init脚本下启动的,那么你必须使用stanza限制来控制它!

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