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后问题解决