In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces what are the commonly used kernel tuning parameters of Linux, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
one。 All TCP/IP tuning parameters are located in the / proc/sys/net/ directory. For example, here are some of the most important tuning parameters, followed by what they mean:
1. / proc/sys/net/core/rmem_max-maximum TCP data reception buffer
2. / proc/sys/net/core/wmem_max-maximum TCP data send buffer
3. / proc/sys/net/ipv4/tcp_timestamps-the timestamp adds 12 bytes to the packet header of TCP (see RFC 1323)
4. / proc/sys/net/ipv4/tcp_sack-selective response
5. / proc/sys/net/ipv4/tcp_window_scaling-supports larger TCP windows. If the maximum TCP window is more than 65535 (64K), you must set this value to 1
6. Rmem_default-default receive window size
7. Rmem_max-maximum size of the receive window
8. Wmem_default-default send window size
9. Wmem_max-maximum size of the send window
Everything in the / proc directory is temporary, so any changes will be lost after rebooting the system.
It is recommended that you automatically modify the TCP/IP parameters when the system starts:
Add the following code to the / etc/rc.local file, then save the file, and the following TCP/IP parameters will be automatically modified when the system reboots:
Echo 256960 > / proc/sys/net/core/rmem_default
Echo 256960 > / proc/sys/net/core/rmem_max
Echo 256960 > / proc/sys/net/core/wmem_default
Echo 256960 > / proc/sys/net/core/wmem_max
Echo 0 > / proc/sys/net/ipv4/tcp_timestamps
Echo 1 > / proc/sys/net/ipv4/tcp_sack
Echo 1 > / proc/sys/net/ipv4/tcp_window_scaling
The TCP/IP parameters are self-interpreting, and the TCP window size is set to 256960, which forbids the timestamp of TCP (cancels the addition of 12 bytes in the header of each packet), supports a larger TCP window and TCP selective replies.
The above values are set according to the Internet connection and the maximum bandwidth / delay rate.
Note: the value in the above example can be applied in practice, but it only contains some parameters.
Another way: use / etc/sysctl.conf to configure the parameters to the values you set when the system starts:
Net.core.rmem_default = 256960
Net.core.rmem_max = 256960
Net.core.wmem_default = 256960
Net.core.wmem_max = 256960
Net.ipv4.tcp_timestamps = 0
Net.ipv4.tcp_sack = 1
Net.ipv4.tcp_window_scaling = 1
two。 System kernel parameters-
1./proc/sys/fs/super-max
This file specifies the maximum number of super block handlers. Any mounted file system requires the use of super blocks, so if you mount a large number of file systems, you may run out of super block handlers.
Default: 256
2./proc/sys/fs/super-nr
This file shows the number of currently allocated super blocks. The file is read-only and is used to display information only.
3./proc/sys/kernel
/ proc/sys/kernel/acct
The file has three configurable values that control when process accounting starts, depending on the amount of free space (as a percentage) on the file system that contains the logs:
If the free space is lower than this percentage, stop the process accounting
If the free space is higher than this percentage value, start the process accounting
Check the frequency of the above two values (in seconds)
To change a value in this file, you should send back a string of numbers separated by spaces.
Default: 2 4 30
"if there is less than 2% free space on the file system that contains logs, these values stop accounting, and if 4% or more space is available, start accounting again." Check every 30 seconds.
4./proc/sys/kernel/ctrl-alt-del
The file has a binary value that controls how the system reacts when it receives a combination of ctrl+alt+delete keys. These two values represent:
A zero (0) value means that the ctrl+alt+delete is captured and sent to the init program. This will allow the system to shut down and restart perfectly, as if you were typing the shutdown command.
A value of one (1) means that the ctrl+alt+delete is not captured and a non-clean shutdown will be performed, just as if the power was turned off directly.
Default setting: 0
5./proc/sys/kernel/domainname
This file allows you to configure a network domain name. It has no default, maybe the domain name has been set, or it may not have been set.
6./proc/sys/kernel/hostname
This file allows you to configure the network hostname. It has no default value, maybe the hostname has been set, maybe it hasn't.
7./proc/ss/kernel/msgmax
This file specifies the maximum length of messages sent from one process to another. Inter-process messaging occurs in kernel memory and is not swapped to disk, so increasing this value increases the amount of memory used by the operating system.
Default: 8192
8./proc/sys/kernel/msgmnb
This file specifies the maximum number of bytes in a message queue.
Default: 16384
9./proc/sys/kernel/msgmni
This file specifies the maximum number of message queue identities.
Default: 16
10./proc/sys/kernel/panic
This file indicates the amount of time (in seconds) that the kernel waits before rebooting if a "kernel critical error (kernel panic)" occurs. The zero (0) second setting forbids reboot in the event of a kernel critical error.
Default setting: 0
11./proc/sys/kernel/printk
The file has four numeric values that define where to send logging messages based on their importance. For more information about different log levels, read the syslog (2) online help page. The four values of the file are:
Console log level: messages with priority higher than this value will be printed to the console
Default message log level: this priority will be used to print messages without priority
Lowest console log level: the minimum value (highest priority) at which the console log level can be set
Default console log level: the default value of the console log level
Default: 6 4 1 7
12./proc/sys/kernel/shmall
This file is the total amount of shared memory (in bytes) that can be used on the system at any given time.
Default: 2097152
13./proc/sys/kernel/shmax
This file specifies the size in bytes of the maximum shared memory segment allowed by the kernel.
Default: 33554432
14./proc/sys/kernel/shmmni
This file represents the maximum number of shared memory segments for the entire system.
Default: 4096
15./proc/sys/kernel/sysrq
If the value specified by the file is non-zero, System Request Key is activated.
Default setting: 0
16./proc/sys/kernel/threads-max
This file specifies the maximum number of threads that the kernel can use.
Default: 2048
17./proc/sys/net
/ proc/sys/net/core/message_burst
The time it takes to write a new warning message (in 1x10 seconds); other warning messages received during this time are discarded. This is used to prevent denial of service (Denial of Service) attacks used by people who attempt to "flood" your system with messages.
Default: 50 (5 seconds)
18./proc/sys/net/core/message_cost
The file contains the cost value associated with each warning message. The higher the value, the more likely it is to ignore warning messages.
Default setting: 5
19./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 faster than the kernel processes them.
Default: 300
20./proc/sys/net/core/optmem_max
This file specifies the maximum buffer size allowed for each socket.
21./proc/sys/net/core/rmem_default
This file specifies the default value (in bytes) for the size of the receive socket buffer.
22./proc/sys/net/core/rmem_max
This file specifies the maximum size of the receive socket buffer in bytes.
23./proc/sys/net/core/wmem_default
This file specifies the default (in bytes) of the send socket buffer size.
24./proc/sys/net/core/wmem_max
This file specifies the maximum size of the send socket buffer in bytes.
25./proc/sys/net/ipv4
All parameters for IPv4 and IPv6 are recorded in the kernel source code documentation. Refer to the file / usr/src/linux/Documentation/networking/ip-sysctl.txt.
26./proc/sys/net/ipv6
Same as IPv4.
27./proc/sys/vm
/ proc/sys/vm/buffermem
This file controls the amount (as a percentage) of the entire system memory used for buffer memory. It has three values, which are set by writing a string of numbers separated by spaces to the file.
Minimum percentage of memory used for buffers
If there is not much system memory left and the system memory is decreasing, the system will attempt to maintain the amount of buffer memory.
Maximum percentage of memory used for buffers
Default: 2 10 60
28./proc/sys/vm/freepages
This file controls how the system responds to all levels of available memory. It has three values, which are set by writing a string of numbers separated by spaces to the file.
If the minimum number of pages available on the system is reached, only some memory is allowed to be allocated by the kernel.
If the number of pages available on the system falls below this limit, the kernel will initiate swapping in a more positive way to free memory and thus maintain system performance.
The kernel will try to keep this amount of system memory available. Below this value will start kernel swapping.
Default: 512 768 1024
29./proc/sys/vm/kswapd
This file controls how the kernel is allowed to swap memory. It has three values, which are set by writing a string of numbers separated by spaces to the file:
The maximum number of pages that the kernel tries to release at a time. You need to increase this value if you want to increase the bandwidth during memory swapping.
The minimum number of times the kernel tries to free a page in each exchange.
The number of pages written by the kernel in a swap. This has the greatest impact on system performance. The higher the value, the more data is exchanged and the less time is spent on disk seek. However, this value is too high to "flood" the request queue, which in turn affects system performance.
Default: 512 32 8
30./proc/sys/vm/pagecache
This file works the same as / proc/sys/vm/buffermem, but it is for memory mapping and general caching of files.
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 redirect methods used above), but it also has a configuration file that executes when the system boots. This allows you to change the running kernel and add those changes to the configuration file so that they remain in effect after the system is rebooted.
The utility, called sysctl, is fully documented on the online help page of sysctl (8). The configuration file for sysctl is / etc/sysctl.conf, which can be edited and recorded under sysctl.conf (8). Sysctl treats the file under / proc/sys as a single variable that can be changed. So, take the file / proc/sys/fs/file-max under / proc/sys as an example, which represents the maximum number of file handles allowed in the system, which is represented as fs.file-max.
This example reveals some wonderful things in the sysctl notation. Because sysctl can only change variables in the / proc/sys directory, and people always think that variables are in this directory, the part of the variable name (/ proc/sys) is omitted. Another change to be noted is the replacement of the directory delimiter (forward slash /) with the English full stop (dot.).
There are two simple rules for converting files in / proc/sys to variables in sysctl:
Remove the previous part / proc/sys.
Change the forward slash in the file name to a dot.
These two rules enable you to convert any filename in / proc/sys to any variable name in sysctl. The general conversion from file to variable is as follows:
/ 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 variables with sysctl, which does exactly the same thing as the echo method used above. It is expressed as follows:
Sysctl-w dir.file= "value"
Using file-max as an example, use one of the following two methods to change the value to 16384.
This is the end of the kernel tuning parameters commonly used in Linux. I hope the above can be helpful to you and learn more. 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.