nginx 错误日志:
2016/02/28 21:07:36 [alert] 11569#0: *41512 socket() failed (24: Too many open files) while connecting to upstream, client: 192.168.1.110, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "192.168.1.218" 2016/02/28 21:07:36 [alert] 11569#0: *41512 socket() failed (24: Too many open files) while connecting to upstream, client: 192.168.1.110, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "192.168.1.218"
解决办法:
三、打开文件最大数设置
查看打开文件最大数
ulimit -a
设置一
ulimit -HSn 102400 #只是当前shell有效
设置二
(1)ulimit -HSn 102400
(2)将ulimit -HSn 102400写到/etc/profile中,因为每次登录终端时,都会自动执行/etc/profile。
(3)令修改open files的数值永久生效,则必须修改配置文件:vi /etc/security/limits.conf. 在这个文件后加上:
* soft nofile 102400
* hard nofile 102400
这种方法需要重启机器才能生效。
另一个,查看下nginx的配置文件。
查看 worker_rlimit_nofile 配置项
worker_rlimit_nofile 655350;