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

How to change the value of swappiness in Linux system

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Linux system how to change the swappiness value, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Swappiness is a kernel parameter of Linux that controls the relative weight of memory usage of the system when swap is performed. The swappiness parameter value can be set between 0 and 100. The worthy size of swappiness determines the swap space.

Check the swappiness value to check the current swappiness value on the system, use the following cat command:

The default swappiness value of $cat / proc/sys/vm/swappiness on most Linux distributions is 60, that is, the returned information is:

sixty

Although the swappiness value of 60 is suitable for most users, in some cases, you may need to set a lower value.

Another command you can use to determine the swappiness value is sysctl:

The returned message of $sysctl vm.swappiness is:

Vm.swappiness = 60

The method Swappiness that changes the swappiness value can have a value between 0 and 100. a value of 0 indicates that the kernel actively avoids swapping for as long as possible, and a value of 100 will actively swap the process out of physical memory.

A lower value will make the kernel avoid swapping as much as possible, while a higher value means that the kernel will try to use swap space more actively.

Accessing swap memory is much slower than accessing physical memory directly, and a lower value of the swappiness parameter is likely to improve overall system performance. For regular desktop installations, the recommended value is 10, and for most database servers, a swappiness value of 0 or 1 is recommended.

The best swappiness value depends on your system workload and the size of RAM memory. You should adjust this parameter in small increments to find the best value.

For example, to set the swappiness value to 10 at run time, enter the following command as the root or sudo user:

Sudo sysctl vm.swappiness=1 to keep the swappiness parameter unchanged after a reboot, open the / etc/sysctl.conf file using a text editor:

$sudo nano / etc/sysctl.conf finds the vm.swappiness parameter and changes its value, and if this parameter does not exist, append the following line to the / etc/sysctl.conf file:

Vm.swappiness=1 thank you for reading this article carefully. I hope the article "how to change the swappiness value of Linux system" shared by the editor will be helpful to you. At the same time, I also hope you will support us and follow the industry information channel. More related knowledge is waiting for you to learn!

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

Development

Wechat

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

12
Report