欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Nginx之——nginx:accept failed 24: Too many open files

程序员文章站 2022-04-11 16:20:14
...
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/51425325

有一台服务器访问量非常高,使用的是nginx ,错误日志不停报以下错误:

2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)
2016/05/16 08:53:49 [alert] 13576#0: accept() failed (24: Too many open files)

解决方法:

centos5.3 中 ulimit -n 为1024, 当Nginx连接数超过1024时,error.log中就出现以下错误:

[alert] 12766#0: accept() failed (24: Too many open files)

使用 ulimit -n 655350 可以把打开文件数设置足够大, 同时修改nginx.conf , 添加 worker_rlimit_nofile 655350; (与error_log同级别)

这样就可以解决Nginx连接过多的问题,Nginx就可以支持高并发。还要修改nginx