6.9. The file-max parameter

The file-max file /proc/sys/fs/file-max sets the maximum number of file-handles that the Linux kernel will allocate. We generally tune this file to improve the number of open files by increasing the value of /proc/sys/fs/file-max to something reasonable like 256 for every 4M of RAM we have: i.e. for a machine with 128 MB of RAM, set it to 8192 - 128/4=32 32*256=8192.

The default setup for the file-max parameter under Red Hat Linux is: "4096" To adjust the value of file-max to 128 MB of RAM, type the following on your terminal:

Version 6.1 only


          [root@deep] /# echo "8192" >/proc/sys/fs/file-max
          
Add the above commands to the /etc/rc.d/rc.local script file and you'll not have to type it again the next time your server reboots.

Version 6.2 only

Edit the /etc/sysctl.conf file and add the following line:

          # Improve the number of open files
          fs.file-max = 8192
          
You must restart your network for the change to take effect. The command to manually restart the network is the following:

          [root@deep] /# /etc/rc.d/init.d/network restart
          

Setting network parameters [ OK ] Bringing up interface lo [ OK ] Bringing up interface eth0 [ OK ] Bringing up interface eth1 [ OK ]

Tip: When you regularly receive from your server a lot of messages with errors about running out of open files, you might want to raise this limit. The default value is 4096. A file server or web server needs a lot of open files.