如何在Ubuntu 12.4上更改* default * open-file limit

时间:2015-09-29 23:20:15

标签: azure ubuntu-12.04 ulimit

我们有Ubuntu 12.04 LTS服务器,包括本地和托管在Azure中。 虽然我们可以更改交互登录用户的文件限制,但默认情况下,init.d启动的服务似乎获得了4096的硬开放文件限制。虽然我们可以使用upstart并为特定服务设置更高的限制,但这并不是#39; t帮助我们,比如Hortonworks HDP,它使用自己的机制运行各种服务。我想要的是更改所有的系统范围默认开放文件限制。我们怎么做?

1 个答案:

答案 0 :(得分:1)

<强> 1。检查系统范围设置:/etc/security/limits.conf

一个非常无限制的配置文件:

*               soft    nofile  102400
*               hard    nofile  102400
*               soft    nproc   102400
*               hard    nproc   102400
root            hard    nofile  102400
root            soft    nofile  102400

<强> 2。检查程序自动启动脚本及其设置

程序自动启动脚本略有不同,它有自己的设置,或者它会使用默认的1024

示例:程序主管(在Ubuntu 12/14上测试)

/etc/init.d/supervisor - auto startup script
/etc/init/supervisor.conf - auto startup script settings

您可以在 /etc/init.d/supervisor 中添加 ulimit 命令来设置限制,或者只需在 / etc / init /中添加限制设置supervisor.conf 即可。 /etc/init/supervisor.conf 示例:

limit nofile 102400 102400

第3。检查程序特定设置

某些程序有其自身的限制。与主管一样,它有自己的文件/进程限制,因此您还必须在其配置文件 /etc/supervisor/supervisord.conf上添加 minfds minprocs 设置即可。其他一些程序只使用系统或自动启动设置。