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 does Linux modify the maximum number of open files

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to modify the maximum number of open files in Linux". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Linux how to modify the maximum number of open files" bar!

To prevent runaway processes from disrupting system performance, UNIX and Linux track most of the resources used by the process and allow users and system administrators to use resource restrictions on the process.

1. The viewing method uses ulimit-an or ulimit-n

Open files (- n) 1024 is the linux operating system limit on the number of file handles opened by a process (including the number of sockets opened)

Here is only a restriction on the user level. In fact, there is also a general restriction on the system. Check the system bus system:

# cat / proc/sys/fs/file-max

Man proc, you can get a description of file-max:

/ proc/sys/fs/file-max This file defines a system-wide limit on the number of open files for all processes. See also setrlimit (2), which can be used by a process to set the per-process limit, RLIMIT_NOFILE, on the number of files it may open. If you get lots of error messages about running out of file handles, try increasing this value:

That is, file-max sets the total number of files that can be opened by all processes in the system. At the same time, some programs can set the limit of each process through setrlimit call. If you get a lot of error messages about running out of file handles, you should increase this value.

That is, this parameter is system-level.

two。 The modification method takes effect temporarily: # ulimit-SHn 10000 in fact, the ulimit command is divided into soft limit and hard limit, adding-H is the hard limit, and adding-S is the soft limit. Soft limits are displayed by default, and if you run the ulimit command to modify without adding-H or-S, the two parameters are changed together.

What is the difference between soft limits and hard limits?

A hard limit is an actual limit, while a soft limit is a warning limit, which only gives a warning.

Permanent effective for the value of ulimits to be permanent, you must modify the configuration file / etc/security/limits.conf to add to the configuration file

* soft nofile 65535

* hard nofile 65535

Echo "* soft nofile 65535" > > / etc/security/limits.conf

Echo "* hard nofile 65535" > > / etc/security/limits.conf

* indicates the user used

To modify the total limit of the system, in fact, the modification is a limit on the number of file handles opened by a process, and we need to set the total limit of the system.

Suppose we set the number of file handles opened by the process to be 1024, but the system bus system is only 500, so all processes can open up to 500 file handles. From this we can see that it is not possible to just set the number of open file handles for the process. So you need to modify the total limits of the system.

Echo 6553560 > / proc/sys/fs/file-max

The above is a temporary method, which will fail after restarting the machine.

Permanent effective method:

Modify / etc/sysctl.conf, add

Fs.file-max = 6553560 restart takes effect

At this point, I believe that everyone on the "Linux how to modify the maximum number of open files" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report