Its a well known scenario. Linux keeps a max number of open files limit, and we were exceeding it. Its possible to increase the limit, but first we should see if there is any process that may be causing the problem.
This is taken from http://doc.nuxeo.com/display/KB/java.net.SocketException+Too+many+open+files
Count File Descriptors in Use
Count Open File Handles
sudo lsof [-u user] | wc -l |
Count File Descriptors in Kernel Memory
sudo sysctl fs.file-nr# => The number of allocated file handles# => The number of unused-but-allocated file handles# => The system-wide maximum number of file handles |
There is a global limit and a per user limit
Raising the Global Limit
- Edit
/etc/sysctl.confand add the following line:
fs.file-max =65536 - Apply the changes with:
sudo sysctl -p /etc/sysctl.conf
Raising the per-User Limit
On some systems it is possible to use theulimit -Hn 8192 and ulimit -Sn 4096 commands. However most of the time this is forbidden and you will get an error such as:ulimit: open files: cannot modify limit: Operation not permitted |
- Edit as root the following system configuration file:
% sudo vi /etc/security/limits.conf - Modify the values for user
user soft nofile4096user hard nofile8192
* soft nofile 4096* hard nofile 8192 |
% su user% ulimit -n1024 |
To fix this:
- Edit
/etc/pam.d/su:
% sudo vi /etc/pam.d/su - Uncomment the line:
The change should now be taken into account the next time you login with your user:session required pam_limits.so
% su user% ulimit -n4096