How to create a Oracle Database on LVM

SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 2
What LVM offers?

LVM is a way to club two or more hard drives into a logical space which can be easily resized (unlike partitions).
So to implement the LVM based database, following steps are required. Most of the steps are same as raw volumns, with the differences in disk partitioning & additional steps to create LVM. Here I’ll be using 2 disks  /dev/sdf & /dev/sdg.

STEP 1
======

Create Linux LVM partitions

1. n to create a new disk partition
2. p to create a primary disk partition
3. 1 to denote it as 1st disk partition
4. ENTER twice to accept the default of 1st and last cylinder – to convert the whole secondary hard disk to a single disk partition
5. t (will automatically select the only partition – partition 1) to change the default Linux partition type (0×83) to LVM partition type (0x8e)
6. L to list all the currently supported partition type
7. 8e (as per the L listing) to change partition 1 to 8e i.e. Linux LVM partition type
8. p to display the secondary hard disk partition setup. Please take note that the first partition is denoted as /dev/hdb1 in Linux
9. w to write the partition table and exit fdisk upon completion.

STEP 2
======

Create a LVM physical volume (PV)

# pvcreate /dev/sdi1

Physical volume “/dev/sdi1″ successfully created

STEP 3
======

Create a LVM volume group (VG) called vg0 with a physical extent size (PE size) of 8MB

# vgcreate -s 8M vg0 /dev/sdi1

Volume group “vg0″ successfully created

STEP 4
======

Check the Physical volume
# pvdisplay

  PV Name               /dev/sdi1
  VG Name               vg0
  PV Size               4.95 GB / not usable 2.62 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              1267
  Free PE               502
  Allocated PE          765
  PV UUID               yjeFgi-enbF-RoM1-dhEp-4dzT-xSc2-G3xvz1

STEP 5
======

Create logical volume (LV) on volume group vg0

lvcreate -L 800M -n systemvol vg0
Logical volume “systemvol” created

lvcreate -L 700M -n sysauxvol vg0
Logical volume “sysauxvol” created

lvcreate -L 500M -n undovol vg0
Logical volume “undovol” created

lvcreate -L 250M -n tempvol vg0
Logical volume “tempvol” created

lvcreate -L 120M -n usersvol vg0
Logical volume “usersvol” created

lvcreate -L 120M -n redovol1 vg0
Logical volume “redovol1″ created

lvcreate -L 120M -n redovol2 vg0
Logical volume “redovol2″ created

lvcreate -L 120M -n redovol3 vg0
Logical volume “redovol3″ created

lvcreate -L 110M -n controlvol1 vg0
Logical volume “controlvol1″ created

lvcreate -L 110M -n controlvol2 vg0
Logical volume “controlvol2″ created

lvcreate -L 50M -n spfilevol vg0
Logical volume “spfilevol” created

lvcreate -L 50M -n passwdvol vg0
Logical volume “passwdvol” created

STEP 6
======
Verify the logical volume created

# lvdisplay | more

  — Logical volume —
  LV Name                /dev/vg0/systemvol
  VG Name                vg0
  LV UUID                UBKKIV-IzYs-Ds04-P6CB-Iszc-eUDM-d1Lrpb
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                800.00 MB
  Current LE             250
  Segments               1
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:35

…………..
…………..
…………..

STEP 7
======
Check the Volume Group details
# vgdisplay vg0
   VG Name               vg0
   System ID
   Format                lvm2
   Metadata Areas        1
   Metadata Sequence No  15
   VG Access             read/write
   VG Status             resizable
   MAX LV                0
   Cur LV                12
   Open LV               9
   Max PV                0
   Cur PV                1
   Act PV                1
   VG Size               4.95 GB
   PE Size               4.00 MB
   Total PE              1267
   Alloc PE / Size       765 / 2.99 GB
   Free  PE / Size       502 / 1.96 GB
   VG UUID               bVklcB-nHYO-XiWx-1d9C-Iuvq-34fQ-Hem181

STEP 8
======

Change the permissions of the LV’s

chown ora11gr1:oinstall /dev/vg0/systemvol
chown ora11gr1:oinstall /dev/vg0/sysauxvol
chown ora11gr1:oinstall /dev/vg0/undovol
chown ora11gr1:oinstall /dev/vg0/tempvol
chown ora11gr1:oinstall /dev/vg0/usersvol
chown ora11gr1:oinstall /dev/vg0/redovol1
chown ora11gr1:oinstall /dev/vg0/redovol2
chown ora11gr1:oinstall /dev/vg0/redovol3
chown ora11gr1:oinstall /dev/vg0/controlvol1
chown ora11gr1:oinstall /dev/vg0/controlvol2
chown ora11gr1:oinstall /dev/vg0/spfilevol
chown ora11gr1:oinstall /dev/vg0/passwdvol
chown ora11gr1:oinstall /dev/raw/raw[0-9]*
chmod 660 /dev/vg0/systemvol
chmod 660 /dev/vg0/sysauxvol
chmod 660 /dev/vg0/undovol
chmod 660 /dev/vg0/tempvol
chmod 660 /dev/vg0/usersvol
chmod 660 /dev/vg0/redovol1
chmod 660 /dev/vg0/redovol2
chmod 660 /dev/vg0/redovol3
chmod 660 /dev/vg0/controlvol1
chmod 660 /dev/vg0/controlvol2
chmod 660 /dev/vg0/spfilevol
chmod 660 /dev/vg0/passwdvol

STEP 9
======
Add the Raw volume mapping in /etc/raw file

raw1001:vg0/systemvol
raw1002:vg0/sysauxvol
raw1003:vg0/undovol
raw1004:vg0/tempvol
raw1005:vg0/usersvol
raw1006:vg0/redovol1
raw1007:vg0/redovol2
raw1008:vg0/redovol3
raw1009:vg0/controlvol1
raw1010:vg0/controlvol2
raw1011:vg0/spfilevol
raw1012:vg0/passwdvol

STEP 10
=======

Bind the partitions to the raw devices  (Red Hat equivalent /sbin/service rawdevices restart)

/etc/init.d/raw start

bind /dev/raw/raw1001 to /dev/vg0/systemvol…                        done
bind /dev/raw/raw1002 to /dev/vg0/sysauxvol…                        done
bind /dev/raw/raw1003 to /dev/vg0/undovol…                          done
bind /dev/raw/raw1004 to /dev/vg0/tempvol…                          done
bind /dev/raw/raw1005 to /dev/vg0/usersvol…                         done
bind /dev/raw/raw1006 to /dev/vg0/redovol1…                         done
bind /dev/raw/raw1007 to /dev/vg0/redovol2…                         done
bind /dev/raw/raw1008 to /dev/vg0/redovol3…                         done
bind /dev/raw/raw1009 to /dev/vg0/controlvol1…                      done
bind /dev/raw/raw1010 to /dev/vg0/controlvol2…                      done
bind /dev/raw/raw1011 to /dev/vg0/spfilevol…                        done
bind /dev/raw/raw1012 to /dev/vg0/passwdvol…                        done

STEP 11
=======

To auto enable raw device binding, after system reboot

/sbin/chkconfig raw on

STEP 12
=======

Create raw configuration file for dbca

system=/dev/raw/raw1001
sysaux=/dev/raw/raw1002
undotbs1=/dev/raw/raw1003
temp=/dev/raw/raw1004
users=/dev/raw/raw1005
redo1_1=/dev/raw/raw1006
redo1_2=/dev/raw/raw1007
redo1_3=/dev/raw/raw1008
control1=/dev/raw/raw1009
control2=/dev/raw/raw1010
spfile=/dev/raw/raw1011
pwdfile=/dev/raw/raw1012

STEP 13
=======

Set the environment variable for defining the configuration file

NOTE: This step is optional. One can always choose the file while install. By setting this variable, DBCA will automatically populate this name in the raw devices section.
$ DBCA_RAW_CONFIG=<path>
$ export DBCA_RAW_CONFIG

STEP 14
=======
Start dbca and select the storage type as Raw Devices and check the Raw Device Mapping File.  Rest of the install is same.


STEP 15
=======
Crosscheck the details
SQL> select name from v$datafile union select name from v$tempfile;

NAME
——————————————————————————–
/dev/raw/raw1001
/dev/raw/raw1002
/dev/raw/raw1003
/dev/raw/raw1005
/dev/raw/raw1004

SQL> select name from v$controlfile;

NAME
——————————————————————————–
/dev/raw/raw1009
/dev/raw/raw1010

SQL> select member from  v$logfile;

MEMBER
——————————————————————————–
/dev/raw/raw1008
/dev/raw/raw1006

SQL> show parameter spfile

NAME                                 TYPE        VALUE
———————————— ———– ——————————
spfile                               string      /dev/raw/raw1011

Associated Commands
===================

lvremove /dev/vg0/*
vgremove vg0
pvremove /dev/sdi1

Associted Errors
================

ORA-202, ORA-27094: Raw Volume Used Can Damage Partition Table

When I tried using these Logical volumns for creating a 10.2.0.4 database, I started getting above error (even after creating the disk partition from 1st cylinder). I found a related Metalink note 738094.1, which talks something similar i.e. Oracle 10 database, LVM & ORA-202/ORA-27094.  I did not download the patch, but tried  this on Oracle 11 database.

About these ads
This entry was posted in Oracle Database Creation Assistant and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s