在启动 nginx 时,由于配置了以下信息:
events {
worker_connections 1024;
}
控制台会出现警告提示信息:
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
这是因为 Linux 下,每个进程默认可打开的文件句柄数量为 256 个:
[L@Mac] nginx $ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 256
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1418
virtual memory (kbytes, -v) unlimited
需要注意其中一行:
open files (-n) 256
可使用下面命令对默认数量进行更改:
[L@Mac] nginx $ ulimit -n 1024
看看更改后的数值:
[L@Mac] nginx $ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 1418
virtual memory (kbytes, -v) unlimited
再次启动 nginx,就不会提示了。
原文:https://www.cnblogs.com/liuhe688/p/14716220.html