In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The maximum number of file limits for Linux ulimit
One: description
Linux for each user, the system limits the maximum number of processes. In order to improve performance, you can set the maximum number of processes for each linux user according to the device resources. You can use ulimit-a to display the current user process limits.
Ulimit: displays (or sets) the limit (limit) of resources available to the user, which is divided into soft limit (current limit) and hard limit (upper limit), where the hard limit is the upper limit of the soft limit, the system resources used by the application do not exceed the corresponding soft limit, and any excess will lead to the termination of the process.
[root@hadoop001] # 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) 15088
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) 15088
Virtual memory (kbytes,-v) unlimited
File locks (- x) unlimited
Second: description of ulimit parameters
Limited does not limit the resources that users can use, but this setting applies to the maximum number of files that can be opened (max open files)
And the maximum number of processes that can run simultaneously (max user processes) is invalid
-a list all current resource limits
-c sets the maximum value of the core file. Unit: blocks
-d sets the maximum value of a process's data segment. Unit: kbytes
-f Shell the maximum file size of the created file (in blocks)
-h specifies that the hard limit of a given resource is set. If the user has root user rights, you can increase the hard limit. Any user can reduce the hard limit
-l the maximum physical memory that can be locked
The maximum resident memory that can be used by-m, in kbytes
-n the maximum number of files that each process can open at the same time
-p sets the maximum value of the pipe in block,1block=512bytes
-s specifies the maximum value of the stack in kbytes
-S specifies that a soft limit is set for a given resource. The soft limit can be increased to the hard limit. If the-H and-S flags are not specified, the limit applies to both.
-t specifies the number of seconds used by each process, in seconds
-u maximum number of concurrent processes that can be run
-v maximum virtual memory that can be used by Shell, in kbytes
Each line of output consists of the name of the resource, (units, arguments to the ulimit command), and soft limits. Detailed explanation:
Parameter description
The maximum value for core file size core files is 100 blocks
The data segment of the data seg size process can be arbitrarily large
File size files can be arbitrarily large
Pending signals has up to 2047 signals to be processed
Max locked memory the maximum physical memory locked by a task is 32kB
Max memory size the maximum resident physical memory of a task
Open files can open up to 1024 files at the same time for a task.
The maximum space for pipe size pipes is 4096 bytes.
The maximum message queue for POSIX message queues POSIX is 819200 bytes
The maximum stack of a stack size process is 8192 bytes
CPU time used by the cpu time process
The maximum number of processes (including threads) opened by the current user of max user processes is 2047.
Virtual memory does not limit the maximum address space of a process.
There is no limit to the maximum number of files that can be locked by file locks
Three: operation
Below, I set the maximum number of processes for a linux user to 10000:
Ulimit-u 10240
For Java applications that need to make a lot of socket connections and keep them open
It is best to modify the number of files that can be opened per process by using ulimit-n xx, which defaults to 1024.
Ulimit-n 4096 increases the number of files that can be opened by each process to 4096, which defaults to 1024
Other important settings that are recommended to be set to unlimited (unlimited) are:
Segment length: ulimit-d unlimited
Maximum memory size: ulimit-m unlimited
Stack size: ulimit-s unlimited
CPU time: ulimit-t unlimited
Virtual memory: ulimit-v unlimited
Temporarily, for the duration of a shell session logged in through the ulimit command.
Permanently, by adding a corresponding ulimit statement to the file read by the login shell
That is, user resource files specific to shell, such as:
1) remove the limit on the maximum number of processes and the maximum number of files opened on the Linux system:
Vi / etc/security/limits.conf
Add the following line soft noproc 11000hard noproc 11000soft nofile 4100hard nofile 4100
Note: * for all users, noproc represents the maximum number of processes, and nofile represents the maximum number of file openings
2) Let SSH accept the login of Login program, and it is convenient to view the ulimit-a resource limit in the ssh client:
A 、 vi / etc/ssh/sshd_config
Change the value of UserLogin to yes and remove the # comment
B. Restart the sshd service:
/ etc/init.d/sshd restart
3) modify the environment variable files of 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
After saving, run # source / etc/profile to make it effective
Four: pay attention
Add the ulimit value to the / etc/profile file (for systems logged in with root privileges)
When configuring
To get a larger ulimit value each time the system restarts, add ulimit to the bottom of the / etc/profile file.
Echo ulimit-n 65535 > > / etc/profile
Source / etc/profile # load modified profile
In production, when you log in again when you are not a root user, your ulimint value does not change.
Solution:
Modify the software and hardware limitation file of linux / etc/security/limits.conf.
[root@hadoop001 security] # pwd
/ etc/security
[root@hadoop001 security] # ll
Total 68
....
-rw-r--r--. 1 root root 2508 Oct 15 2017 limits.conf
....
Add the following code at the end of the file:
Soft noproc 11000
Hard noproc 11000
Soft nofile 4100
Hard nofile 4100
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.