以前作過實驗而未作記錄,今天在生產壞境中再次遇到。現將整個操做過程記錄以下,供之後參考使用:
node
使用free -m查看如今swap的大小:bash
[root@mcluster-alpha2-node2 ~]# free -mapp
total used free shared buffers cachedide
Mem: 48227 47870 356 0 1862 28928spa
-/+ buffers/cache: 17079 31148orm
Swap: 5999 5138 861xml
如上可知如今可用的swap分區爲6G,且絕大部分被佔用。ci
swap的擴充有三種方法:it
若是你原有的swap是用的lvm,那很簡單。擴容lvm便可。class
Disable swapping for the associated logical volume: # swapoff -v /dev/VolGroup00/LogVol01 Resize the LVM2 logical volume by 256 MB: # lvm lvresize /dev/VolGroup00/LogVol01 -L +256M Format the new swap space: # mkswap /dev/VolGroup00/LogVol01 Enable the extended logical volume: # swapon -va Test that the logical volume has been extended properly: # cat /proc/swaps 或者# free
2.新建邏輯卷作swap分區
Create the LVM2 logical volume of size 256 MB: # lvm lvcreate VolGroup00 -n LogVol02 -L 256M Format the new swap space: # mkswap /dev/VolGroup00/LogVol02 Add the following entry to the /etc/fstab file: /dev/VolGroup00/LogVol02 swap swap defaults 0 0 Enable the extended logical volume: # swapon -va Test that the logical volume has been extended properly: # cat /proc/swaps 或者# free
3.新建swapfile
mkdir /letv/swap dd if=/dev/zero of=/letv/swap/96g.out bs=1G count=96 mkswap /letv/swap/96g.out -f swapon -p 100 /letv/swap/96g.out echo '/letv/swap/96g.out swap swap defaults 0 0' >> /etc/fstab
以上三種方式皆可,此次用的是低三種方式,方便。