linux下file descriptoer限制

 

linux下file descriptoer限制

默认分类    2009-11-21 14:47   阅读0   评论0  
字号:    

Tuning file descriptor limits on Linux

Linux limits the number of file descriptors that any one process may open; the default limits are 1024 per process. These limits can prevent optimum performance of both benchmarking clients (such as httperf and apachebench) and of the web servers themselves (Apache is not affected, since it uses a process per connection, but single process web servers such as Zeus use a file descriptor per connection, and so can easily fall foul of the default limit).

The open file limit is one of the limits that can be tuned with the ulimit command. The command

ulimit -aS

displays the current limit, and

ulimit -aH

displays the hard limit (above which the limit cannot be increased without tuning kernel parameters in /proc).

The following is an example of the output of

ulimit -aH

. You can see that the current shell (and its children) is restricted to 1024 open file descriptors.

core file size (blocks) unlimiteddata seg size (kbytes) unlimitedfile size (blocks) unlimitedmax locked memory (kbytes) unlimitedmax memory size (kbytes) unlimitedopen files 1024pipe size (512 bytes) 8stack size (kbytes) unlimitedcpu time (seconds) unlimitedmax user processes 4094virtual memory (kbytes) unlimited

Increasing the file descriptor limit

The file descriptor limit can be increased using the following procedure:

 

  1. Edit

     

    /etc/security/limits.conf

    and add the lines:

    * soft nofile 1024

  2. * hard nofile 65535

     

  3. Edit

     

    /etc/pam.d/login

    , adding the line:

    session required /lib/security/pam_limits.so

     

  4. The system file descriptor limit is set in

     

    /proc/sys/fs/file-max

    . The following command will increase the limit to 65535:

    echo 65535 > /proc/sys/fs/file-max

     

  5. You should then be able to increase the file descriptor limits using:

     

    ulimit -n unlimitedThe above command will set the limits to the hard limit specified in

    /etc/security/limits.conf

    .

 

Note that you may need to log out and back in again before the changes take effect.

第四步没有能够执行,别的没有问题,注意设置完成后重启机器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值