Set Linux Open file handles the difference between/proc/sys/fs/file-max and ulimit-n

Source: Internet
Author: User

Max-file represents the number of file handles that can be opened at the system level. is a limitation on the entire system and is not intended for the user.

Ulimit-n controls the number of file handles that the process level can open. Provides control over the file handles available to the shell and its initiated processes. This is process-level.

For the server, both the File-max and the ulimit need to be set up, otherwise the file descriptor exhaustion problem will occur.

In general if you encounter a file handle reached the upper limit, you will encounter "Too many open files" or Socket/file:can ' t open so many files and other errors.

In order for the server to restart, the configuration is still valid and needs to be modified with a permanently active configuration method.

Max-file:

View the number of file handles that can be opened at the system level, CENTOS7 default is 794168

# Cat/proc/sys/fs/file-max

794168

System level Open maximum file handle the number of modified methods that are permanently in effect, modify the file, add the configuration content to the end of the file:

# vim/etc/sysctl.conf

Fs.file-max = 2000000

Then execute the command to make the modification configuration effective immediately:

# sysctl-p

Ulimit

To view the number of user process-level Open file handles, CENTOS7 default is 1024

This sets the maximum open limit for the current user of the current shell, and if the current user opens multiple shells, each shell can open the maximum value

# Ulimit-n

1024

Process-level Open file handle number of permanent modification methods, modify the file, the end of the file to add configuration content:

This limits the maximum number of all shells that a user can open:

# vim/etc/security/limits.conf

* Soft Nofile 65535

* Hard Nofile 65535

After you modify it, you need to log back in to take effect.

If you need to set the current user session to take effect immediately, you also need to perform:

# Ulimit-n 65535

For servers, it is generally possible to modify the maximum number of open file handles at the process level (system default 1024, a bit small). You generally do not need to adjust the maximum number of system levels.

If there is a maximum system-level limit, the maximum number of system-level adjustments also needs to be synchronized.

Set Linux Open file handles the difference between/proc/sys/fs/file-max and ulimit-n

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.