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 modify swappiness parameters in Linux system

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

Share

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

This article mainly shows you "how to modify happiness parameters in Linux system", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "how to modify happiness parameters in Linux system" this article bar.

Linux systems generally need to configure a little swap partition, desktop configuration a little more, server configuration a little less. The details of how swap partitions are used are controlled by a parameter called swap.

Check Swappiness Value

To check the current happiness value on the system, use the following cat command:

cat /proc/sys/vm/swappiness

The default happiness value on most Linux distributions is 60:

60

While a swappiness value of 60 is appropriate for most users, in some cases you may want to set a lower value.

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

sysctl vm. swappiness vm.swappiness = 60 Change the Swappiness value

Swappiness can have values between 0 and 100. A value of 0 indicates that the kernel actively avoids swapping for as long as possible. A value of 100 actively swaps processes out of physical memory.

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

Access to swap memory is much slower than direct access to physical memory. Lower values of the happiness parameter are likely to improve overall system performance. For regular desktop installations, the recommended value is 10. For most database servers, a happiness value of 0 or 1 is recommended.

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

For example, to set the happiness value to 10 at runtime, type the following command as root or sudo user:

sudo sysctl vm.swappiness=10

To keep the happiness parameter unchanged after a restart, use a text editor to open the file/etc/sysctl.conf:

sudo nano /etc/sysctl.conf

Find the vm. happiness parameter and change its value. If this parameter does not exist, append the following line to the file/etc/sysctl.conf

vm. happiness =10 above is "how to modify happiness parameters in Linux system" all the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to 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

Development

Wechat

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

12
Report