Swap frequency of use
By adjusting the swappiness
value, the system can be used to adjust the frequency of the swap
The smaller the value, the greater the extent of physical memory, min = 0
The larger the value, the more active the swap swap, max = 100
View swappiness value
cat /proc/sys/vm/swappiness
centos default is 10, Ubuntu default 60
Temporary modification (restart failure)
sysctl vm.swappiness=59
Permanent modification
echo "vm.swappiness=59" >> /etc/sysctl.conf
- This link: Use https://docs.lvrui.io/2017/06/02/Swap frequency /
- Disclaimer: This blog All articles unless otherwise specified, are used BY-NC-SA license. Please indicate the source!
On / off function + SWAP SWAP to make the file / partition
Can be used in linux
free -m
command to view memory usage (including use of swap swap partition) on the meaning of existence of the swap will not be discussed, and some people in some circumstances need to open the swap function to ensure that the program does not crash; there who in some cases you need to close the swap feature to ensure that "no dang rather slow."
On / off function swap
Open
- The swap file:
swapon /opt/swapfile
- swap partition:
swapon /dev/sdb1
shut down
- The swap file:
swapoff /opt/swapfile
- swap partition:
swapoff /dev/sdb1
If the system is set up swap during the installation, at a later stage want to close swap feature, you can go to modify /etc/fstab
file
Swap information will contain this line commented out/dev/mapper/centos-swap swap swap defaults 0 0
Increase swap space
Production swap file
1 |
# Create a file 1G as a swap using |
Production swap partition
1 |
# Create a swap partition |
Tips: If the machine has 2G swap swap partition, and make the swap file partition 8G, then the execution swapon
after the command, swap space for 10G (swap space will accumulate)