Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to modify the file handle limit in linux

Shulou Source: shulou.com Published: 2022-06-01 17:00:47 09月20日 Update

Linux how to modify the file handle limit, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Modify file handle

Parameters.

/ proc/sys/fs/file-max determines the maximum number of file handles that the current kernel can open.

Ulimit-n the number of file handles that can be opened at the user process level.

Modify kernel parameters

If it takes effect after reboot, you need to write it to the configuration file.

Vim / etc/sysctl.d/openfile.conf

Create a file first, and then add fs.file-max. The size can be set according to the actual situation, or it can be limited by calculating the amount of memory used.

For example, to limit the use of up to 10% of memory

Grep-r MemTotal / proc/meminfo | awk'{printf ("% d\ n", $2max 10)}'

Fs.file-max = 6553600

If it is systemd management, you need to restart the systemd-sysctl service to take effect.

Systemctl restart systemd-sysctl

If there is a / etc/sysctl.conf file, you can directly use sysctl to take effect.

Sysctl-p

Modify ulimit parameters

Temporary modifications can be set directly using ulimit-n 65536. If you need to start automatic loading, write directly to the startup command, there may be an error, and you need to rely on the pam module.

If you need a restart to take effect automatically, you need to modify / etc/security/limits.conf

Vim / etc/security/limits.conf

Add

* soft nproc 6553600 * hard nproc 6553600 * soft nofile 6553600 * hard nofile 6553600

If it doesn't work, you need to replace * with a user name that needs to be modified, usually on the Ubuntu.

After reading the above, have you mastered the method of how to modify the file handle limit in linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: File handle limit parameter memory content kernel size method more user problem maximum helpless for this reason you can pass the command actually for this Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux MySQL Shulou Information Xiaomi