Linux Max Open File descriptor number

Source: Internet
Author: User

1. System maximum Open file descriptor:/proc/sys/fs/file-max
A. View
$ cat/proc/sys/fs/file-max
186405
2. Settings
A. Temporary
# echo 1000000 >/proc/sys/fs/file-max
2. Permanent: Set in/etc/sysctl.conf, in the new
Fs.file-max = 1000000

2. Process Max Open File descriptor: Soft limit for nofile in user limit
A. View
$ ulimit-n
1700000
2. Settings
A. Temporary: Set the maximum open file descriptor soft limit by ULIMIT-SN, note that soft limit cannot be greater than hard limit (Ulimit-hn can see hard limit), and ulimit-n by default view soft Li MIT, but Ulimit-n 1800000 is set soft limit and hard limit at the same time. For non-root users, you can only set hard limit that is smaller than the original.
View Hard limit:
$ ulimit-hn
1700000
Set soft limit, must be less than hard limit:
$ ULIMIT-SN 1600000
2. Permanent: The above method is only temporary, log off and re-login is invalid, and can not increase hard limit, only within the range of hard limit to modify soft limit. To make the modification permanent, you need to set it in/etc/security/limits.conf (Root permission required), and you can add the following two lines, indicating that the user Chanon the maximum number of open file descriptors soft limit is 1800000,hard Limit is 2000000. The following settings require logging off and then logging back in to take effect:
Chanon Soft Nofile 1800000
Chanon Hard Nofile 2000000
Set Nofile hard Limit There is also a point to note is that you can not be more than/proc/sys/fs/nr_open, and if it is more than Nr_open, log out after logging off. You can modify the value of the Nr_open:
# echo 2000000 >/proc/sys/fs/nr_open

3. View the number of open file descriptors used by the current system
[Email protected] bin]# CAT/PROC/SYS/FS/FILE-NR
5664 0 186405
The first number indicates the number of open file descriptors that the current system has been assigned to use, the second number is freed after allocation (no longer used), and the third number equals File-max.

4. Summary:
A. The number of file descriptors opened by all processes must not exceed/proc/sys/fs/file-max
B. The number of file descriptors opened by a single process cannot exceed Nofile soft limit in user limit
C. nofile's soft limit cannot exceed its hard limit
D. Nofile's hard limit cannot exceed/proc/sys/fs/nr_open

Linux Max Open File descriptor number

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.