增加Ubuntu/Upstart(initctl)的最大打开文件数 [英] Increase max open files for Ubuntu/Upstart (initctl)

查看:147
本文介绍了增加Ubuntu/Upstart(initctl)的最大打开文件数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在Ubuntu 12.04.3 LTS服务器上.

This is on an Ubuntu 12.04.3 LTS server.

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

I've added the following to /etc/security/limits.conf (my Golang processes run as root):

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

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

I've added the following to /etc/pam.d/common-session

session required pam_limits.so

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

I've added the following to /etc/sysctl.conf:

fs.file-max = 50000

但是当我使用/proc/{PID}/limits时,我得到了:

Yet when I cat /proc/{PID}/limits, I get:

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

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

This happens only when I start the process from Upstart via sudo initctl start service_name. If I start the process myself, it acknowledges my settings.

我该如何解决?

推荐答案

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

This needs to be added to your Upstart script for it to work:

limit nofile 50000 50000

这是设计使新贵没有关注的地方 /etc/security/limits.conf用于系统作业.仅PAM设置 适用于用户会话,而不适用于系统服务." https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/938669

"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/Upstart(initctl)的最大打开文件数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆