What are the Linux system tuning parameters?

Source: Internet
Author: User

All TCP/IP tuning parameters are in the/proc/sys/net/directory. For example, the following are some of the most important optimization parameters, which are followed by their meanings:

1./proc/sys/net/core/rmem_max-maximum TCP Data receiving buffer 2./proc/sys/net/core/wmem_max-maximum TCP data sending buffer 3, /proc/sys/net/ipv4/tcp_timestamps-timestamp in (refer to RFC 1323) add 12 bytes to the TCP Header. 4./proc/sys/net/ipv4/tcp_sack-select the response. 5./proc/sys/net/ipv4/tcp_window_scaling-support larger TCP window. if the maximum TCP window is 65535 (64 K ), you must set this value to 16, rmem_default-default Receiving Window Size 7, rmem_max-maximum receiving window size 8, and wmem_default-default sending window size 9. wmem_max-maximum size of the sending window

All contents in the/proc directory are temporary, so any modifications will be lost after the system is restarted.

We recommend that you automatically modify the TCP/IP parameters when starting the system:

Add the following code to the/etc/rc. local file and save the file. When the system restarts, the following TCP/IP parameters are automatically modified:

echo 256960 > /proc/sys/net/core/rmem_defaultecho 256960 > /proc/sys/net/core/rmem_maxecho 256960 > /proc/sys/net/core/wmem_defaultecho 256960 > /proc/sys/net/core/wmem_maxecho 0 > /proc/sys/net/ipv4/tcp_timestampsecho 1 > /proc/sys/net/ipv4/tcp_sackecho 1 > /proc/sys/net/ipv4/tcp_window_scaling

The TCP/IP parameters are self-explanatory. The TCP window size is set to 256960 and the TCP timestamp is disabled (12 bytes are removed from the header of each packet ), supports larger TCP windows and selective responses over TCP.

The above value is determined based on the Internet connection and the maximum bandwidth/latency rate.

Note: The value in the above instance can be used in practice, but it only contains some parameters.

Another method: Use/etc/sysctl. conf to set the parameter to the value you set when the system starts:

net.core.rmem_default = 256960net.core.rmem_max = 256960net.core.wmem_default = 256960net.core.wmem_max = 256960net.ipv4.tcp_timestamps = 0net.ipv4.tcp_sack =1net.ipv4.tcp_window_scaling = 1

----------------------------------------------------------------

/proc/sys/fs/super-max

This file specifies the maximum number of super block processors. Super block is required for any mounted file system. Therefore, if a large number of mounted file systems are installed, the super block processing program may be used up.

Default: 256

/proc/sys/fs/super-nr

This file displays the number of allocated Super blocks. This file is read-only and only used to display information.

/proc/sys/kernel/proc/sys/kernel/acct

This file has three configurable values that control when process accounting starts based on the number of available space on the file system containing logs (expressed in percentages:

  • If the available space is lower than this percentage value, stop process accounting
  • Process accounting starts if the available space is higher than this percentage value
  • Check the frequency of the above two values (in seconds)
  • To change a value of this file, you should return a string of numbers separated by spaces.

Default setting: 2 4 30

If there is only less than 2% of the available space on the file system that contains logs, these values will stop billing. If there is 4% or more available space, start billing again. Check every 30 seconds.

/proc/sys/kernel/ctrl-alt-del

This file has a binary value that controls how the system responds when receiving a combination of ctrl + alt + delete keys. The two values indicate:

  • Zero (0) indicates capturing ctrl + alt + delete and sending it to the init program. This allows the system to be shut down and restarted perfectly, just as if you entered the shutdown command.
  • The value 1 indicates that ctrl + alt + delete is not captured, and non-clean shutdown will be executed, as if the power is directly turned off.

Default Value: 0.

/proc/sys/kernel/domainname

This file allows you to configure the network domain name. It does not have the default value. It may have already set the domain name, or it may not have been set.

/proc/sys/kernel/hostname

This file allows you to configure the network host name. It does not have a default value, maybe the host name has been set, or maybe not.

/proc/sys/kernel/msgmax

This file specifies the maximum length of the message sent from one process to another. Messages are transmitted between processes in the kernel memory and are not exchanged to the disk. Therefore, if this value is increased, the memory used by the operating system is increased.

Default: 8192

/proc/sys/kernel/msgmnb

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

Default: 16384

/proc/sys/kernel/msgmni

This file specifies the maximum number of Message Queue IDs.

Default setting: 16

/proc/sys/kernel/panic

This file indicates the waiting time (in seconds) of the kernel before the reboot in the event of "kernel panic ). Zero (0) seconds will disable reboot in the event of a serious kernel error.

Default Value: 0.

/proc/sys/kernel/printk

This file has four numeric values, which define where messages are sent based on the importance of logging. For more information about different log levels, see the online help page of syslog (2. The four values of this file are:

  • Console Log Level: messages with a higher priority will be printed to the console
  • Default Message Log Level: this priority is used to print messages with no priority.
  • Lowest console Log Level: Minimum value that can be set at the console Log Level (highest priority)
  • Default console Log Level: Default console Log Level

Default settings: 6 4 1 7

/proc/sys/kernel/shmall

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

Default: 2097152

/proc/sys/kernel/shmax

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

Default: 33554432

/proc/sys/kernel/shmmni

This file indicates the maximum number of shared memory segments used by the entire system.

Default: 4096

/proc/sys/kernel/sysrq

If the specified value of this file is non-zero, the System Request Key is activated.

Default Value: 0.

/proc/sys/kernel/threads-max

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

Default: 2048

/proc/sys/net/proc/sys/net/core/message_burst

The time required to write a new warning message (in 1/10 seconds). Other warning messages received during this time will be discarded. This is used to prevent Denial of Service (Denial of Service) Attacks by certain people who attempt to "flood" your system with messages.

Default setting: 50 (5 seconds)

/proc/sys/net/core/message_cost

This file contains cost values related to 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 allowed to be sent to the queue when the interface receives packets at a rate faster than the kernel processes these packets.

Default: 300

/proc/sys/net/core/optmem_max

This file specifies the maximum buffer size allowed by each socket.

/proc/sys/net/core/rmem_default

This file specifies the default value of the buffer size of the receiving socket (in bytes ).

/proc/sys/net/core/rmem_max

This file specifies the maximum buffer size of the received socket (in bytes ).

/proc/sys/net/core/wmem_default

This file specifies the default value of the buffer size of the sending socket (in bytes ).

/proc/sys/net/core/wmem_max

This file specifies the maximum size of the buffer for sending Sockets (in bytes ).

/proc/sys/net/ipv4

All IPv4 and IPv6 parameters are recorded in the kernel source code documentation. See the file/usr/src/linux/Documentation/networking/ip-sysctl.txt.

/proc/sys/net/ipv6

Same as IPv4.

/proc/sys/vm/proc/sys/vm/buffermem

This file controls the total number of system memories used for the buffer memory (expressed as a percentage ). It has three values. You can set these values by writing a string of numbers separated by spaces to the file.

Minimum Percentage of memory used for the Buffer Zone

If the remaining system memory is small and the system memory is decreasing, the system will try to maintain the number of buffer memory.

Maximum percentage of memory used for the Buffer Zone

Default setting: 2 10 60

/proc/sys/vm/freepages

The file control system can cope with various levels of available memory. It has three values. You can set these values by writing a string of numbers separated by spaces to the file.

  • If the number of available pages reaches the minimum limit, only the kernel is allowed to allocate some memory.
  • If the number of available pages in the system is lower than this limit, the kernel starts the SWAp in a more active way to release the memory to maintain system performance.
  • The kernel will try to keep this amount of system memory available. If the value is lower than this value, kernel switching will be started.

Default: 512 768 1024

/proc/sys/vm/kswapd

This file controls how the kernel can swap memory. It has three values. You can write a string of numbers separated by spaces into the file to set these three values:

  • The maximum number of pages that the kernel tries to release at a time. This value is required if you want to increase the bandwidth during memory swap.
  • The minimum number of times the kernel tries to release the page during each switch.
  • 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 is exchanged, and the less time it takes to track the disk. However, this value is too large to be "overwhelmed" by The Request queue, which in turn affects system performance.

Default setting: 512 32 8

/proc/sys/vm/pagecache

This file is the same as/proc/sys/vm/buffermem, but it is for File Memory ing and general high-speed cache.

Make kernel settings persistent

A convenient utility is provided 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 is executed during system boot. This allows you to change the running kernel and add these changes to the configuration file so that these changes take effect after the system is rebooted.

This utility is called sysctl. On the online help page of sysctl (8), complete documentation is provided for this utility. The sysctl configuration file is/etc/sysctl. conf. You can edit the file and record it under sysctl. conf (8. Sysctl treats files in/proc/sys as a single variable that can be changed. Therefore, taking the file/proc/sys/fs/file-max in/proc/sys as an example, it indicates the maximum number of file handles allowed in the system, this file is represented as fs. file-max.

This example reveals some wonderful things in sysctl notation. Because sysctl can only change the variables in the/proc/sys directory, and people always think that the variables are under this directory, the part of the variable name (/proc/sys) is omitted ). Another note is to change the directory separator (forward slash/) to a period (Dot.) in English .).

There are two simple rules to convert files in/proc/sys to variables in sysctl:

  • Remove the previous section/proc/sys.
  • Change the forward slash in the file name to a vertex.

These two rules allow you to convert any file name in/proc/sys to any variable name in sysctl. Generally, the conversion from a file to a variable is as follows:

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

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

You can also use sysctl to change the variable, which performs exactly the same work as the echo method used above. The representation is:

sysctl -w dir.file="value"

Use file-max as an example to change the value to 16384 using one of the following two methods.

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.