加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

51.Nginx连接数超过1024出错,(24: Too many open files)!

(2016-05-03 10:42:46)
分类: nginx
1.错误:
[crit] 1366#0: accept4() failed (24: Too many open files)
[alert] 1366#0: *4172 socket() failed (24: Too many open files) while connecting to upstream

2.原因:
查看ulimit  -n 为1024, 当Nginx连接数超过1024时,error.log中就出现以下错误: 

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


3.解决方法是:

修改/etc/security/limits.conf

/etc/security/limits.conf 中加入以下内容: 

* soft  nofile 65535
* hard nofile 65535

星号代表全局, soft为软件,hard为硬件,nofile为这里指可打开文件数。

4.另外,要使 limits.conf 文件配置生效,必须要确保 pam_limits.so 文件被加入到启动文件中。查看 /etc/pam.d/login 文件中有:
session required /lib/security/pam_limits.so

me  --->【 session    required     pam_limits.so 】

【保存并关闭,最后重新载入sysctl命令,以使以上改变生效:

sysctl -p】


修改完重新登录(me:另外打开一个ssh)就可以见到效果,可以通过 ulimit -n


5.然后再修改 /usr/local/nginx/conf/nginx.conf

http://s6/mw690/002M8vvwgy71o8Ynj5r25&690Too many open files)!" TITLE="51.Nginx连接数超过1024出错,(24: Too many open files)!" />



参考:http://my.oschina.net/foxidea/blog/91408
          http://www.xuebuyuan.com/213681.html




0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有