In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
When the physical memory of the Linux system is insufficient, a portion of the physical memory needs to be freed for use by the currently running program. The freed space may come from programs that have been inactive for a long time, and the freed space is temporarily saved in Swap space, and when those programs are about to run, the saved data is recovered from Swap to memory.
In the past, almost all books managed by Linux systems recommended that the swap partition size be 2 times the size of memory. These suggestions are so applicable now that today's servers are prone to 16GB/32GB or even 256GB memory, so should the corresponding swap partition be expanded to 32GB/64GB/512GB?
So what is the optimal size of the swap partition?
First, take a look at the recommendations on setting the size of swap partitions in Redhat's official documentation.
Physical memory-recommended swap space-recommended swap space if hibernation is turned on
2GB-2 times the memory-3 times the memory
2GB-8GB Murray-equal to memory size-twice the amount of memory
8GB-64GB Murray-at least 4G-1.5x memory
64GB-at least 4G-dormancy is not recommended
Therefore, in general, you can set the swap size according to the following rules:
For physical memory within 4 gigabytes, SWAP is set to 2 times the amount of memory and no more than 4 gigabytes.
4-8 gigabytes of physical memory, SWAP equal to memory size.
8-64 GB of physical memory, SWAP set to 8 GB.
64-256g physical memory, SWAP set to 16G.
In fact, the size of the swap partition in the system does not depend on the amount of physical memory, but on the load of memory in the system, so the value of SWAP should be set according to the specific business when installing the system.
Under what circumstances will the system use SWAP?
In fact, it is not until all the physical memory is consumed that the swap space is used, and when it is used is controlled by the value of the swappiness parameter.
Cat / proc/sys/vm/swappiness
thirty
-
The default value is 30 on centos 7 and 60 on Centos 6, which shows that the new version of linux is already adjusting according to memory size trends.
-
Swappiness=0 means maximum use of physical memory, followed by swap space
Swappiness=100 means actively using swap partitions and moving the data in memory to swap space in a timely manner.
Now the memory of the server is always hundreds of gigabytes, so we can set this parameter lower so that the operating system can use physical memory as much as possible, reduce the use of swap, and improve the performance of the system. Especially for database servers with high performance requirements, all of them are required to use memory.
How do I view the SWAP partition of the system?
Use the free command.
How do I modify swappiness parameters?
Temporary modification:
Sysctl vm.swappiness=10
Vm.swappiness = 10
Cat / proc/sys/vm/swappiness
ten
Our changes have taken effect here, but if we restart the system, it will become the system default again.
Permanent modification:
Add the following parameters to the / etc/sysctl.conf file:
Vm.swappiness=10
Then restart the system.
This article recommends the swap size setting for Redhat. The following are the recommended swap settings based on the actual work:
Physical memory-recommended swap space
"4GB-2 times the memory, no more than 4G
4GB-8GB-equal to memory size
8GB-64GB-8G
\ > 64GB-16G
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.