Nginx:[emerg] socket()失败(24:打开的文件过多)

时间:2016-11-03 06:02:46

标签: nginx webserver

我可以看到为这个问题创建了更多的线程。尝试了这些线程中提到的所有解决方案。但是没有一个选项适合我。所以我正在创建这个新线程。

  

操作系统:CentOS 7.2.1511

     

Nginx:1.10.0

错误讯息:

Nov  2 23:21:36 localhost nginx: Starting nginx: nginx: [emerg] socket() x.x.x.x:80 failed (24: Too many open files)
Nov  2 23:21:36 localhost nginx: [FAILED]
Nov  2 23:21:36 localhost systemd: nginx.service: control process exited, code=exited status=1
Nov  2 23:21:36 localhost systemd: Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3 proxy server.
Nov  2 23:21:36 localhost systemd: Unit nginx.service entered failed state.
Nov  2 23:21:36 localhost systemd: nginx.service failed.

Ulimit价值:

[root@serv1 nginx]# ulimit -n
16000
[root@serv1 nginx]# 

sysctl.conf的:

fs.file-max = 752415

nginx.conf:

worker_rlimit_nofile 30000;

nginx用户Ulimit:

[nginx@serv1 ~]$ ulimit -Sn
16000
[nginx@serv1 ~]$ ulimit -Hn
16000
[nginx@serv1 ~]$ 

Nginx PID max打开文件限制:

Max open files            1024                 4096                 files

不确定,为什么打开文件限制不会反映到nginx进程。当我从proc目录检查pid限制值时。它显示如上所述的默认值。软件和软件的值应为16000。硬限制。

另外,我检查了nginx进程的服务器上的openfiles限制。它没有超过1042。

openfiles:

[root@serv1 ~]# ps -ef | grep nginx
root      4285     1  0 23:12 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/conf/nginx/nginx.conf
nginx     4286  4285  0 23:12 ?        00:00:00 nginx: worker process
root      4308  4290  0 23:12 pts/1    00:00:00 grep --color=auto nginx
[root@serv1 ~]# lsof -p 4285 | wc -l 
1042
[root@serv1 ~]# 

有人请帮我解决这个问题。感谢。

1 个答案:

答案 0 :(得分:0)

发现问题。由于nginx.service文件未创建,因为nginx是手动编译的。一旦创建了nginx.service文件并在文件中添加了limitonfile值,修复了我的问题。

希望,这可能对那些遇到这个问题的人有所帮助。