Chinaunix首页 | 论坛 | 博客
  • 博客访问: 503394
  • 博文数量: 81
  • 博客积分: 7010
  • 博客等级: 少将
  • 技术积分: 1500
  • 用 户 组: 普通用户
  • 注册时间: 2005-12-15 10:51
文章分类

全部博文(81)

文章存档

2011年(1)

2009年(22)

2008年(58)

我的朋友

分类: 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.

Global File Descriptor Tuning

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.

Process File Descriptor Tuning

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:

  1. 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
  2. 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.

  3. 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).
  4. Verify this has raised the limit by checking the output of:
    ulimit -a (bash) or limit (csh, tcsh)
  5. Restart the web server using:
    $ZEUSHOME/restart-zeus

    or by running:

    $ZEUSHOME/stop-zeus

    followed by:

    $ZEUSHOME/start-zeus

Related:



阅读(2381) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~