业务需要增加swap虚拟内存
~]# free -h
total used free shared buff/cache available
Mem: 31G 15G 234M 121M 15G 15G
Swap: 0B 0B 0B
~]# ls /
bin boot dev etc home lib lib64 media mnt oa opt proc root run sbin srv sys tmp usr var
# 创建swap file
~]# dd if=/dev/zero of=/swap bs=1M count=8192
8192+0 records in
8192+0 records out
8589934592 bytes (8.6 GB) copied, 7.93159 s, 1.1 GB/s
# 格式化文件。
#将swapfile格式化为swap
~]# mkswap /swap
Setting up swapspace version 1, size = 8388604 KiB
no label, UUID=050d2736-9b55-4aee-bd34-bee92175add0
# 赋权
~]# chmod 0600 /swap
# 激活虚拟内存。
# 激活swap
~]# swapon /swap
~]# free -h
total used free shared buff/cache available
Mem: 31G 15G 233M 121M 15G 15G
Swap: 8.0G 0B 8.0G
~]#
~]# vi /etc/fstab
~]# cat /etc/fstab
/swap swap swap defaults 0 0
~]# free -h
total used free shared buff/cache available
Mem: 31G 15G 223M 121M 15G 15G
Swap: 8.0G 0B 8.0G
~]# swapon --show
NAME TYPE SIZE USED PRIO
/swap file 8G 0B -2
~]#