Cloud Server Swap Configuration
One, create a file for the swap partition:
dd if=/dev/zero of=/opt/swap bs=1M count=8192
Two, set the swap partition file:
mkswap /opt/swap
Third, enable swap partition files now
swapon /opt/swap
Four, view swap partitions
swapon -s
Five, set the SWAP partition to be self-enabled when booting:
Vim/etc/fstab
/opt/swap swap swap defaults 0 0
Six, modify the swpapiness parameter
When the value of the swappiness content is 0 o'clock, the SWAP partition is used when the physical memory is used to maximize physical memory. When the value of the swappiness content is 100, the swap partition is actively used, and the in-memory data is replaced in a timely manner to the swap partition.
Currently in effect settings
echo 10 > /proc/sys/vm/swappiness
Permanent Entry Settings
Vim/etc/sysctl.conf
vm.swappiness=10
Close swap operation
Currently closed
swapoff /mnt/swap
Permanently closed
Vim/etc/fstab
#/opt/swap swap swap defaults 0 0
Cloud Server ECS Linux SWAP configuration