查看swap 大小
一般的swap大小是实体内存的1-2倍,本例修改为内存的1.5倍。
[root@services swap]# free
total used free shared buff/cache available
Mem: 1882356 92720 1116504 492 673132 1624656
Swap: 0 0 0
可以看到此服务器没有设置 swap 大小,这里我们为了安装oracle12c,将swap调整为3G
设置swap文件大小
创建/usr/swap文件,并进入该文件
[root@services ~]# mkdir /usr/swap && cd /usr/swap
创建3g大小文件
[root@services swap]# dd if=/dev/zero of=swapfile bs=1G count=3
3+0 records in
3+0 records out
3221225472 bytes (3.2 GB) copied, 30.0177 s, 107 MB/s
查看文件大小
[root@services swap]# ll
total 3145732
-rw-r–r-- 1 root root 3221225472 May 14 21:39 swapfile
修改为swap文件格式
[root@services swap]# mkswap /usr/swap/swapfile
Setting up swapspace version 1, size = 3145724 KiB
no label, UUID=1cc9cb0c-4cc7-4c2d-981c-11da20dd9014
设置永久生效
删除原来swap类型行数据,新增一行/usr/swap/swapfile swap swap defaults 0 0
[root@services swap]# vi /etc/fstab
/dev/mapper/centos-root / xfs defaults 0 0
UUID=b8febb87-f699-469b-8ba8-425f54aa99d0 /boot xfs defaults 0 0
#/dev/mapper/centos-swap swap swap defaults 0 0
/usr/swap/swapfile swap swap defaults 0 0