Ulimit Linux Optimization

Source: Internet
Author: User

Ulimit-A is used to display various current user process restrictions.
Linux limits the maximum number of processes for each user. To improve performance, you can,
Set the maximum number of processes for each Linux User. Below I will set the maximum number of processes for a Linux User to 10000:
Ulimit-u 10000
For Java applications that require many socket connections and make them open,
You are advised to use ulimit-n xx to modify the number of files that can be opened by each process. The default value is 1024.
Ulimit-N 4096 increases the number of files that each process can open to 4096. The default value is 1024.
Other important settings recommended for unlimited are:
Data 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, it is applicable when logging on to a shell session through the ulimit command.
Permanently, add a corresponding ulimit statement to the file read by the logon shell, that is, the shell-specific user resource file, such:

1) Remove the maximum number of processes and maximum number of files opened in Linux:
VI/etc/security/limits. conf
# Add the following rows
* Soft noproc 11000
* Hard noproc 11000
* Soft nofile 4100
* Hard nofile 4100
Note: * represents all users
Noproc indicates the maximum number of processes.
Nofile indicates the maximum number of opened files.
2) enable SSH to accept login program login, so that you can view the ulimit-a resource restrictions on the SSH client:
A, VI/etc/ssh/sshd_config
Change the userlogin value 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

/**************************************

Sometimes you need to open multiple files in the program for analysis. The default number of files in the system is 1024 (as you can see from ulimit-a). This is enough for normal use, but for the program, that's too little.
Modify two files.
1./etc/security/limits. conf
VI/etc/security/limits. conf
Add:
* Soft nofile 8192
* Hard nofile 20480
2./etc/PAM. d/login
Session required/lib/security/pam_limits.so
**********
Make sure that the/etc/PAM. d/system-auth file contains the following content:
Session required/lib/security/$ ISA/pam_limits.so
This line ensures that the system executes this restriction.
***********
3. The. bash_profile of a general user
# Ulimit-n 1024
Log On again. OK.

This article is from the chinaunix blog. If you want to view the original text, click:Http://blog.chinaunix.net/u2/60332/showart_472398.html

 

***************************

 

You can use ulimit-a to view all the limit values of the current system, and use ulimit-N to view the maximum number of opened files.

By default, only 1024 of newly installed Linux instances are installed. When used as a server with a large load, it is easy to encounter error: Too program open files. Therefore, you need to increase it.

You can use ulimit-N 65535 to modify it in real time, but it becomes invalid after restart. (Note that ulimit-shn 65535 is equivalent to ulimit-N 65535.-s indicates soft and-h indicates hard)

There are three ways to modify it:

1. Add a ulimit-shn 65535 row in/etc/rc. Local.
2. Add a ulimit-shn 65535 row in/etc/profile.
3. Add the following two lines of records at the end of/etc/security/limits. conf:
* Soft nofile 65535
* Hard nofile 65535

Which method is used? which method is effective? I use 1st methods in centos for no effect, 3rd methods for effect, and 2nd methods for Debian for Effect

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.