I've run ulimit -n 65536
, added the following lines to /etc/security/limits.conf
:
* soft nofile 65536
* hard nofile 65536
alix soft nofile 65536
alix hard nofile 65536
root soft nofile 65536
root hard nofile 65536
And added session required pam_limits.so
to both:
- /etc/pam.d/common-session
- /etc/pam.d/common-session-noninteractive
And fs.file-max = 65536
to /etc/sysctl.d/60-file-max.conf
.
Still, after restarting and running ulimit -n
on my session, I only get 4096 (was 1024 before).
What am I missing?
From the manual:
systemd
has an option for this:But this is also only for the graphical user settings. Remove the
#
and you can set it to 65536.Comment from Daniel Fernández:
might also be needed in
Ubuntu 18.04 Step by Step
Hope all this helps, quite long but it works (with proof)
I came across this thread whilst installing MongoDb on Ubuntu 18.04
https://posidev.com/blog/2009/06/04/set-ulimit-parameters-on-ubuntu/
As you can see it's quite old however it works for me.
Here is what I did.
MongoDb Recommended Settings (https://docs.mongodb.com/manual/reference/ulimit/#review-and-set-resource-limits)
Check my current Limits
Make a note of what requires changing
What does ubuntu say about how to change these limits?
Here is the start of that file, and look it even has instructions within of course, remember this is open source written by the good guys! :)
Here are my changes: -
Finally, finally, remember this in the man limits.conf entry.
limits.conf - configuration file for the pam_limits module
Better make sure that the pam_limits module is loaded so all this limits stuff works. To do this you edit /etc/pam.d/common-session. Of course this is also in the man page.
A reboot will show the limits (for user mongodb) have been applied. If you applied them using '*' instead, you can check without having to switch to the mongodb user. Just execute this command.
As you can see, lubbly jubbly all set to the limits we wanted.
I had the same problem on Ubuntu 20.04.
The only file that needed to be changed was
/etc/security/limits.conf
. Appending the line* - nofile 100000
to that file and re-login in did the trick: