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