linux's maximum number of open files limit modification method

  • 2020-06-19 12:29:10
  • OfStack

preface

This paper mainly introduces the modification of the maximum number of open files in linux and shares it for your reference and study. The following is not enough. Let's start with a detailed introduction:

linux has a limit on the maximum number of files that can be opened for each user to log into the system, and this limit is passed ulimit -n As you can see, 1 is 1024.

In some cases of concurrency or multithreading, this limit needs to be breached.

Modify the

Step 1 to edit/etc security/limits conf line and ensure it contains the following:


* soft nofile 65535
* hard nofile 65535

Here * refers to all users, but some systems do not recognize, need specific user name, such as:


root soft nofile 65535
root hard nofile 65535

Step 2 edit etc/pam d/login, ensure that like a downside:


session required pam_limits.so

Step 3 Exit the terminal and login again.

validation

use ulimit -Hn and ulimit -Sn The command looks at the hard and soft limits for the current process user, respectively.

Or after the current user starts a program, it passes cat /proc/<PID>/limits (pid is for this process, or pid for any one of its children)

conclusion


Related articles: