hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Hosting Security and Technology : Max open file descriptors stuck at 1024 on CentOS 4?
Reply

Forum Jump

Max open file descriptors stuck at 1024 on CentOS 4?

Reply Post New Thread In Hosting Security and Technology Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 03-12-2006, 08:58 PM
MikeHart MikeHart is offline
Junior Guru Wannabe
 
Join Date: Jul 2005
Posts: 77

Max open file descriptors stuck at 1024 on CentOS 4?


I'm running a server daemon that over 1000 people connect to at the same time and that worked perfectly when running on FreeBSD 5.4. However, when I migrated to CentOS 4, the daemon started outputting "accept: Bad file descriptor" errors on the console when it hit 1024 open file descriptors and disconnecting the users trying to connect. ulimit -n quickly revealed that the open file limit was set to 1024 and responsible for this. I read into how to raise the limit in CentOS and tried the following things (in different combinations):

  • Making sure /proc/sys/fs/file-max was big enough
  • Adding "fs.file-max = 2048" to /etc/sysctl.conf
  • Adding "* - nofile 2048" to /etc/security/limits.conf
  • Adding "session required pam_limits.so" to /etc/pam.d/login and /etc/pam.d/sshd
  • Changing the limit using "ulimit -n 65536" as root
  • Restarting sshd several times
  • Rebooting the machine several times

None of this seemed to work.. in fact at some point the daemon would actually segment fault when it hit the limit instead of disconnecting users attempting to connect... Lowering the limit to 1024 in /etc/security/limits.conf stopped that and brought me back to the bad file descriptor errors. Once again, the same software worked just fine with over 1024 users on FreeBSD 5.4, so I'm pretty sure the crashing isn't the software's fault.

Am I overlooking something in the CentOS config that would cause this? I'm out of ideas.. and I've tried just about anything google would come up with.

Reply With Quote


Sponsored Links
  #2  
Old 03-13-2006, 08:34 AM
InstaCarma_carmen InstaCarma_carmen is offline
Junior Guru Wannabe
 
Join Date: Mar 2006
Posts: 48
Hi,

Just type

ulimit -n <newlimit>

and then check ulimit -n this will show the new limit.

If it is getting changed at the server reboot, then think of adding the above line to

/etc/rc.d/rc.local

Be happy.

Sincerely,
Carmen [carmen@instacarma.com]

__________________
InstaCarma.com
24x7 Technical Support and Server Management

Reply With Quote
  #3  
Old 03-13-2006, 04:18 PM
MikeHart MikeHart is offline
Junior Guru Wannabe
 
Join Date: Jul 2005
Posts: 77
Quote:
Originally Posted by MikeHart
  • Changing the limit using "ulimit -n 65536" as root
Thanks for the reply, but I already tried that... and the problem with it is that you can only do that as root and it only changes the value for root. Normal users still have their own limits and they cannot be changed with ulimit.

Editting /etc/security/limits.conf and then checking ulimit -n again as a normal user does show a change and the bad file descriptor errors stop, but instead any program that tries to access more than 1024 files/connections segment faults.

Reply With Quote
Sponsored Links
  #4  
Old 03-14-2006, 08:51 AM
InstaCarma_carmen InstaCarma_carmen is offline
Junior Guru Wannabe
 
Join Date: Mar 2006
Posts: 48
Hi Mike,

You can set the limits for the groups instead of users to globally change the limits for all the users at once.

You also need to ensure that pam_limits is configured in the /etc/pam.d/system-auth file, or in /etc/pam.d/sshd for ssh, /etc/pam.d/su for su, or /etc/pam.d/login for local logins and telnet if you don't want to enable it for all login methods. Here are the two session entries which you need to have in /etc/pam.d/system-auth file:

session required /lib/security/$ISA/pam_limits.so
session required /lib/security/$ISA/pam_unix.so

Now login to the user account since the changes will become effective for new login sessions only. Note that the ulimit options are different for other shells.

To make the above changes permanent, you could also set the soft limit equal to the hard limit in /etc/security/limits.conf which I prefer:

user/groupname soft nofile 63536
user/groupname hard nofile 63536

Sincerely,
<<Signature to be setup in your profile>>

__________________
InstaCarma.com
24x7 Technical Support and Server Management


Last edited by anon-e-mouse; 04-25-2006 at 01:51 AM.
Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Open Source Collaboration Provider Open-Xchange Launches OX Spreadsheet Tool: WHD.global 2014 Web Hosting News 2014-04-01 11:18:13
Dropbox Suffers Temporary Outage Impacting File Sharing and Synchronizing Web Hosting News 2014-03-14 12:11:46
Red Hat Takes Active Role in CentOS Project to Drive New Technology Adoption Web Hosting News 2014-01-08 12:00:22
Solar VPS Becomes Official Mirror for Centos and Ubuntu Web Hosting News 2013-04-16 11:03:34
Web Host Rackspace Adds FreeBSD 9, CentOS 6.3 Support to Cloud Servers Web Hosting News 2012-07-30 12:47:10


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?