Nov 10, 2018

How to solve: Too many open files;

System-wide file descriptors Limits

Check maximum number of open file descriptors:

# cat /proc/sys/fs/file-max


# sysctl fs.file-max
fs.file-max = 1845212

You can increase the maximum number of open files by setting a new value in kernel variable /proc/sys/fs/file-max as follows:

# sysctl -w fs.file-max=1845288

You need to edit /etc/sysctl.conf file and put following line so that after reboot the setting will remain as it is:

# vi /etc/sysctl.conf

Append a config directive as follows:

fs.file-max = 1845288

Save and close the file. Users need to log out and log back in again for changes to take effect or just type the following command:

# sysctl -p

User Level file descriptors Limits

The ulimit command provides control over the resources available to the shell and/or to processes started by it.

Check current limit (soft and hard) of the user:

# ulimit -n
# ulimit -Hn
# ulimit -Sn

You can change the limit httpd (or any other users) user to specific limits by

ulimit -n 500000

It is ok before next restart.

For permanent changes, editing /etc/security/limits.conf file:

# vi /etc/security/limits.conf

Set httpd user soft and hard limits as follows:

httpd soft nofile 4096

httpd hard nofile 500000

You can check for the current open file handles by java/glassfish/tomcat use lsof:

# lsof | grep glassfish | wc -l