Linux Performance Tuning Basic Policy Settings

  

About ulimit

ulimit -a Used to display current user process restrictions. For each user, Linux 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. Below I set the maximum number of processes for a linux user to 10000: ulimit -u 10000 for many socket connections and open them. For Java applications, it is best to modify the number of files that can be opened per process by using ulimit -n xx. The default value is 1024. Ulimit -n 4096 Increases the number of files that can be opened per process to 4096. The default is 1024. Other important settings that are set to unlimited (unlimited) are: data 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 Temporarily, for logging in to a shell session with the ulimit command. Permanently, by adding a corresponding ulimit statement to the file read by the login shell, that is, a shell-specific user resource file, such as:

1), releasing the maximum number of processes and maximization of the Linux system File open limit: vi /etc/security/limits.conf# Add the following line * soft noproc 11000* hard noproc 11000* soft nofile 4100* hard nofile 4100

Description: * stands for noproc for all users Represents the maximum number of processes, nofile, which represents the maximum number of open files

2). Let SSH accept the login of the Login program. It is convenient to view the ulimit -a resource limit on the ssh client: a, vi /etc/ssh/sshd_config Change the value of UserLogin to yes, remove the # comment, restart the sshd service: /etc/init.d/sshd restart3), modify the environment variable files of all linux users: vi /etc/profileulimit -u 10000ulimit -n 4096ulimit - d unlimitedulimit -m unlimitedulimit -s unlimitedulimit -t unlimitedulimit -v unlimited

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

Sometimes you need to open multiple files in the program. Analysis, the system is usually the default number 1024, (see with ulimit -a) is enough for normal use, but for the program is concerned, it is too little.

Modify 2 files. 1./etc/security/limits.confvi /etc/security/limits.conf plus: * soft nofile 8192* hard nofile 204802./etc/pam.d/loginsession required /lib/security/pam_limits.so*** ******* Also make sure that the /etc/pam.d/system-auth file has the following content required /lib/security/$ISA/pam_limits.so line to ensure that the system will enforce this restriction. ***********3. The general user's .bash_profile#ulimit -n 1024 re-login ok------------- for solaris

actually in the system There is such a command ulimit, the following is the result of ulimit -a execution:

time(seconds) unlimitedfile(blocks) unlimiteddata(kbytes) unlimitedstack(kbytes) 8192coredump(blocks) unlimitednofiles(descriptors) 1024memory(kbytes) Unlimited where nofiles is the variable value of the file descriptor. This value is affected by the rlim_fd_cur parameter and can be modified with the ulimit -n number command. But no matter how you change it, the program still can't break the limit of fd=256. The following information can be found in the Solaris Tunable Parameters Reference Manua book:

A 32-bit program using standard I/O is limited to 256 file descriptors. A 64-bit program using standard I/O can use up to 2 billion descriptors. This means that 32-bit programs can't break through this limitation. Only 64-bit programs can use up to 200 million file descriptors. SUN's hardware and software have realized 64-bit architecture long ago. The solution is to compile the program into a 64-bit program. In order to generate a 64-bit program, you must have a 64-bit compiler (in fact, this is not the case). If you go to www.sunfreeware.com to download the 64-bit compiler gcc, on the website. Not specifically noted is the 64-bit gcc, but there will be an unexpected gain, that is, the description of the software indicates that you can generate a 64-bit program by adding the -m64 option when compiling with gcc.

So after using gcc-m64 to compile and generate a 64-bit program, use ulimit -n 102400 to set the number of fd to a large size, all the problems are solved, and there is no longer enough file descriptors. Case.

Set the rlimi_fc_max and rlim_fd_cur formats in the /etc/system file as follows:

* set hard limit on file descriptorsset rlim_fd_max = 4096* set soft limit on file descriptorsset rlim_fd_cur = 1024 command ulimit uses the following format :

usage: ulimit [ -HSacdfnstv ] [ limit ]ulimit -a is to display the setting value of each parameter, ulimit -n is used to set the maximum value of fd. *************************************************< Br>

Modify File Descriptor Limits

Solaris has two parameter control file descriptors that can be opened by the process: rlim_fd_max, rlim_fd_cur. The former modification is a hard setting, the modification requires permission, and the latter is a soft setting. The user can modify it by limit or setrlimit(), and the maximum value cannot exceed the former. Generally we modify these two parameters in /etc/system

set rlim_fd_max = 65535

set rlim_fd_cur = 65535

=========== ===============

ulimit The resource used by the shell to start the process.

You can use this command to check the status of resources occupied by the process.

Usage: ulimit [-acdfHlmnpsStvw] [size]

-H Set hardware resource limit.-S Set software resource limit.-a Display all current resource limits.-c size: Set the maximum value of the core file. Unit: blocks-d size: set the maximum value of the data segment. Unit: kbytes-f size: set the maximum value of the created file. Unit: blocks-l size: set the maximum locking process in memory Value. Unit: kbytes-m size: Set the maximum value of resident memory that can be used. Unit: kbytes-n size: Set the maximum value of the file descriptor that the kernel can open at the same time. Unit: np size: Set the pipe buffer Maximum. Unit: kbytes-s size: Set the maximum value of the stack. Unit: kbytes

Copyright © Windows knowledge All Rights Reserved