
➜ 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
制限
* hard nofile 2037581
* soft nofile 2037581
root hard nofile 2037581
root soft nofile 2037581
su は、
session required pam_limits.so
/etc/pam.d/共通セッション
session required pam_limits.so
その後再起動します。
しかし、ulimit -n は再び 1024 を取得しました。
最大値として ulimit -n 4096 のみ指定可能
またはエラーが発生しました
ulimit: value exceeds hard limit
答え1
設定すると、root hard nofile 65535
ルートユーザーの制限のみが変更されます。他のユーザーの制限を変更する場合は、そのユーザーのユーザー名を追加します。例:
sharewind hard nofile 65535
または、ユーザー名に * を追加すると、すべてのユーザーの制限が変更されます。ただし、これは推奨されません。
答え2
サービスが upstart init スクリプトで起動される場合は、スタンザ制限を使用してこれを制御する必要があることがわかりました。
見る:http://bryanmarty.com/2012/02/10/setting-nofile-limit-upstart/