nginx の failed to open stream: Too many open files in /xxxx/xxx/xxx に対処する

● nginx の 開けるファイル数を確認する

ps ax | grep nginx | grep worker
11151 ?        S      0:01 nginx: worker process

 ↓ 11151 から次のコマンドを実行

cat /proc/11151/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             1866                 1866                 processes 
Max open files            20000                20000                files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       1866                 1866                 signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us  

Max open files 20000 となっています。

● nginxの設定を確認する

cat /etc/nginx/nginx.conf | grep worker_rlimit_nofile
20000

● OS全体の設定を確認する(これより小さい値にする)

cat /proc/sys/fs/file-max

● nginxの worker_rlimit_nofile 設定を変更する

vi /etc/nginx/nginx.conf

例: worker_rlimit_nofile を 40000 に設定する

worker_rlimit_nofile  40000;

nginx のリスタート

nginx -s reload
No.1549
07/12 17:47

edit