In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to use the ulimit command in linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Temporary system tuning-- ulimit command ulimit command usage instructions
Command: ulimit
Function: control the resources of shell programs
Syntax: ulimit [- aHS] [- c] [- d] [- f] [- m] [- n] [- p] [- s] [- t] [- u] [- v]
Description: ulimit is a built-in instruction for shell, which can be used to control the resources of shell program execution.
Parameters:
-a displays the current resource limit settings.
-c sets the maximum value of the core file in blocks.
-d the maximum value of the program data section in KB.
-f shell can create the largest file, in chunks.
-H sets hard limits on resources, that is, those set by administrators.
-m specifies the upper limit of available memory in KB.
-n specifies the maximum number of files that can be opened at a time.
-p specifies the size of the pipe buffer in 512 bytes.
-s specifies the upper limit of the stack in KB.
-S sets flexible limits for resources.
-t specifies the upper limit of CPU usage time (in seconds).
-u the maximum number of processes that a user can start.
-v specifies the upper limit of virtual memory available, in KB.
Default resource configuration # ulimit-a...core file size (blocks,-c) 0data seg size (kbytes,-d) unlimitedscheduling priority (- e) 0file size (blocks,-f) unlimitedpending signals (- I) 30518max locked memory (kbytes,-l) 64max memory size (kbytes -m) unlimitedopen files (- n) 1024pipe size (512 bytes,-p) 8POSIX message queues (bytes,-Q) 819200real-time priority (- r) 0stack size (kbytes,-s) 10240cpu time (seconds,-t) unlimitedmax user processes (- u) 1024virtual memory (kbytes -v) unlimitedfile locks (- x) unlimited modifies the maximum number of processes
Linux for each user, the system limits the maximum number of processes. To improve performance, you can set the maximum number of processes for each linux user, such as 10000, depending on the device resources
# ulimit-u 10000 modify the maximum number of file openings
For Java applications that need to make many socket connections and keep them open, you need to set the number of files that can be opened per process, the default is 1024.
# ulimit-n 65535 other Settings
Some important settings recommended to be set to unlimited (unlimited) are:
Segment length # ulimit-d unlimited maximum memory size # ulimit-m unlimited stack size # ulimit-s unlimitedCPU time # ulimit-t unlimited virtual memory # ulimit-v unlimited
Note: ulimited 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 at the same time (max user processes) is invalid.
Permanent system tuning-/ etc/security/limits.conf or create a new file write limit under the / etc/security/limits.d/ folder
/ etc/security/limits.conf is a Linux resource usage profile that is used to limit users' use of system resources. The limits.conf file is actually the configuration file for pam_limits.so in Linux PAM (plug-in Authentication Module, Pluggable Authentication Modules) and is only for a single session. The contents of the files defined under the / etc/security/limits.d/ folder are the same as the limits.conf format, but with higher priority. It is recommended to define what you need under this folder.
Limits.conf format username | @ groupname type resource limit
Username | @ groupname: set the user name that needs to be restricted. The group name is preceded by the difference between @ and user name. You can also use the wildcard'*'to restrict all users.
Type: there are soft,hard and -, and soft refers to the setting for which the current system is in effect. Hard indicates the maximum value that can be set in the system. The limit of soft cannot be higher than the limit of har. Using-indicates that both soft and hard values are set.
Resource:
Core-limits the size of kernel files
Date-the largest size of big data
Fsize-maximum file size
Memlock-maximum locked memory address space
Nofile-maximum number of files opened
Rss-maximum persistent setting size
Stack-maximum stack size
Cpu-maximum CPU time in minutes
Noproc-maximum number of processes
As-address space restriction
Maxlogins-maximum number of logins allowed by this user
Limit: specific value
Other configurations enable / etc/security/limits.conf function
For the limits.conf file configuration to take effect, you must ensure that the pam_limits.so file is added to the startup file. View the / etc/pam.d/su file as follows:
... session required pam_limits.so... Modify the Linux environment variable # vim / etc/profile...# to add the following ulimit-SHn 204800
Note: the 204800 set here must be greater than the maximum number of / etc/security/limits.conf openings
Give an example
For example: modify file descriptor size (65536)
Step1
# vim / etc/security/limits.d/30-nofile.conf...* soft nofile 65536 * hard nofile 65536
Step2
# vim / etc/pam.d/su...session required pam_limits.so
Step3
# vim / etc/profile...ulimit-SHn 204800 attention!
If the above settings for service startup do not work, you need to set them in the server file, which is generally located in the following location:
/ usr/lib/systemd/system system service
/ etc/systemd/system user-defined service
Add the following to the service file
... [Service]... LimitCORE=infinityLimitNOFILE=65536LimitNPROC=65536
The above three items need to be added to the service, and 65536 is the number of customizations.
You can view the resource limits for the currently running service with the following command
# cat / proc//limit Thank you for reading! This is the end of the article on "how to use ulimit commands in linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.