
➜ 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
答案1
如果你設定root hard nofile 65535
它只會改變 root 使用者限制。如果您想更改另一個用戶限制,請新增該用戶的用戶名,例如,
sharewind hard nofile 65535
或為使用者名稱新增*,這將變更所有使用者限制。但不建議這樣做。
答案2
我發現,如果服務是在新貴初始化腳本下啟動的,則必須使用節限制來控制它!
看:http://bryanmarty.com/2012/02/10/setting-nofile-limit-upstart/