【问题标题】:Increase max open files for Ubuntu/Upstart (initctl)增加 Ubuntu/Upstart (initctl) 的最大打开文件数
【发布时间】:2013-11-15 07:37:13
【问题描述】:

这是在 Ubuntu 12.04.3 LTS 服务器上。

我已将以下内容添加到 /etc/security/limits.conf(我的 Golang 进程以 root 身份运行):

*      hard   nofile   50000
*      soft   nofile   50000
root   hard   nofile   50000
root   soft   nofile   50000

我已将以下内容添加到 /etc/pam.d/common-session

session required pam_limits.so

我已将以下内容添加到 /etc/sysctl.conf:

fs.file-max = 50000

然而,当我 cat /proc/{PID}/limits 时,我得到:

Limit                     Soft Limit           Hard Limit           Units     
Max open files            1024                 4096                 files     

只有当我通过 sudo initctl start service_name 从 Upstart 启动进程时才会发生这种情况。如果我自己启动该过程,它会确认我的设置。

我该如何解决这个问题?

【问题讨论】:

    标签: ubuntu file-descriptor upstart


    【解决方案1】:

    这需要添加到您的 Upstart 脚本中才能正常工作:

    limit nofile 50000 50000
    

    “暴发户不看是设计使然 /etc/security/limits.conf 用于系统作业。 PAM 设置仅 应用于用户会话,而不是系统服务。”来自 https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/938669

    来源:

    https://github.com/saltstack/salt/issues/5323

    http://bryanmarty.com/blog/2012/02/10/setting-nofile-limit-upstart/

    【讨论】:

      猜你喜欢
      • 2012-03-17
      • 2014-02-26
      • 1970-01-01
      • 2016-01-24
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多