Linux too many open files problem-modify Linux max file handle number

Source: Internet
Author: User

When Linux servers are tuned for large concurrency, it is often necessary to pre-tune the Linux parameters, where modifying the maximum number of Linux file handles is one of the most frequently modified parameters.


You can query Linux-related parameters by executing ulimit-a in Linux, as follows:

[Email protected] ~]# ulimit-a

Open files (-N) 1024


By default, the maximum number of file handles for Linux is 1024. When your server reaches its limit in large concurrency, it will report "Too many open files".

So how do I change the number of Linux max file handles? It's actually very simple:


1. Temporary effective method

This command modifies the maximum number of Linux file handles and modifies the state of the changes using ulimit-a later, such as:

[Email protected] ~]# ulimit-n 65536

[Email protected] ~]# ulimit-a

Open files (-N) 65536

[Email protected] ~]# ulimit-n

65536

However, this method is only valid for the current process. Reopen a shell or open a process, and you'll see that the parameter is still a number before the Ulimit-n xx changes.


2, modify the Linux system parameters. vi/etc/security/limits.conf add

* Soft Nofile 65536

* Hard Nofile 65536

Note: "*" means that it is valid for all users, and if only one user needs to be active, only the "*" should be changed to a user name.

Modify save later, log off the current user, login again, execute ulimit-a, OK, the parameters are in effect:

[Email protected] ~]# ulimit-a

Open files (-N) 65536

Note:

The hard limit indicates the maximum value that can be set in the soft limit. The soft limit refers to the setting value that the current system is in effect. Hard limit values can be reduced by ordinary users. But cannot be increased. The soft limit cannot be set higher than the hard limit. Only the root user can increase the hard limit value.

Maximum can be set to:

655350


This article from "Travel Life" blog, declined reprint!

Linux Too many open files problem-Modify the maximum number of Linux file handles

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.