Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of adjusting Linux kernel parameters

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you the relevant knowledge of what the method of Linux kernel parameter adjustment is. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's learn about it.

Ulimit Settin

Ulimit-n needs to be adjusted to 100000 or more. Execute ulimit-n 100000 from the command line to modify it. If you cannot modify it, you need to set / etc/security/limits.conf and join.

Soft nofile 262140

Hard nofile 262140

Root soft nofile 262140

Root hard nofile 262140

Soft core unlimited

Hard core unlimited

Root soft core unlimited

Root hard core unlimited

Kernel Settin

Net.unix.max_dgram_qlen = 100

Swoole uses unix socket dgram for interprocess communication, and this parameter needs to be adjusted if the number of requests is large. The system defaults to 10 and can be set to 100 or greater.

Or increase the number of worker processes and reduce the number of requests allocated by a single worker process.

Net.core.wmem_max

Modify this parameter to increase the memory size of the socket cache

Net.ipv4.tcp_mem = 379008 505344 758016

Net.ipv4.tcp_wmem = 4096 16384 4194304

Net.ipv4.tcp_rmem = 4096 87380 4194304

Net.core.wmem_default = 8388608

Net.core.rmem_default = 8388608

Net.core.rmem_max = 16777216

Net.core.wmem_max = 16777216

Net.ipv4.tcp_tw_reuse

Whether or not socket reuse, this function is used to quickly reuse the listening port when Server is restarted. If this parameter is not set, it will cause the failure to start when the port is not released in time when server is restarted.

Net.ipv4.tcp_tw_recycle

Use socket for quick recycling. This parameter needs to be enabled for short connection Server.

Message queuing Settings

This kernel parameter needs to be adjusted when message queuing is used as the mode of interprocess communication

Kernel.msgmnb = 4203520, the maximum number of bytes of the message queue

Kernel.msgmni = 64, the maximum number of message queues allowed to be created

Kernel.msgmax = 8192, the maximum length of a single data in the message queue

FreeBSD/MacOS

Sysctl-w net.local.dgram.maxdgram=8192

Sysctl-w net.local.dgram.recvspace=200000 modifies the buffer area size of Unix Socket

Turn on CoreDump

Set kernel parameters

Kernel.core_pattern = / data/core_files/core-%e-%p-%t

View the limits of the current coredump file through the ulimit-c command

Ulimit-c

If it is 0, you need to modify / etc/security/limits.conf to set the limit.

After opening core-dump, if an exception occurs in the program, the process will be exported to a file. It is of great help to investigate procedural problems.

For other important configurations, the following are brothers' companies.

Www.lampbrother.net

Method demonstration:

Net.ipv4.tcp_syncookies=1

Net.ipv4.tcp_max_syn_backlog=81920

Net.ipv4.tcp_synack_retries=3

Net.ipv4.tcp_syn_retries=3

Net.ipv4.tcp_fin_timeout = 30

Net.ipv4.tcp_keepalive_time = 300

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_tw_recycle = 1

Net.ipv4.ip_local_port_range = 20000 65000

Net.ipv4.tcp_max_tw_buckets = 200000

Net.ipv4.route.max_size = 5242880

Check whether the configuration is in effect

For example, after modifying net.unix.max_dgram_qlen = 100, pass the

Cat / proc/sys/net/unix/max_dgram_qlen

These are all the contents of the article "what is the method of adjusting Linux kernel parameters?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report