Linux sets the permanent and effective way of "the maximum number of files that can be opened by the process"

0. Before setting [root@localhost ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited sched...
0. Before setting
[root@localhost ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 3829 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 3829 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited
1. Modify the limits.conf main configuration file
[root@localhost ~]# vim /etc/security/limits.conf
2. Add the following two sentences at the end of the main configuration file
* soft nofile 65535 * hard nofile 65535

Note that "*" is added to the file. The meaning of these two sentences is the limit of the maximum number of openable files in the soft ware level limit, hard indicates the limit of the maximum number of openable files in the operating system level limit, and "*" indicates that all users are effective. Save the file (only the root user has permission).

After saving this file, the configuration will not take effect immediately. To ensure that the configuration in this shell session will take effect immediately, we need to change the shell session settings through ulimit command (of course, if you want to restart the system, I can't say anything).

[root@localhost ~]# ulimit -n 65535
3. The configuration takes effect as soon as the command is executed. You can use ulimit -a to view all the core configurations in the current session
[root@localhost ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 3829 max locked memory (kbytes, -l) 64 max memory size (kbytes, -m) unlimited open files (-n) 65535 pipe size (512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 3829 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited

Note the open files entry.

4 May 2020, 08:45 | Views: 2951

Add new comment

For adding a comment, please log in
or create account

0 comments