以前作过实验而未作记录,今天在生产坏境中再次遇到。现将整个操做过程记录以下,供之后参考使用:
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
以上三种方式皆可,此次用的是低三种方式,方便。