zoukankan      html  css  js  c++  java
  • nginx提示Error: Too many open files的解决办法

      nginx提示:Too many open files这种错误问题的原因是因为linux文件系统最大可打开文件数为1024,而你的nginx中的error.log出现大量的Too many open files,说明文件句柄不够用了所以就错误提示出来了。

      如果nginx的error.log出现大量的Too many open files,说明文件句柄不够用了,这时候我们需要加大系统的文件句柄数和nginx的允许最大的连接数

      默认情况下linux文 件系统最大可打开文件数为1024,对于一个应用于生产环境下的服务器来说,这个设置太小,例如在用nginx做web服务器,当并发达到一定数量时,可以看到error.log里出现大量的“Nginx accept() failed (24: Too many open files)” 的错误。

      

      正确设置Linux的ulimit -n的值的步骤如下:

      1.先用命令ulimit -n 查看目前的值

      2. vim /etc/security/limits.conf

        建议把下面两项都设置为65535

        * soft nofile 65535 

        * hard nofile 65535

        (前面的*星号代表全局,针对所有的用户;nofile代表文件句柄数量;soft nofile的值不能超过hard nofile的值

      3.vim /usr/local/nginx/conf/nginx.conf 

        找到worker_connections ,把值调大一些,比如加个0

      4.重启Linux系统

        命令:shutdown -r now 表示立即重启

     

    如果您阅读过此文章有所收获,请为我顶一个,如果文章中有错误的地方,欢迎指出。

    相互学习,共同进步!

     

  • 相关阅读:
    Wannafly挑战赛21A
    luoguP4000 斐波那契数列
    关于斐波那契数模意义下的循环节问题
    Codeforces Round #501 (Div. 3) F. Bracket Substring
    1257: [CQOI2007]余数之和
    51nod1380 夹克老爷的逢三抽一
    51nod1423 最大二"货" 单调栈
    51nod1624 取余最长路 前缀和 + set
    51nod1437 迈克步 单调栈
    51nod1515 明辨是非 并查集 + set
  • 原文地址:https://www.cnblogs.com/zhangxiaoliu/p/5103031.html
Copyright © 2011-2022 走看看