linux下tomcat之too many open files

Posted chendeming

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux下tomcat之too many open files相关的知识,希望对你有一定的参考价值。

一、问题表象:

  程序日志报错:java.io.IOException: Too many open files at 

 

二、解决方案:

  1、查看系统允许打开的最大文件数:
    cat /proc/sys/fs/file-max
  2、查看每个用户允许打开的最大文件数:
    ulimit -a
  3、发现系统默认的是open files (-n) 1024,问题就出现在这里。
    在系统文件/etc/security/limits.conf中修改这个数量限制, 在文件中加入内容:
      * soft nofile 65536
      * hard nofile 65536
    另外方法:
      1、使用ps -ef |grep java (java代表你程序,查看你程序进程) 查看你的进程ID,记录ID号,假设进程ID为12
      2、使用lsof -p 12 | wc -l 查看当前进程id为12的 文件操作状况
        执行该命令出现文件使用情况为 1052
      3、使用命令ulimit -a 查看每个用户允许打开的最大文件数
        发现系统默认的是open files (-n) 1024,问题就出现在这里。
      4、然后执行ulimit -n 4096
        将open files (-n) 1024 设置成open files (-n) 4096

 

摘抄自:https://www.aliyun.com/jiaocheng/120721.html
















以上是关于linux下tomcat之too many open files的主要内容,如果未能解决你的问题,请参考以下文章

Too many open files错误与解决方法

Too many open files 问题

解决tomcat too many open files问题

linux系统下too many files open如何定位与解决

Spring Boot OAuth2,使用 Tomcat 和 nginx 验证后出现错误 ERR_TOO_MANY_REDIRECTS

too many open files怎么解决