Increase the number of file descriptors on Centos and Fedora Linux

Raising the number of file descriptors for a regular user on CentOS/Fedora/Redhat is surprisingly difficult to learn how to do. There are lots of incomplete walk throughs on the web, some with typos and other problems.

Here are the steps that worked for me to raise the open file descriptor limit from 1024 (the default) to 65535:

1. As root, edit /etc/sysctl.conf and add the line:

fs.file-max = 512000

2. At the bash prompt, run:

$ sysctl -p

That will cause the settings to take effect. You can also `cat 512000 > /proc/sys/fs/file-max` but that may reset on reboot.

3. Edit /etc/security/limits.conf and add the following:

* - nofile 65535

See the inline comments for more details on what that does and how to make it more restrictive if you prefer.

4. As root, run

$ ulimit -n 65535

and make sure you have no errors. To double check, run `ulimit -n` and make sure the response is 65535.

4. Ensure that PAM authentication is turned on for SSH, or else when you try to connect as a regular user, you won’t see the new limits. Edit /etc/ssh/sshd_config and make sure you have:

UsePAM yes

Restart SSH `/sbin/service sshd restart` if you made any changes.

6. Login as a regular user with a new SSH session & shell and run:

$ ulimit -n 65535

Run `ulimit -n` again to check and good luck!

Tuesday, January 5, 2010 — 1 note
blog comments powered by Disqus
  1. benjaminsteinpro posted this