本文介绍了增加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

来源:

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

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

这篇关于增加Ubuntu/Upstart(initctl)的最大打开文件数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 14:19