1.查看系统Swap空间使用
[root@oracle root]# free
total used free shared buffers cached
Mem: 513980 493640 20340 0 143808 271780
-/+ buffers/cache: 78052 435928
Swap: 1052248 21256 1030992
2.在空间合适处创建swap文件
[root@oracle root]# mkdir swap
[root@oracle root]# cd swap
[root@oracle swap]# dd if=/dev/zero of=swapfile bs=1024 count=10000
10000+0 records in
10000+0 records out
[root@oracle swap]# ls -al
total 10024
drwxr-xr-x 2 root root 4096 8月 15 10:18 .
drwxr-xr-x 19 root root 4096 8月 15 10:17 ..
-rw-r--r-- 1 root root 10240000 8月 15 10:18 swapfile
[root@oracle swap]# mkswap swapfile
Setting up swapspace version 1, size = 9996 KiB
3.激活swap文件
[root@oracle swap]# swapon swapfile
[root@oracle swap]# ls -l
total 10016
-rw-r--r-- 1 root root 10240000 8月 15 10:18 swapfile
[root@oracle swap]# free
total used free shared buffers cached
Mem: 513980 505052 8928 0 143900 282288
-/+ buffers/cache: 78864 435116
Swap: 1062240 21256 1040984
[root@oracle swap]#
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7230168/viewspace-968791/ ,如需转载,请注明出处,否则将追究法律责任。