gpt4 book ai didi

ubuntu - 增加 Ubuntu/Upstart 的最大打开文件数(initctl)

转载 作者:太空宇宙 更新时间:2023-11-03 16:43:06 25 4
gpt4 key购买 nike

这是在 Ubuntu 12.04.3 LTS 服务器上。

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

*      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 启动进程时才会发生这种情况。如果我自己启动该过程,它会确认我的设置。

我该如何解决这个问题?

最佳答案

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

limit nofile 50000 50000

"It's by design that upstart does not look at /etc/security/limits.conf for system jobs. PAM settings are only applied to user sessions, not to system services." from 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/

关于ubuntu - 增加 Ubuntu/Upstart 的最大打开文件数(initctl),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19995855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com