红联Linux门户
Linux帮助

安装Oracle时报SWAP空间不足的处理方法

发布时间:2015-12-22 10:54:44来源:linux网站作者:dbaway

在安装Oracle的时候,可能因为我们分配的swap空间不够导致安装失败。处理步骤如下:


1.SWAP空间为2G

[root@linux01 oracle]# free
total      used      free    shared    buffers    cached
Mem:      2039004    1207260    831744          0      22668    833660
-/+ buffers/cache:    350932    1688072
Swap:      2097144          0    2097144

通过dd命令创建一个临时的swap file,大小为1Gb

[root@linux01 oracle]# dd if=/dev/zero of=/home/oracle/swap.file bs=1024k count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 16.711 s, 64.3 MB/s


2.通过mkswap命令格式化步骤1中创建的临时交换文件

[root@linux01 oracle]# mkswap /home/oracle/swap.file
mkswap: /home/oracle/swap.file: warning: don't erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=99e682db-bb37-444a-a8db-ee742a71b5d3


3.通过swapon命令使swap文件生效,如下:

[root@linux01 oracle]# swapon /home/oracle/swap.file


4.通过free命令或者grep swap /proc/meminfo检查添加swap的效果,如下:

[root@linux01 oracle]# free
total      used      free    shared    buffers    cached
Mem:      2039004    1955200      83804          0      12348    1569000
-/+ buffers/cache:    373852    1665152
Swap:      3145712          0    3145712
[root@linux01 oracle]# grep Swap /proc/meminfo
SwapCached:            0 kB
SwapTotal:      3145712 kB
SwapFree:        3145712 kB


5.如果需要永久有效,那么需要将新加的swap设备文件写到fstab文件中,使其每次服务器重启都会自动生效

echo "/home/oracle/swap.file swap  swap    defaults        0 0">>/etc/fstab


6.在临时设备上面关闭SWAP

[root@linux01 oracle]# swapoff /home/oracle/swap.file
[root@linux01 oracle]# free
total      used      free    shared    buffers    cached
Mem:      2039004    1955324      83680          0      12440    1569460
-/+ buffers/cache:    373424    1665580
Swap:      2097144          0    2097144


不推荐这么做,最好还是安装系统的时候分配足够的swap空间,但是如果确实出现这个问题了,也是一个很有效率的解决方案。


Linux非图形界面安装Oracle数据库:http://www.linuxdiyf.com/linux/14391.html

fedora22安装oracle11gr2:http://www.linuxdiyf.com/linux/13991.html

ubuntu-15.04-desktop-amd64.iso:安装Oracle11gR2:http://www.linuxdiyf.com/linux/13116.html

64位Ubuntu安装Oracle 11G:http://www.linuxdiyf.com/linux/9955.html

Ubuntu 14.04 LTS 64位安装Oracle 11g:http://www.linuxdiyf.com/linux/9954.html