Fixing the "Too many open files" error

    Problem

    The default number of open files on Red Hat Linux 5 is 1024.  Jive SBS requires a much higher limit for this.  Not only does Jive open and close several files at once, but connections to ports are bundled in this limit as well.  When a connection to a port is closed, it can hang in an open state for up to 3 minutes.  If these connections are opened and closed rapidly, the number of open files can quickly spike to the limit.

     

    If you reach the limit of open files, you will see something similar to this in the logs:

    20:35:28,667 [http-0.0.0.0-9001-Acceptor-0] ERROR org.apache.tomcat.util.net.AprEndpoint - Socket accept failed
    I20:35:28,667 [http-0.0.0.0-9001-Acceptor-0] ERROR org.apache.tomcat.util.net.AprEndpoint - Socket accept failed
    org.apache.tomcat.jni.Error: Too many open files
     at org.apache.tomcat.jni.Socket.accept(Native Method)
     at org.apache.tomcat.util.net.AprEndpoint$Acceptor.run(AprEndpoint.java:1128)
     at java.lang.Thread.run(Thread.java:619)
    
    

     

    Fix Version

    In 4.5.5.0 it is not possible to install the RPM without first increasing the number of open files.

     

    Solution

    To fix this problem, increase the soft limit to 8192 and the hard limit to 65535 by following the steps below.

     

    1. Edit /etc/security/limits.conf and add the lines:

    *       soft    nofile  8192
    *       hard    nofile  65535

     

    2. Edit /etc/pam.d/login, adding the line:

    session required /lib/security/pam_limits.so