linux添加虛擬記憶體解決swap空間不足問題
增加一個SWAP檔案:
1. 查看當前虛擬記憶體
[root@ora11gr2 ~]# free -m
total used free shared buffers cached
Mem: 2026 217 1809 0 11 126
-/+ buffers/cache: 78 1947
Swap: 2047 0 2047
[root@ora11gr2 ~]#
[root@ora11gr2 ~]#
[root@ora11gr2 mapper]# ll
total 0
crw------- 1 root root 10, 63 Mar 19 00:11 control
brw-rw---- 1 root disk 253, 0 Mar 19 00:11 VolGroup00-LogVol00
brw-rw---- 1 root disk 253, 1 Mar 19 00:11 VolGroup00-LogVol01
[root@ora11gr2 mapper]#
[root@ora11gr2 mapper]#
2. 將當前swap空間由2047mb增加到3047mb 新增一個1024mb 的swap 檔案
[root@ora11gr2 mapper]# dd if=/dev/zero of=/home/swap bs=1024 count=1024000
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 29.5369 seconds, 35.5 MB/s
3.執行以下命令增加並啟用虛擬記憶體
[root@ora11gr2 mapper]# mkswap /home/swap
Setting up swapspace version 1, size = 1048571 kB
[root@ora11gr2 mapper]# swapon /home/swap
[root@ora11gr2 mapper]# cd /home/
[root@ora11gr2 home]# ll
total 1025008
drwx------ 3 oracle oinstall 4096 Mar 18 23:49 oracle
-rw-r--r-- 1 root root 1048576000 Mar 19 00:14 swap
[root@ora11gr2 home]# free -m
total used free shared buffers cached
Mem: 2026 1232 793 0 13 1127
-/+ buffers/cache: 92 1934
Swap: 3047 0 3047