Linux open handle limit adjustment, linux handle limit Adjustment

Source: Internet
Author: User

Linux open handle limit adjustment, linux handle limit Adjustment
Linux handle restrictions

References:

Linux --- Process Handle limits Summary (http://blog.csdn.net/jhcsdb/article/details/32338953)

!! This article is only tested on RHEL6.4.

Linux handles can be divided into 1 system level limit and 2 user level limit:

/Proc/sys/fs/nr_open>/proc/sys/fs/file-max> = ulimit-Hn> = ulimit-Sn

1 system-level limit: 1.1/proc/sys/fs/nr_open

The maximum number of file handles supported by the System File System. The default value is 1048576 (1 M). The maximum value is limited by the system memory. This is the maximum value for all restrictions.

1.2/proc/sys/fs/file-max

The maximum number of file handles supported by the system file system must be smaller than nr_open. view the command (the following three commands are equivalent ):

[root@vm-cdh4 ~]# sysctl -a | grep -i file-max --colorfs.file-max = 188436[root@vm-cdh4 ~]# cat /proc/sys/fs/file-max188436[root@vm-cdh4 ~]# sysctl -e fs.file-maxfs.file-max = 188436

Run the following command to view the number of opened file descriptors used by the current system:

[root@vm-cdh4 ~]# cat /proc/sys/fs/file-nr832    0    188436
File-max = 188436

1.3 change file-max

Temporary changes, disappears after restart:

[root@vm-cdh4 ~]# sysctl -w fs.file-max=102400
Permanent changes, In /Etc/sysctl. conf(Applicable to kernels 2.2 and 2.4 ):

Fs. file-max = 102400 #### only for the 2.2 kernel: #### fs. inode-max = 102400
When /Etc/sysctl. confAfter the change, run the following command to make the change take effect immediately:
[root@vm-cdh4 ~]# sysctl -p

2. user-level limit: 2.1 hard upper limit: ulimit-Hn

The maximum number of handles of a single process. <= file-max. view the command:

[root@vm-cdh4 ~]# ulimit -Hn4096
Temporary changes, Disappears after restart:

[root@vm-cdh4 ~]# ulimit -Hn 8192[root@vm-cdh4 ~]# ulimit -Hn8192

2.2 Soft Upper Limit ulimit-Sn

The maximum number of handles for a single process. <= ulimit-Hn. view the command:

[root@vm-cdh4 ~]# ulimit -Sn1024[root@vm-cdh4 ~]# ulimit -n1024

Temporary changes, Disappears after restart:

[root@vm-cdh4 ~]# ulimit -Sn 8000[root@vm-cdh4 ~]# ulimit -n8000

2.3 modify the maximum number of handles of a single process

Modify the soft and hardware limits temporarily (<= file-max)Disappears after restart:

[root@vm-cdh4 ~]# ulimit-SHn 10240

Permanently modify the hard and soft limits (RHEL6.4 )./Etc/security/limits. conf(* Indicates all users ):

#......#@student        -       maxlogins       4*    hard    nofile    10240*    soft    nofile    10240# End of file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.