centos*开启swap
dd if=/dev/vda1 of=/mnt/swap2g bs=1MB count=2048
mkswap /mnt/swap2g
swapon /mnt/swap2g
nano /etc/fstab
#添加的内容
/mnt/swap2g swap swap defaults 0 0
nano /etc/sysctl.conf
行尾添加vm.swappiness = 10
- 激活设置:
sysctl -p
- 查看是否生效:
cat /proc/sys/vm/swappiness