如何设置全局无文件限制以避免出现“许多打开的文件"的问题.错误? [英] How to set a global nofile limit to avoid "many open files" error?

查看:84
本文介绍了如何设置全局无文件限制以避免出现“许多打开的文件"的问题.错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个websocket服务.发生错误的阶段:打开的文件太多",但是我将系统配置为:

I have a websocket service. it's strage that have error:"too many open files", but i have set the system configure:

/etc/security/limits.conf
*               soft    nofile          65000
*               hard    nofile          65000

/etc/sysctl.conf
net.ipv4.ip_local_port_range = 1024 65000

ulimit -n
//output 6500

所以我认为我的系统配置正确.

So i think my system configure it's right.

我的服务是由主管管理的,可能受到主管的限制吗?

My service is manage by supervisor, it's possible supervisor limits?

由主管启动检查过程:

cat /proc/815/limits
Max open files            1024                 4096                 files 

检查流程手动启动:

cat /proc/900/limits
Max open files            65000                 65000                 files 

原因是使用主管管理服务.如果我重新启动主管并重新启动子进程,则在重新启动系统主管自动启动时,它是最大打开文件数"确定(65000)但错误(1024).

The reason is used supervisor manage serivce. if i restart supervisor and restart child process, it's "max open files" ok(65000) but wrong(1024) when reboot system supervisor automatically start.

超级用户启动时可能是超级用户启动级别太高并且系统配置不起作用吗?

May be supervisor start level is too high and system configure does not work when supervisor start?

系统:ubuntu 12.04 64位

system: ubuntu 12.04 64bit

这不是管理员问题,系统重启后所有进程自动启动都不使用系统配置(最大打开文件数= 1024),但可以重启.

It's not supervisor problem, all process auto start after system reboot are not use system configure(max open files=1024), but restart it's ok.

更新

问题可能是:

  • https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/938669
  • http://bryanmarty.com/blog/2012/02/10/setting-nofile-limit-upstart/
  • Increase max open files for Ubuntu/Upstart (initctl)

现在的问题是,如何设置全局nofile限制,因为我不想在我需要的每个新贵脚本中都设置nofile限制.

Now the question is, how to set a global nofile limit because i don't want to set nofile limit in every upstart script which i need.

推荐答案

我遇到了同样的问题.即使ulimit -Sn显示了我的新限制,运行supervisorctl restart allcat的proc文件也没有显示新的限制.

I had the same problem. Even though ulimit -Sn shows my new limit, running supervisorctl restart all and cating the proc files did not show the new limits.

问题在于supervisord仍然具有原始限制.因此,它创建的任何子进程仍然具有原始限制.

The problem is that supervisord still has the original limits. Therefore any child processes it creates still have the original limits.

因此,解决方案是杀死并重新启动supervisord.

So, the solution is to kill and restart supervisord.

这篇关于如何设置全局无文件限制以避免出现“许多打开的文件"的问题.错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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