ulimit on CentOS 8.1

https://dev.to/onichandame/ulimit-on-centos-8-1-3md3

ulimit on CentOS 8.1





In /etc/security/limits.conf 


*          soft nofile 32767
*          hard nofile 65535
[username] soft nofile 32767
[username] hard nofile 65535



/etc/systemd/user.conf
DefaultLimitNOFILE=65535



1. `/etc/security/limits.conf` works for processes not under the control of systemd. Therefore, since (for example) my Gnome Terminal is running under systemd, `limits.conf` doesn't affect my Terminal's `ulimit`.

2. `/etc/systemd/user.conf` translates as roughly what controls the soft limits for your `ulimit`.

3. `/etc/systemd/system.conf` acts roughly as the hard limit.




Problem

On a fresh-installed Centos 8.1(kernel 4.18.0-147.8.1.el8_1) machine, the max number of opened file descriptors is set to H: 2048, S: 1024.

By editing /etc/security/limits.conf the limits can be upped. But this only takes effect in non-gnome-terminals, such as ssh sessions.

Cause

The gnome terminals do not see /etc/security/limits.conf during login as they are started under systemd(I hate it).

Fix

According to this/etc/systemd/user.conf sets the soft limit and /etc/systemd/system.conf sets the hard limit for the user under systemd. The variable for file descriptors is DefaultLimitNOFILE.

If you are using Node.js, one more step is required: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p according to this issue.

ความคิดเห็น