本文主要是介绍nginx 出错:socket() failed (24: Too many open files) while connecting to upstream,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1. 错误描述
通过nginx负载两个节点的rabbitmq
当用java代码创建超过500个连接时(我的机器默认只能创建这么多),出现错误:
com.rabbitmq.client.ShutdownSignalException: connection error
java.net.SocketException: Software caused connection abort: recv failed
查看nginx日志/var/log/nginx/error.log,发现错误
socket() failed (24: Too many open files) while connecting to upstream
解决
- 修改linux打开文件句柄数,编辑vi /etc/security/limits.conf,添加
<domain> <type> <item> <value>
* soft nofile 204800
* hard nofile 204800
- 修改nginx打开文件数, 编辑nginx.conf,添加worker_rlimit_nofile值
worker_processes 1;
worker_rlimit_nofile 20480;
重启nginx后问题解决
这篇关于nginx 出错:socket() failed (24: Too many open files) while connecting to upstream的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!