Monday, March 7, 2011

Adding swap to a RedHat Linux host for Oracle 11gR2 installation

I was installing Oracle 11gR2 on a RedHat Linux when I got the message that there wasn't enough swap space.



On the host system you can total memory and swap as follows:


[root@isvx7 ~]# grep SwapTotal /proc/meminfo
SwapTotal:    16386292 kB
[root@isvx7 ~]# grep MemTotal /proc/meminfo
MemTotal:     65816328 kB

[root@isvx7 ~]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       16386292        0      -1

The following command will create a 1GB swap file

[root@isvx7 ~]# dd if=/dev/zero of=/swapfile bs=1024 count=1024000
1024000+0 records in
1024000+0 records out
1048576000 bytes (1.0 GB) copied, 5.02885 seconds, 209 MB/s
[root@isvx7 ~]# ls -lh /swapfile
-rw-r--r-- 1 root root 1000M Mar  7 16:48 /swapfile

Setup the swap with the command:

[root@isvx7 ~]# mkswap /swapfile
Setting up swapspace version 1, size = 1048571 kB

To enable swap use swapon, but this will not enable it again on  a reboot.

[root@isvx7 ~]# swapon /swapfile
[root@isvx7 ~]#


To enable swap at boot time, include the following in the /etc/fstab

[root@isvx7 ora_binaries]# cat /etc/fstab

/swapfile               swap                    swap    defaults        0 0

There we go, we can see that the 1GB swap file that we created has been added to swap

[root@isvx7 ora_binaries]# cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       16386292        0      -1
/swapfile                               file            1023992 0       -2
Now, let us see if Oracle recognises it.


There we go, the swap error message has gone. Ok, I know there are other error messages that are to be resolved, but one thing at a time :-)

No comments: