【问题标题】:Open file limit on Ubuntu serverUbuntu 服务器上的打开文件限制
【发布时间】:2018-11-06 18:37:53
【问题描述】:

我的 Java Tomcat 应用程序 (Bitbucket) 托管在 Ubuntu 16.04 上,当超过打开文件限制时,我会收到以下错误。

java.io.IOException: Too many open file

我最初通过在 /etc/security/limits.conf 文件中添加以下行来解决此问题

atlbitbucket hard nofile 8192 
atlbitbucket soft nofile 4096 

然而问题再次出现两次:

  1. 打开文件有上限吗?

  2. 如何每 1 分钟监控一次打开的文件并将其记录下来以绘制图表?

  3. 如何缓解打开文件限制问题以避免上述错误?

【问题讨论】:

    标签: java ubuntu-16.04 bitbucket-server


    【解决方案1】:

    1) Linux 确实有一个上限,通常是足够的(如果你问的是这个)。不过,对于 bitbucket,您可以设置:

    atlbitbucket hard nofile unlimited
    atlbitbucket soft nofile unlimited
    

    2) 使用watch 命令统计每1分钟打开的文件数:

    watch -n 60 ls -l /proc/$$/fd | wc -l
    

    其中 $$ 是 bitbucket 进程的 PID。这不是图表,但您会很清楚发生了什么。

    3) 见 1)

    【讨论】:

    • 谢谢,命令:watch -n 5 'ls -l /proc/123731/fd | wc -l' 在 Ubuntu 16.04 LTS 上为我工作
    • 我们如何根据服务器上的可用资源计算打开文件的 ulimit,是否有任何公式,或者当我们达到最大打开文件列表时,猜测是否会继续增加限制?
    • 从 Redhat 网站得到了答案。每 4MB RAM 256 个。
    猜你喜欢
    • 1970-01-01
    • 2015-07-11
    • 2022-11-13
    • 2014-12-07
    • 1970-01-01
    • 2021-01-05
    • 2019-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多