How to set a global nofile limit to avoid “many open files” error?

随声附和 提交于 2019-11-28 18:40:30

Fixed this issue by setting the limits for all users in the file :

$ cat /etc/security/limits.d/custom.conf
* hard nofile 550000
* soft nofile 550000

REBOOT THE SERVER after setting the limits.

VERY IMPORTANT: The /etc/security/limits.d/ folder contains user specific limits. In my case hadoop 2 (cloudera) related limits. These user specific limits would override the global limits so if your limits are not being applied, be sure to check the user specific limits in the folder /etc/security/limits.d/ and in the file /etc/security/limits.conf.

CAUTION: Setting user specific limits is the way to go in all cases. Setting the global (*) limit should be avoided. In my case it was an isolated environment and just needed to eliminate file limits issue from my experiment.

Hope this saves someone some hair - as I spent too much time pulling my hair out chunk by chunk!

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.

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

So, the solution is to kill and restart supervisord.

Try to edit /etc/sysctl.conf and adjust the limits globally For example:

Forces the limit to 100000 files.

vi /etc/sysctl.conf

Append:

fs.file-max = 100000

Save and close the file. Users need to log out and log back in again to changes take effect or just type the following command:

sysctl -p

To any weary googlers: you might be looking for the minfds setting in the supervisor config. This setting seems to take effect for both the supervisord process as well as the children. I had a number of other strategies, including launching a shell script that set the limits before executing the actual program, but this was the only thing that worked.

You can find you limit with:

 cat /proc/sys/fs/file-max

or sysctl -a | grep file

change it in /proc/sys/fs/file-max file or with:

sysctl -w fs.file-max=100000

luqmaan's answer was the ticket for me, except for one small caveat: the * wildcard doesn't apply to root in Ubuntu (as described in limits.conf's comments).

You need to explicitly set the limit for root if supervisord is started as the root user:

vi /etc/security/limits.conf

root soft nofile 65535
root hard nofile 65535

Can you set the limit on Service on this way:

add: LimitNOFILE=65536 in: /etc/systemd/system/{NameofService}.service

I think this has nothing to do with opened files(It's just wrong error message). Any port that your application uses in use. 1. Try to find the process ID with command

ps aux

2. Kill the process (for example 8572) with command

sudo kill -9 8572

3. Start your application again.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!