【问题标题】:Too many open files throwing an IOException太多打开的文件引发 IOException
【发布时间】:2016-07-18 14:16:05
【问题描述】:

我在 Amazon 上运行我的应用程序,我部署了一个按租户和日期分隔日志文件的版本,这意味着有一次我的环境不接受更多请求,引发 IOException。

29-Mar-2016 11:56:07.939 SEVERE [http-nio-8080-Acceptor-0] org.apache.tomcat.util.net.NioEndpoint$Acceptor.run Socket accept failed
 java.io.IOException: Too many open files
    at sun.nio.ch.ServerSocketChannelImpl.accept0(Native Method)
    at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:241)
    at org.apache.tomcat.util.net.NioEndpoint$Acceptor.run(NioEndpoint.java:688)
    at java.lang.Thread.run(Thread.java:745)

我该如何解决这个问题?

【问题讨论】:

  • 从 Tomcat 的 conf/server.xml 发布您的 <Connector> 配置。此外,您可能希望以“是一个问题”的形式表达您的问题,而不是“有人看过这个”?也许“我该如何解决这个问题”?
  • 您是在专门询问 AWS,但您的问题只是一般的 Linux 问题。如果你搜索“Linux too many files open”,你会找到很多答案。例如:stackoverflow.com/questions/20901518/ubuntu-too-many-open-files
  • 谢谢@ChristopherSchultz

标签: linux unix tomcat logging


【解决方案1】:

今天碰到这个问题。 事实证明,打开文件描述符(本质上是一个唯一标识打开文件的数字)有一个软限制。这些限制是按进程设置的。

$ ulimit -S -n
256
$ ulimit -S -n 1024
1024
Syntax
      ulimit [-abcdefHilmnpqrsStTuvx] [limit]

Key
   -S   Set a soft limit for the given resource.
   -n   The maximum number of open file descriptors. 

参见文档https://ss64.com/bash/ulimit.html

【讨论】:

    【解决方案2】:

    我按照那个教程解决了我的问题

    https://easyengine.io/tutorials/linux/increase-open-files-limit/

    【讨论】:

      猜你喜欢
      • 2011-01-03
      • 2011-05-16
      • 1970-01-01
      • 2012-07-05
      • 1970-01-01
      • 1970-01-01
      • 2020-09-30
      • 1970-01-01
      相关资源
      最近更新 更多