Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

we are having a problem with the maximum limit of open file descriptors. After configuring the server with the settings mentioned below we test to see if the the max open file descriptor is set to 10000 right after a reboot to see if the settings remain like so, ulimit -Hn and ulimit -Sn or ulimit -a. The values reported (10000) are correct.

When we run our java application, we hit a maximum of 4096 open file descriptors until we get java.net.ConnectException.

I run watch -n 1 -x cat /proc/sys/fs/file-nr to check the number of open files and it report 4448 when the exception occurs which is normal, because before running the jar there are 352 reported.

The kernel being run is in the title of this post Ubuntu 11.04 (GNU/Linux 2.6.38-8-virtual x86_64) and i'm wondering if this could be the problem?

We have configured the following on our system

/etc/security/limits.conf

Add the following 2 lines to the file. The asterisk simply means that the rule will apply to all users.

root soft nofile 10000
root hard nofile 10000
(our ssh user) soft nofile 10000
(our ssh user) hard nofile 10000

/etc/pam.d/common-session

Add the following line:

session required pam_limits.so

Save the file and exit.

Increase the maximum number of open files by setting a new value in kernel variable /proc/sys/fs/file-max as follows (login as the root):

sysctl -w fs.file-max=65000

Edit /etc/sysctl.conf file and append the following line so that after reboot the setting will remain as it is:

fs.file-max = 65000

Reboot the server to apply changes.

share|improve this question
    
How are you starting the Java application? Are you SSHing in and then running java, or is it an /etc/init.d service? Is the java executable run directly or is something else used to spawn it (like start-stop-daemon)? Which user does it run as? What does /proc/<pid>/limits show (where <pid> is the PID of the Java application)? –  mgorven Mar 25 '12 at 23:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.