12

I cannot seem to figure out what exactly is needed to allow the maximum number of file descriptors to be raised permanently for all users.

/etc/security/limits.conf:

root    hard    nofile    1500000
root    soft    nofile    1000000
root    hard    nproc     15000
root    soft    nproc     10000
*       hard    nofile    1500000
*       soft    nofile    1000000
*       hard    nproc     15000
*       soft    nproc     10000

I have placed the following in the /etc/pam.d/common-session:

session required pam_limits.so

After a reboot, logging in as any user and issuing ulimit -n resulted in 1024.

After that, I tried requiring pam_limits.so into every file under /etc/pam.d. Rebooted. Logged in. No such luck.

If I issue the command ulimit -n 1000000, then check, the limit is set as expected. So, I placed @reboot ulimit -n 1000000 into crontab -e. Rebooted. Logged in. No luck.

I checked /etc/ssh/sshd_config and PAM is enabled.

I have tried setting the limits on every reboot with:

/sbin/sysctl -w fs.file-max=1000000
/sbin/sysctl -p

No luck.

I have a server that has a ton of concurrent traffic, and need those limits that high, because it takes the server a very long time to clear out file descriptors. What do I have to do in order to permanently raise the file descriptor limit?

11

I increased the number of files limits for everyone this way (segment from /etc/security/limits.conf):

#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open files (Doug: - so Samba will not complain)
* - nofile 16384
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)

That was on a 12.04 server. However, I tested 100000 on my 14.04 server and it worked fine.

~/config/security$ ulimit -n
16384
| improve this answer | |
  • 2
    That still had no effect. Did you have to place session require pam_limits.so anywhere? – w3rthl3ss Apr 9 '15 at 0:57
  • No. I just did the edit, as sudo, and re-booted, before the ulimit was 1024 and after the ulimit on my 14.04 test server was 100000. – Doug Smythies Apr 9 '15 at 1:17
  • Simply adjusting /etc/security/limits.conf and reverting everything else back to stock worked. Thanks! – w3rthl3ss Apr 9 '15 at 2:12
  • No need to reboot, just logout/login. – Jacob Apr 10 '17 at 23:11
  • @w3rthl3ss what does your limit.conf looks like i have same issue and reference purposes – Rizwan Patel Jul 20 '17 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.