[CentOS] Troubleshooting "too many open files'

Sun May 7 06:42:45 UTC 2006
Marco Garza <testuser at ccskavenger.info>

----- Original Message ----- 
From: "Michael Rock" <mikerocks65 at yahoo.com>
To: <centos at centos.org>
Sent: Sunday, May 07, 2006 12:40 AM
Subject: [CentOS] Troubleshooting "too many open files'

> ulimit -n was 1024, so I am assuming that is likely
> the problem.  So if I understand your reply correctly,
> I can do a 'ulimit -n 8192' to increase the value, but
> that is only for the session?
> Since I have the program starting at bootup what you
> are saying is I need to edit these files and reboot,
> Then ulimit -n should show whatever I set it to below?
> FD_SETSIZE defined in:
> /usr/include/linux/posix_types.h
> /usr/include/bits/typesizes.h
> #define __FD_SETSIZE    8192
> Do I have that right? thx

I have always used ulimit -HSn 8192 in the startup of the program.  for 
example, I used it in /etc/rc.d/init.d/squid like so:

start() {
    ulimit -HSn 8192
    echo 8192 > /proc/sys/fs/file-max
    echo 1024 32768 > /proc/sys/net/ipv4/ip_local_port_range
    echo 4096 > /proc/sys/net/ipv4/tcp_max_syn_backlog

    for adir in $CACHE_SWAP; do
        if [ ! -d $adir/00 ]; then
             echo -n "init_cache_dir $adir... "
             $SQUID -z -F -D 2>/dev/null

You might have to re-compile the program so that it can use these settings. 
I have to re-compile squid with these values entered or it defaults to 1024.