Tuning for Linux Open handle restrictions
Reference article:
Linux---Process handle limit summary (http://blog.csdn.net/jhcsdb/article/details/32338953)
!! The content of this article is only tested on RHEL6.4.
The Linux handle limit is divided into 1 system-level restrictions and 2 user-level restrictions :
/proc/sys/fs/nr_open >/proc/sys/fs/file-max >= ulimit-hn >= ulimit-sn
1 system-level throttling 1.1/proc/sys/fs/nr_open
The system file system supports a maximum number of file handles, and the default value is 1048576 (1M). The upper limit of this value is limited by system memory. This is the maximum value for all limits.
1.2/proc/sys/fs/file-max
The system file system supports the maximum number of file handles, which must be less than nr_open. View commands (The following 3 commands are equivalent):
[Email protected] ~]# Sysctl-a | Grep-i File-max--colorfs.file-max = 188436[[email protected] ~]# Cat/proc/sys/fs/file-max188436[[email protected] ~]# s YSCTL-E Fs.file-maxfs.file-max = 188436
To view the number of open file descriptors commands used by the current system:
[Email protected] ~]# cat/proc/sys/fs/file-nr832 0 188436
where File-max = 188436
1.3 Change File-max
temporary change, restart after the disappearance :
[Email protected] ~]# sysctl-w fs.file-max=102400
permanent ChangesIn
/etc/sysctl.conf(for version 2.2 and 2.4 cores):
fs.file-max=102400#### for version 2.2 kernels only: # # # fs.inode-max=102400
When
/etc/sysctl.confAfter the change, run the following command to make the change effective immediately:
[Email protected] ~]# sysctl-p
2 user-level limit 2.1 hard upper Ulimit-hn
The hard upper limit of the number of individual process handles. <= File-max. To view a command:
[Email protected] ~]# ulimit-hn4096
Temporary changes,
disappears after reboot:
[Email protected] ~]# ulimit-hn 8192[[email protected] ~]# ulimit-hn8192
2.2 Soft Upper ULIMIT-SN
The soft upper limit of the number of single process handles, <= ulimit-hn. View commands:
[Email protected] ~]# ulimit-sn1024[[email protected] ~]# ulimit-n1024
Temporary changes,
disappears after reboot:
[Email protected] ~]# ulimit-sn 8000[[email protected] ~]# ulimit-n8000
2.3 Modifying the maximum number of individual process handles
While temporarily modifying the soft and hard upper limit (<=file-max) after reboot disappears :
[Email protected] ~]# Ulimit-shn 10240
permanently modify the soft and hard upper limit (RHEL6.4), set in /etc/security/limits.conf (* indicates to all users):
#......# @student - maxlogins nofile 10240* soft nofile 10240# End of File
Tuning for Linux open handle restrictions