2015-01-08 21 views
9

私は以下の設定を行って、さらにサーバーを再起動したものの:nginxの最大オープンファイルを設定するには?

# head /etc/security/limits.conf -n2 
www-data soft nofile -1 
www-data hard nofile -1 
# /sbin/sysctl fs.file-max 
fs.file-max = 201558 

特定のプロセスのオープン・ファイルの制限は、まだ4096分の1024です:

# ps aux | grep nginx 
root  983 0.0 0.0 85872 1348 ?  Ss 15:42 0:00 nginx: master process /usr/sbin/nginx 
www-data 984 0.0 0.2 89780 6000 ?  S 15:42 0:00 nginx: worker process 
www-data 985 0.0 0.2 89780 5472 ?  S 15:42 0:00 nginx: worker process 
root  1247 0.0 0.0 11744 916 pts/0 S+ 15:47 0:00 grep --color=auto nginx 
# cat /proc/984/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    15845    15845    processes 
Max open files   1024     4096     files 
Max locked memory   65536    65536    bytes 
Max address space   unlimited   unlimited   bytes 
Max file locks   unlimited   unlimited   locks 
Max pending signals  15845    15845    signals 
Max msgqueue size   819200    819200    bytes 
Max nice priority   0     0 
Max realtime priority  0     0 
Max realtime timeout  unlimited   unlimited   us 

私はすべての可能な解決策を試してみましたグーグルではなく無駄だ。私は何の設定を忘れましたか?私はこの質問を投稿した後、数分で答えを見つけることが

+2

重複:http://stackoverflow.com/questions/16919673/nginx-file-descriptor-limit? – T0xicCode

答えて

9

www-data(それのNOLOGINユーザ)とは何の関係もないshoudので...

# cat /etc/default/nginx 
# Note: You may want to look at the following page before setting the ULIMIT. 
# http://wiki.nginx.org/CoreModule#worker_rlimit_nofile 
# Set the ulimit variable if you need defaults to change. 
# Example: ULIMIT="-n 4096" 
ULIMIT="-n 15000" 

/etc/security/limit.confは、PAMによって使用されます。 (7.xの上でテスト)のCentOS上で

+4

ここに/ etc/default/nginxはありますか?私は/etc/nginx/nginx.confしか見ていません、運がないのはworker_rlimit_nofileです – SathiyaS

19

次の内容のファイル/etc/systemd/system/nginx.service.d/override.confを作成しますと

[Service] 
LimitNOFILE=65536 

リロードにsystemdデーモン:

systemctl daemon-reload 

は、これを追加Nginx設定ファイル:

worker_rlimit_nofile 16384; (has to be smaller or equal to LimitNOFILE set above) 

そして最後には、nginxの再起動:

systemctl restart nginx 

あなたはそれがcat /proc/<nginx-pid>/limitsで動作することを確認することができます。

+1

私はこれも** Ubuntu Xenial **で動作していることを確認しています。このアプローチに感謝します。 – cepharum

+0

多分私たちはnginxのマスタープロセスのために 'worker_rlimit_nofile'を持っています:おそらくmaster_rlimit_nofile – davesave

+0

これはRHELでもうまくいきます! –

関連する問題