Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to modify the file handle limit in linux

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report