[Centos] permanent ulimit -n on CentOS 3.4

Thu Feb 24 06:16:39 UTC 2005
Mike Obvious <mike4mike at gmail.com>

Thanks, Barry.

It helps, but with some questions.
I did it from console and from ssh logged as root - the same
#ulimit -Hn
1024

But if I do login as a user ( from console or from ssh - the same
result) - I will have 16384. su - still 16384.

See (ssh session):

[root at NAFNAF root]# ulimit -Hn
1024
[root at NAFNAF root]# su user1
Password:
[user1 at NAFNAF root]$ ulimit -n
16384
[user1 at NAFNAF root]$ ulimit -Hn
16384
[user1 at NAFNAF root]$ su root
Password:
[root at NAFNAF root]# ulimit -n
16384

So, at this point I not sure how many files will have  my application
running as root.
I put this:
echo "ulimit -Hn, -n:" >> /root/ulimit.log
ulimit -Hn >> /root/ulimit.log
ulimit -n >> /root/ulimit.log
at the beginning of the script running my app.
And it gave me 1024.
Sure I can say in the same script ulimit -n 16384 and it works.
Any comments on this?

Mike

On Wed, 23 Feb 2005 21:39:45 -0600, Barry Brimer
<barry.brimer at bigfoot.com> wrote:
> Quoting "C. Linus Hicks" <lhicks at nc.rr.com>:
> 
> > On Wed, 2005-02-23 at 21:50 -0500, Mike Obvious wrote:
> > > Hi!
> > >
> > > Question from the novice.
> > >
> > > I have to permanently increase number of opened files ( ulimit -n 16384 and
> > > ulimit -Hn 16384) for some application.
> > > I did custom kernel based on
> > >
> > >
> >
> https://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/sysadmin-guide/s1-custom-kernel-modularized.html
> > >
> > > and application documentation ( written for RH 9), no error during all
> > makes
> > > but I have panic during the boot. ( It's Dell SC1425, dual CPU, 2GB RAM,
> > > i686-based kernel).
> > >
> > > Is there any other way to do it ?
> >
> > Look in /etc/security/limits.conf
> 
> To keep number of opened files at 16384 do the following
> 
> Append this to your /etc/security/limits.conf
> ====================
> * soft nofiles 16384
> * soft nofiles 16384
> ====================
> Append this to your /etc/sysctl.conf
> ===================
> fs.file-max = 16384
> ===================
> Type sysctl -p to reread your sysctl.conf file.  This will also syntax check
> your sysctl.conf file for you.
> 
> Log out, and log back in to complete this task and reread your environment with
> the new settings.
> 
> Important note: Centos 3.x uses a privelege separated sshd by default.  You can
> disable this functionality if needed in /etc/ssh/sshd_config.  Basically, sshd
> runs as the user connecting to it, instead of root.  Since root is the only
> user who can change ulimit settings, you will be unable set ulimit settings as
> an unprivelged user in an ssh session.  The way to test this is to make the
> changes above and log in at the console.  Typing ulimit -n should work
> correctly.  If you ssh to the server, and type ulimit -n it will show the
> default (probably 1024).  If you su - user and then type ulimit -n it should
> show the correct number (16384)
> 
> Hope this helps.
> 
> Barry
> _______________________________________________
> CentOS mailing list
> CentOS at caosity.org
> http://lists.caosity.org/mailman/listinfo/centos
>