Linux system parameter Adjustment __linux

Source: Internet
Author: User
Tags delete key documentation message queue numeric value

Recently led a task, system tuning. I have seen this article in the past, now reprinted it for future reference.

Article formerly known as

Use the/proc file system to control the system see http://wgzhao.com/2005/11/16/control-system-with-proc-fs/#more-18


A detailed description of the usage and the exact information about each file in/proc is beyond the scope covered by this article. To get any additional information about the/proc file not covered by this article, one of the best sources is the Linux kernel source code itself, which contains some very good documentation. For system administrators, the following files in/proc are more useful. This does not mean that it is a detailed description, but a reference that is easily accessible in everyday use. /PROC/SCSI /PROC/SCSI/SCSI

As a system administrator, the most useful thing to know is how to add more disk space without restarting the system if you have a hot swap drive. If you do not use/proc, you can insert the drive, but in order for the system to recognize the new disk, you must reboot the system. Here, you can use the following command to enable the system to recognize the new drive:

echo "SCSI Add-single-device W x y z" >/proc/scsi/scsi

For this command to work correctly, you must specify the correct parameter values W, x, Y, and Z, as follows:
W is the host adapter ID, the first adapter is 0 (0)
X is the SCSI channel on the host adapter, the first channel is 0 (0)
Y is the SCSI identification of the device
Z is the LUN number, the first LUN is 0 (0)

Once you have added a disk to your system, you can mount any previously formatted file system, or you can start formatting it. For example, if you are unsure what device the disk is, or if you want to check any previously existing partitions, you can report this information to you with commands such as fdisk-l.

Conversely, the command to remove a device from the system without rebooting the system is:

echo "SCSI Remove-single-device W x y z" >/proc/scsi/scsi

Before you enter this command and remove the hot swap SCSI disk from the system, be sure to remove any file systems that have been installed from the disk first. /proc/sys/fs/ /proc/sys/fs/file-max

This file specifies the maximum number of file handles that can be allocated. You may need to increase this value if the user gets an error message stating that they cannot open more files because the number of open files has reached the maximum. You can set this value to have any number of files, and you can change the value by writing a new numeric value to the file.

Default setting: 4096 /proc/sys/fs/file-nr

This file is related to File-max, which has three values: number of allocated file handles the maximum number of file handles used for the file handle is read-only and is used only for display information. /proc/sys/fs/inode-*

Any file that starts with the name "Inode" takes the same action as the one above that starts with the name "file", but the operation is related to the index node, regardless of the file handle. /proc/sys/fs/overflowuid and/proc/sys/fs/overflowgid

These two files hold the user identification (UID) and group IDs (GID) of any file systems that support 16-bit user identities and group identities. You can change these values, but if you do feel the need to do so, you may find it easier to make the group and password file entries easier.

Default setting: 65534 /proc/sys/fs/super-max

This file specifies the maximum number of Super block handlers. Any file system you mount requires a super block, so if you mount a large number of file systems, you may run out of super block handlers.

Default setting: 256 /PROC/SYS/FS/SUPER-NR

This file displays the number of super blocks currently allocated. The file is read-only and is used only for display information. /proc/sys/kernel /proc/sys/kernel/acct

The file has three configurable values, based on the number of free space (in percentages) on the file system that contains the log, which controls when the process accounting begins: If free space falls below this percentage value, stop process accounting if the free space is higher than this percentage value, Start process Accounting Check frequency of two values above (in seconds) to change a value for this file, you should echo a string of digits separated by a space.

Default setting: 2 4 30

If there is less than 2% free space on the file system that contains the log, these values cause the accounting to stop and, if there is 4% or more free space, start accounting again. Do one check every 30 seconds. /proc/sys/kernel/ctrl-alt-del

The file has a binary value that controls how the system reacts when it receives the Ctrl+alt+delete key combination. These two values indicate that 0 (0) values represent the capture ctrl+alt+delete and send it to the INIT program. This allows the system to shut down and reboot perfectly as if you were typing the shutdown command. One (1) value indicates that Ctrl+alt+delete is not captured and will perform a dirty shutdown as if the power supply is turned off directly.

Default setting: 0 /proc/sys/kernel/domainname

This file allows you to configure the network domain name. It has no default value, may have already set the domain name, may not have the setting. /proc/sys/kernel/hostname

This file allows you to configure the network host name. It has no default value and may have set the hostname, perhaps without setting it. /proc/sys/kernel/msgmax

This file specifies the maximum length of messages that are sent from one process to another. Message passing between processes occurs in the kernel's memory and is not exchanged to disk, so if you increase this value, the amount of memory used by the operating system increases.

Default setting: 8192 /proc/sys/kernel/msgmnb

This file specifies the maximum number of bytes in a message queue.

Default setting: 16384 /proc/sys/kernel/msgmni

This file specifies the maximum number of message queue identities.

Default setting: /proc/sys/kernel/panic

This file represents the time, in seconds, that the kernel waits before rebooting if "Kernel Critical Error (Kernelpanic)" occurs. A 0 (0) Second setting disables reboot when a kernel critical error occurs.

Default setting: 0 /PROC/SYS/KERNEL/PRINTK

The file has four numeric values that define where to send it, based on the importance of logging messages. For more information about different log levels, read the Syslog (2) online help page. The four values for this file are: Console log level: Messages with a higher priority than this value will be printed to the console default message log level: This priority will be used to print the lowest level of console log for messages with no priority: the minimum value (highest priority) that can be set by the console log level default console log level: Default for console log level

Default setting: 6 4 1 7 /proc/sys/kernel/shmall

The file is the total amount of shared memory (in bytes) that can be used on the system at any given time.

Default setting: 2097152 /proc/sys/kernel/shmax

This file specifies the size, in bytes, of the maximum shared memory segment allowed by the kernel.

Default setting: 33554432 /proc/sys/kernel/shmmni

This file represents the maximum number of shared memory segments for the entire system.

Default setting: 4096 /PROC/SYS/KERNEL/SYSRQ

If the file specifies a Non-zero value, the System Request Key is activated.

Default setting: 0 /proc/sys/kernel/threads-max

This file specifies the maximum number of threads that the kernel can use.

Default setting: 2048 /proc/sys/net /proc/sys/net/core/message_burst

The time required to write a new warning message (in 1/10 seconds), and other warning messages received during this time are discarded. This is used to prevent certain denial of service (Denial Ofservice) attacks used by people attempting to "drown" your system with the message.

Default setting: 50 (5 seconds) /proc/sys/net/core/message_cost

The file contains the cost values associated with each warning message. The larger the value, the more likely it is to ignore the warning message.

Default setting: 5 /proc/sys/net/core/netdev_max_backlog

This file specifies the maximum number of packets that are allowed to be sent to the queue when the interface receives packets at a faster rate than the kernel processes those packets.

Default setting: /proc/sys/net/core/optmem_max

This file specifies the maximum buffer size allowed for each socket. /proc/sys/net/core/rmem_default

This file specifies the default value, in bytes, that receives the socket buffer size. /proc/sys/net/core/rmem_max

This file specifies the maximum size, in bytes, of the receive socket buffer. /proc/sys/net/core/wmem_default

This file specifies the default value, in bytes, for the size of the send socket buffer. /proc/sys/net/core/wmem_max

This file specifies the maximum size of the send socket buffer, in bytes. /proc/sys/net/ipv4

All IPv4 and IPv6 parameters are recorded in the kernel source code document. Please refer to file/usr/src/linux/documentation/networking/ip-sysctl.txt. /proc/sys/net/ipv6

With IPV4. /PROC/SYS/VM /proc/sys/vm/buffermem

This file controls the amount of system memory (expressed as a percentage) for the buffer memory. It has three values and sets these three values by writing a string of digits to the file. Minimum percentage of memory used for buffers if there is not much memory left and system memory is decreasing, the system will attempt to maintain the amount of buffer memory. The maximum percentage of memory used for the buffer

Default setting: 2 /proc/sys/vm/freepages

This file controls how the system should respond to various levels of available memory. It has three values and sets these three values by writing a string of digits to the file. If the number of available pages in the system reaches the minimum limit, only the kernel is allowed to allocate some memory. If the number of pages available in the system is below this limit, the kernel will initiate the swap in a more aggressive manner to free up memory, thereby maintaining system performance. The kernel will attempt to keep this amount of system memory available. Below this value will start the kernel swap.

Default setting: 768 1024 /PROC/SYS/VM/KSWAPD

This file control allows the kernel to exchange memory. It has three values and sets these three values by writing a string of digits to the file: the maximum number of pages the kernel tries to release at one time. If you want to increase the bandwidth in the memory swap process, you need to increase the value. The minimum number of times the kernel tries to free pages in each swap. The number of pages written by the kernel in one swap. This has the greatest impact on system performance. The larger the value, the more data you exchange, and the less time you spend on disk search. However, this value is too general due to "drowning" the request queue and in turn affects system performance.

Default setting: 8 /proc/sys/vm/pagecache

This file is the same as/PROC/SYS/VM/BUFFERMEM, but it is a memory-mapped and general cache for files.

Make Kernel settings persistent

A handy utility is provided here to change any kernel parameters in the/proc/sys directory. It allows you to change the running kernel (similar to the Echo and redirection methods used above), but it also has a configuration file that executes when the system boots. This allows you to change the kernel in the run and add those changes to the configuration file so that the changes will still take effect after the system reboots.

The utility, called Sysctl, is documented in the online help page of Sysctl (8) for a complete documentation of the utility. The Sysctl configuration file is/etc/sysctl.conf, and you can edit the file and record it under sysctl.conf (8). Sysctl treats a file under/proc/sys as a single variable that can be changed. So, in the case of file/proc/sys/fs/file-max under/proc/sys, it represents the maximum number of file handles allowed in the system, which is represented as Fs.file-max.

This example reveals some of the wonderful things in sysctl notation. Because Sysctl can only change the variables in the/proc/sys directory, and people always think that the variable is in this directory, so omit the part of the variable name (/proc/sys). Another change to be described is to replace the directory separator (forward slash/) with a period in English (point.).

There are two simple rules for converting a file in/proc/sys to a variable in sysctl: Remove the previous part/proc/sys. Changes the forward slash in the file name to a point.

These two rules allow you to convert any file name in/proc/sys to any of the variable names in Sysctl. The conversion of a general file to a variable is:

/proc/sys/dir/file--> dir.file  
dir1.dir2.file-->/proc/sys/dir1/dir2/file  

You can use the command sysctl-a to view all variables that can be changed and their current settings.

You can also change a variable with sysctl, which works exactly like the Echo method used above. The notation is:

Sysctl-w dir.file= "Value"

Or use File-max as an example, change the value to 16384 using one of the following two methods:

Sysctl-w fs.file-max= "16384"

Or:

echo "16384" >/proc/sys/fs/file-max

Don't forget sysctl.

Changes will not be added to the configuration file, which you can do by hand. If you want the previous changes to remain valid after rebooting, you must maintain this profile.

Note: Not all distributions offer sysctl support. If this is the case for your particular system, you can add these commands to the startup script using the Echo and redirection methods described above, which will be executed each time the system boots.

Commands for setting up the system

It is possible to change other non-kernel system parameters while the system is running, and to make these settings effective without rebooting the system. The files that contain these parameters are listed in the/ETC/INIT.D directory, which are categorized primarily by service, daemon, and server. Since more and more scripts can be listed in this directory, it is not possible to discuss all the various configurations. However, here are some examples that discuss how to manipulate scripts under/ETC/INIT.D on different Linux distributions. The example here may be useful, which discusses the change daemon, and then reloading the configuration without rebooting the system: Changing the WEB server configuration and then reloading Apache to remove unwanted inetd Logon service operation network settings export a new file system start/stop firewall via NFS

First, the common approach is to direct the operation of the operating system through the/ETC/INIT.D in the script. These scripts manipulate the services they control with parameters, and you can see what valid options are available by entering the script name without any arguments. The common parameters are:
Start: Starting a service that has stopped
Stop: Stopping a running service
Restart: Stop the running service before restarting the service; It will start the service that stopped
Reload: Reload the service configuration without interrupting any connections
Status: Reporting whether the service is running or stopped

For example, the following command will reload the XINETD configuration without terminating any connected user sessions (this command is useful if you have changed/etc/xinetd.conf):

/ETC/INIT.D/XINETD Reload

Red Hat provides a service command that can operate services for you. The service command provides the same functionality as the input script name itself. Its syntax is as follows:

Service Script-name [parameter]

For example:

Service xinetd Reload

SuSE also provides a command named RC. This command is similar to the service command above, but there is no space between the command and the script name. Its syntax is as follows:

Rc{script-name} parameter

For example:

Rcapache start

Similar to changing kernel parameters, changes to these services will be lost once the system is rebooted. More and more distributions are now starting with the Chkconfig command, which manages services that start at various run levels, including at boot time. When writing this article, the syntax for the chkconfig command differs slightly depending on the Linux version, but if you enter a command chkconfig without any arguments, a list of how to use the command is displayed. You can also find more information about Chkconfig through the online help page of Chkconfig (8).

Http://www-900.ibm.com/developerWorks/cn/linux/l-adfly/index.shtml

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.