Ulimit: A resource that controls the shell program (Ulimit is a shell-built directive that can be used to control the resources of the Shell Execution program)
Usage:
ulimit [-ahs][-c <core file Cap >][-d < data section size >][-f < file size >][-m < memory size >][-n < number of files >][-p < buffer size >][-s < stack size >][-t <cpu time >][-u < number of programs >][-v < virtual memory size;]
Parameters:
-a displays the current resource limit settings.
-C <core File cap > set the maximum value of the core file, in chunks.
-D < data section size > Maximum value of the Program Data section, in kilobytes.
-F < file size > The largest file the shell can create, in chunks.
-H sets the hard limit for the resource, which is the limit set by the administrator.
-m < memory size > Specifies the maximum amount of memory that can be used, in kilobytes.
-N < number of files > specifies the maximum number of files that can be opened at the same time.
-p < buffer size > Specifies the size of the pipe buffer, in 512 bytes.
-s < stack size > specifies the upper bound of the stack in kilobytes.
-S sets the elastic limit for the resource.
-T <CPU time > Specifies the maximum CPU usage time in seconds.
-U < number of processes > number of processes the user can start.
-v < virtual memory size > Specifies the maximum amount of virtual memory that can be used, in kilobytes.
**************************************
The Ulimit-n command allows you to see the maximum number of open file descriptors in a Linux system, and the newly installed Linux default is only 1024, which is easy to encounter error:too many open files as a server with a large load. Therefore, it is necessary to reset the maximum number of open file descriptors in the Linux system.
The use of ulimit-n 65535 can be modified instantly, but it is not available after a reboot. (note ulimit-shn 65535 equivalent ulimit-n 65535,-s refers to soft,-h)
So where should it be set up.
There are three ways to modify:
1. Add a line ulimit-shn 65535 in/etc/rc.local
2. Add a line ulimit-shn 65535 in/etc/profile
3. At the end of the/etc/security/limits.conf, add the following two lines of records (* no less, on behalf of all users)
* Soft Nofile 65535
* Hard Nofile 65535
Since there are not so many systems available to try, it is not valid to use the first method in the CentOS system, which is valid in the third Way, and the second in Debian. (The method lists, this everyone can try on their own)
By adding a corresponding Ulimit statement to a file that is read by the login shell, the shell-specific user resource file, such as:
1) Unlock the maximum number of processes and maximum file opening limits for Linux systems:
Vi/etc/security/limits.conf
# Add the following line
* Soft Noproc 11000
* Hard Noproc 11000
* Soft Nofile 4100
* Hard Nofile 4100
Description: * Represents for all users
Noproc represents the maximum number of processes
Nofile is the number of open files representing the maximum file
2) Modify the environment variable files for all Linux users:
Vi/etc/profile
Ulimit-u 10000
Ulimit-n 4096
Ulimit-d Unlimited
Ulimit-m Unlimited
Ulimit-s Unlimited
Ulimit-t Unlimited
Ulimit-v Unlimited
**************************************
Most of the time the program needs to open multiple files, the system is generally the default number is 1024,
It's enough for normal use (as you can see with ulimit-a), but too little for large projects.
Modify the following two files:
1)/etc/security/limits.conf
Vi/etc/security/limits.conf
At the end add:
* Soft Nofile 100000
* Hard Nofile 100000
2)/etc/pam.d/login
Session required/lib/security/pam_limits.so
Also make sure that the/etc/pam.d/system-auth file has the following content:
Session required/lib/security/$ISA/pam_limits.so
This line ensures that the system will enforce this restriction.
This article references: Click to open the link
This article references: Click to open the link