nginx 报Too many open files

nginx 异常报 Too many open files

  • 上周时,nginx已经报 Too many open files 当时把
    配置文件调整最大连接65535了,reload 重新加载nginx后不报错了。
cat    /proc/14921/limits |grep  "Max open file"
*		soft	nofile		65535
*		hard	nofile		65535

cat /etc/sysctl.conf 
net.ipv4.tcp_tw_reuse = 1 
net.ipv4.tcp_tw_recycle = 1

  • 以为没问题了, 结果今天又报错Too many open files

  • 这就奇怪了,配置都已经修改了,为什么还会报Too many open files
  • 最后看了下进程的limit限制,发现nginx主进程软限制是1024,硬限制是4096。
[root@xxxx log]# ps -ef|grep nginx|grep -v shutting
root      4334     1  0  2023 ?        00:00:02 nginx: master process /usr/local/nginx/sbin/nginx
nobody   12350  4334  0 3月15 ?       00:02:18 nginx: worker process
nobody   14918  4334  0 11:29 ?        00:00:01 nginx: worker process
nobody   14919  4334  0 11:29 ?        00:00:00 nginx: worker process
nobody   14920  4334  0 11:29 ?        00:00:01 nginx: worker process
nobody   14921  4334  0 11:29 ?        00:00:01 nginx: worker process
nobody   14922  4334  0 11:29 ?        00:00:01 nginx: worker process
nobody   14923  4334  0 11:29 ?        00:00:02 nginx: worker process
nobody   14924  4334  0 11:29 ?        00:00:01 nginx: worker process
nobody   14925  4334  0 11:29 ?        00:00:03 nginx: worker process
root     21621 16905  0 11:46 pts/3    00:00:00 grep --color=auto nginx

[root@xxx log]#  cat /proc/4334/limits
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             124951               124951               processes 
Max open files            1024                 4096                 files     

[ccodrunner@xxxx ]$ cat    /proc/14921/limits |grep  "Max open file"
Max open files            65535                65535                files   
  • 看nginx主进程是2023年启动时间,可能是在启动nginx时,当时文件打开数为进行配置时,未重启nginx主进程,才导致最近业务量增加,经常出现无法创建打开文件数情况。
  • 最后等晚上重启nginx主进程,待记录观察。

相关推荐

  1. nginx错相关问题

    2024-03-18 16:16:02       15 阅读
  2. WordPress Nginx 错 502 Bad Gateway

    2024-03-18 16:16:02       86 阅读
  3. 解决 nginx 504 Gateway Time-out错问题

    2024-03-18 16:16:02       42 阅读
  4. Nginx 错 504 Gateway Time-out 的解决方法

    2024-03-18 16:16:02       19 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-18 16:16:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-18 16:16:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-18 16:16:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-18 16:16:02       20 阅读

热门阅读

  1. C++中内存泄露的几种情况?

    2024-03-18 16:16:02       21 阅读
  2. 对对架构决策记录的一些思考

    2024-03-18 16:16:02       18 阅读
  3. python 炸敌人。

    2024-03-18 16:16:02       22 阅读
  4. LeetCode 面试经典150题 45.跳跃游戏II

    2024-03-18 16:16:02       19 阅读
  5. [自研开源] MyData v0.7.2 更新日志

    2024-03-18 16:16:02       21 阅读