在REDHAT LINUX 5.5 X86_64操作系统上安装ORACLE 10G 时发现,SWAP 分区只有786M,安装程序check时报错。
REDHAT LINUX 5.5 是安装在VMWARE 的一个虚拟机上。分配了一个10G的磁盘用于安装操作系统和补丁包,分配了一个10G的磁盘用于安装ORACLE软件(ORACLE RDBMS SERVER和GRID CONTROL)。
本文就如何修改LINUX SWAP 区,进行了一些实验操作。
[root@linux_oracle ~]# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
[root@linux_oracle ~]# vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 1 1 0 wz--n- 9.12G 0
oravg 1 1 0 wz--n- 10.00G 96.00M
[root@linux_oracle ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol00 VolGroup00 -wi-ao 9.12G
LogVol01 VolGroup00 -wi-ao 768M
lv_oracle oravg -wi-ao 9.90G
[root@linux_oracle ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 VolGroup00 lvm2 a- 9.12G 0
/dev/sdb oravg lvm2 a- 10.00G 96.00M
[root@linux_oracle ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
8.8G 4.4G 4.4G 50% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/mapper/oravg-lv_oracle
9.8G 4.4G 5.0G 47% /oracle
因为swap区太小(只有786M),将影响到ORACLE的安装及以后的正常运行,需要增加swap区的空间.
增加swap有两个方法:1. 增加swap文件 2.增加swap磁盘分区
方法一: 增加swap文件的方法
#mkdir /swap_dir
#cd /swap_dir/
#dd if=/dev/zero of=/swap_dir/swap bs=1M COUNT=2048
#ls -lt /swap_dir/swap
#mkswap /swap_dir/swap
#free (查看swap的大小,768M )
#swapon /swap_dir/swap
#free (查看swap的大小,2816M)
#vi /etc/fstab
增加一行,保证下次系统重新启动是,自动挂载这个swap.
/swap_dir/swap swap swap defaults 0 0
这样增加swap后,/目录只剩余2g空间,而且swap只有2.6G,(ORACLE 建议4G以上),这种方法可以解决增加swap的大小的问题,但同时也减少了文件系统的空间.
方法二. 增加swap磁盘分区.
首先在vmware服务器上将原来10G的磁盘空间扩充到15G,然后使用新增加的5G划分一个新的磁盘分区,新分区的id设置为82(Linux swap / Solaris),然后使用这个分区作为独立的swap区.
系统磁盘游10G增加到15G后,最好重新启动一下操作系统,方便识别到新的磁盘空间。
#reboot
#fdisk -l
Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
发现/dev/sda 由原来的10.7G,增加到了16.1G,1958个 cylinders,目前使用到了1305.
#fdisk /dev/sda
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1306-1958, default 1306):
Using default value 1306
Last cylinder or +size or +sizeM or +sizeK (1306-1958, default 1958):
Using default value 1958
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]# fdisk -l
Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1305 10377990 8e Linux LVM
/dev/sda3 1306 1958 5245222+ 82 Linux swap / Solaris
#partprobe
同步分区信息
root@localhost ~]# mkswap /dev/sda3
Setting up swapspace version 1, size = 5371101 kB
[root@localhost ~]# swapon /dev/sda3
[root@localhost ~]# swapon -s
Filename Type Size Used Priority
/dev/mapper/VolGroup00-LogVol01 partition 786424 0 -1
/swap_dir/swap file 2097144 0 -2
/dev/sda3 partition 5245212 0 -3
[root@localhost ~]# free
total used free shared buffers cached
Mem: 4044464 417392 3627072 0 28960 284488
-/+ buffers/cache: 103944 3940520
Swap: 8128780 0 8128780
[root@localhost ~]# swapoff /swap_dir/swap
[root@localhost ~]# swapoff /dev/mapper/VolGroup00-LogVol01
删除旧的两个swap设备,只保留新增的swap分区.
[root@localhost ~]# swapon -s
/dev/sda3 partition 5245212 0 -3
[root@localhost ~]# vi /etc/fstab
……
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/swap_dir/swap swap swap defaults 0 0
增加
/dev/sda3 swap swap defaults 0 0
[root@linux_oracle ~]# more /etc/fstab
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sda3 swap swap defaults 0 0
[root@linux_oracle ~]# free
total used free shared buffers cached
Mem: 4044464 3637020 407444 0 40852 3214008
-/+ buffers/cache: 382160 3662304
Swap: 5245212 0 5245212