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

B. Permanent: Set in/etc/sysctl.conf

Fs.file-max = 1000000

2. Process Max Open File descriptor: Soft limit for nofile in user limit

A. View

$ ulimit-n

170000

B. Settings

1). Temporary:

Soft limit, which sets the maximum number of open file descriptors by ULIMIT-SN, note that soft limit cannot be greater than hard limit (Ulimit-hn can see hard limit), and ulimit-n default view is soft limit, Ulimit-n 180000, however, sets 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.

(1) View hard limit:

$ ulimit-hn

170000

(2) Set soft limit, must be less than hard limit:

$ ULIMIT-SN 160000

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 two lines that indicate that the soft limit for the maximum number of open file descriptors for all users is 102400,hard Limit is 104800. The following settings require logging off and then logging back in to take effect:

In/etc/security/limits.conf, add the following:

* Soft Nofile 102400

* Hard Nofile 104800

      Note: set nofile hard limit There is one more thing to note is that if you do not have more than/proc/sys/fs/nr_open, you will not be able to log in after logging out if you have more than Nr_open.

You can modify the value of the Nr_open:

# echo 200000 >/proc/sys/fs/nr_open

3. View the number of open file descriptors used by the current system

$ 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.