Linux: Use Ulimit to set the maximum number of files open __linux

Source: Internet
Author: User

As you all know, the Linux system defaults to open files of 1024, in the actual production environment, this value is always too small, and the consequence is that your system will report: too many open files and other such errors cause your system to die, so we always have to modify this value, although on the surface it seems , Linux provides ulimit commands like this to allow you to change the number of open files, but unfortunately, the process is far from easy to see, the following child monkeys to talk about this problem.

1, we first through the Ulimit–a command to view some of the system's resource constraints, as follows :

The red box shows the maximum number of open files, usually 1024, but since my system has been changed to 32768, I now see 32768.

We can also use the Ulimit–n command to view the maximum number of file open, as follows:

32768

2, modify the target

Our goal is: to allow each user login system after the system opened the maximum number of files are we set good.

But what I have to say here is: Unfortunately, there are many articles on the internet about Ulimit settings to modify resource restrictions, but none of the articles worked.

Break this goal down to two goals:

2.1, set the root user login system effective

This goal can be achieved without difficulty.

2.2, set to all users effective

This is a lot of trouble, and bad will also put your system to the bad, because you want to recompile Linux kernel will do.

So on balance, I only achieved the first goal, because the second goal is too risky, and I think if I knew it before, I would do it first when I was installing the system, but now I think it's late.

3, the modified place

3.1. Modify/etc/security/limits.conf

Modify its content through vi/etc/security/limits.conf, and add it at the end of the file (values can be defined yourself):

* Soft Nofile = 32768

* Hard Nofile = 65536

3.2. Modify/etc/profile

Through Vi/etc/profile modifications, add the following at the end

Ulimit-n 32768

And then log back in to take effect.

Description :

In fact, only modify the/etc/profile can be effective, but I suggest that the/etc/security/limits.conf also modified.

Finally, if you want to make the changes work for all users, it now appears that you can only recompile the Linux kernel.

if no reprint of the description, are all original site articles, reproduced please specify: Source: Monkey Blog

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.