nginx服务器出现如下信息:
[crit] 17221#0: accept4() failed (24: Too many open files) [crit] 17221#0: accept4() failed (24: Too many open files) [crit] 17221#0: accept4() failed (24: Too many open files) [crit] 17221#0: accept4() failed (24: Too many open files) [crit] 17221#0: accept4() failed (24: Too many open files)
原回是nginx进程打开文件数过多
解决方法:
修改/etc/security/limits.conf文件
* soft nofile 10240 * hard nofile 10240
星号代表全局,soft为软件,hard为硬件,nofile为这里指可打开文件数。
root soft nofile 10240 root hard nofile 10240 nobody soft nofile 10240 nobody hard nofile 10240
修改nginx.conf,添加如下代码:
worker_rlimit_nofile 10240;
重启nginx服务器。