分类: LINUX
2008-09-07 12:32:39
Tuning file descriptor kernel parameters is non-trivial, and Zeus Support are only able to provide very general advice on how to do this: The best settings for any server will be unique to it and the load that it is designed to handle.
To examine your file descriptor usage as a snapshot in time, use the following
cat /proc/sys/fs/file-nr
Three numbers will be returned, for example:
1022 427 8192
| | |
| | |
| | maximum open file descriptors permitted
| total free allocated file descriptors
total allocated file descriptors since boot
A low value or even 0 in the second column would indicate a lack of available file descriptors.
In current (2.4+) Linux kernels, file descriptors are dynamically created as necessary, but cannot be removed or reduced other than by rebooting the server.
A very large number of file descriptiors (the maximum possible number of which is 2,147,483,647; although this is realistically limited to less than 536,870,912) could actually result in server instability due to lack of memory.
In addition to configuring system-wide global file-descriptor values, you must also consider per-process limits.
The following example describes how to raise the maximum number of file descriptors per process to 4096 on the RedHat distibution of Linux:
Allow all users to modify their file descriptor limits from an initial value of 1024 up to the maximum permitted value of 4096 by changing /etc/security/limits.conf
* soft nofile 1024
* hard nofile 4096
In /etc/pam.d/login, add:
session required /lib/security/pam_limits.so
Increase the system-wide file descriptor limit by adding the following line to the /etc/rc.d/rc.local startup script:
echo -n "8192" > /proc/sys/fs/file-max
or, on 2.6 kernels:
echo -n "8192" > $( mount | grep sysfs | cut -d" " -f 3 )/fs/file-max
Now restart the system or run these commands from a command line to apply these changes.
You will then need to tell the system to use the new limits:
ulimit -n unlimited
(bash)
or
ulimit -n 65535
(bash)
or
unlimit descriptors
(csh, tcsh).
ulimit -a
(bash) or limit (csh, tcsh)
$ZEUSHOME/restart-zeus
or by running:
$ZEUSHOME/stop-zeus
followed by:
$ZEUSHOME/start-zeus