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

About the ulimit command to modify the size of hardware and software resources and correctly modify the limit configuration of software and hardware resources

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Recently, my colleague made some CentOS optimizations to deploy online services and asked me why I changed the limit on the number of soft and hard resource processes and why it didn't take effect after reboot. I said that if the configuration is written into the configuration file, it can take effect. Therefore, I checked the optimized configuration of his system and found that he used the command of ulimit to modify the process limit configuration.

Ulimit-HSn 65536

Then write it in the rc.local configuration file. Why is it written like that? I was surprised when my colleague said that it was done on the Internet.

So, I started Baidu, found that a lot of optimized configuration information on the Internet is done in this way, I started, helpless, I do not know which god spread out ah, and was reproduced by a lot of people, please everyone, walk again and turn again? Otherwise, the hole will be dug bigger and bigger.

Here is the ulimit command. Ulimit can be used to display commands that modify the current limit on the number of user processes in the system. For more information, please refer to the Linux manual. The usage of this command parameter is not listed here. This command only takes effect on the current user environment, to put it bluntly, the changes made during your connection to the current shell through the terminal tool are valid, once your port is disconnected and the user exits, it will change back to the system default 1024, whether you are written in the startup configuration file or not, it will not take effect. So don't write it in the startup configuration file again, it won't work.

The effective way to restart is to directly modify the / etc/security/limits.conf configuration file, as mentioned on the Internet, which can be used to modify restrictions on system users, groups, the number of files, etc., through which restrictions can be made for a certain user or all. However, it cannot exceed the limits of the system; for specific modification methods, refer to the comments of the configuration file. Paste the online configuration here.

In addition, people often ask me why I wrote 10240 or what 65536 about this number, and everyone was misled by this number. In fact, there is nothing, just a limited number, you can also write an integer or something. But to remind you, this number is not the bigger the better, it depends on the actual performance of the machine. If this number is very large, when the performance bottleneck of the machine is reached, the system will accept more files, which will cause the machine to run stutter and crash. Without preventing redundant processes from executing. Therefore, it is necessary to modify this limit value.

Finally, I would like to remind you that this configuration file actually loads the pam_limits.so module, so for this configuration file to take effect, make sure the module loads properly. With regard to the loading of this module, there are a lot of online materials, so I will not repeat them.

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

Network Security

Wechat

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

12
Report