【NGINX】 nginx: [warn] 2048 worker_connections exceed open file resource limit: 1024と叱られた(´’ω’)

この記事は約6分で読めます。

 

こんにちは( ‘ω’)ノ
暫くこれといったメンテナンスは必要としていなかったうちの鯖ですが、最近またちょこちょこ弄りだしたところ、nginxの再起動時に叱られるようになりました。
動作には特別支障はないようなので困りはしないのですが、変なメッセージは出ないに越したことはないので、修正しておきたいと思います。

Plaintext
nginx: [warn] 2048 worker_connections exceed open file resource limit: 1024
nginx を停止中:                                             [  OK  ]
nginx を起動中: nginx: [warn] 2048 worker_connections exceed open file resource limit: 1024
                                                           [  OK  ]

 

調べてみると、open files (-n)とmax user processes (-u)に依存するらしいのですが、open files (-n)はデフォルトのままなのに、max user processes (-u)は無茶苦茶な数値に設定されていましたw

Bash
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 60366
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m)
unlimited open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 60366
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

 

ということで、利用できるプロセス数の制限を変更します。

Plaintext
ulimit -u 2048
ulimit -n 2048

 

変更を確認します。

Bash
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 60366
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 2048
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 2048
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited

 

次にnginx.confを開いてwork_connectionsを変更します。

Bash
$ vim /etc/nginx/nginx.conf

worker_connections 2048;

 

これでnginxを再起動しても叱られなくなりました٩(ˊᗜˋ*)و

Plaintext
nginx を停止中:                                             [  OK  ]
nginx を起動中:                                             [  OK  ]

 

最近特に物忘れが激しくなってきた気がするので、覚え書きしておかないとですね…。
ではまた(=゚ω゚)ノシ

コメント

タイトルとURLをコピーしました