Monday, April 11, 2011

RAW Device and ASM for Oracle Database Creation on Linux & Solaris Platform

Hi,
We do have some doubts related to RAW Device and ASM when it comes to practical.
The below practical of mine can be useful to understand RAW Device and ASM and how both can be used to Create Database on Linux and Solaris Platform.

1.A)DATABASE CREATION ON RAW PARTITION ON LINUX:

Step 1:Create Logical volumes from Volume Group:
#pvcreate /dev/sdc
#pvdisplay – to display the information of volume
#vgcreate rawvg /dev/sdc
#vgdisplay -- to display the volume groups
#lvcreate –L 500 –n rawvg1 rawvg  for system (fixed)
#lvcreate –L 500 –n rawvg2 rawvg  for sysaux (fixed)
#lvcreate –L 500 –n rawvg3 rawvg  for undo
#lvcreate –L 250 –n rawvg4 rawvg  for temp
#lvcreate –L 160 –n rawvg5 rawvg  for example
#lvcreate –L 120 –n rawvg6 rawvg  for users
#lvcreate –L 120 –n rawvg7 rawvg  for redo logfiles
#lvcreate –L 120 –n rawvg8 rawvg  for redo logfiles
#lvcreate –L 120 –n rawvg9 rawvg  for redo logfiles
#lvcreate –L 110 –n rawvg10 rawvg  for control file
#lvcreate –L 110 –n rawvg11 rawvg  for control file
#lvcreate –L 110 –n rawvg12 rawvg  for control file
#lvcreate –L 5 –n rawvg13 rawvg  for spfile
#lvcreate –L 5 –n rawvg14 rawvg  for password file

Step 2:Grant ownership and permissions to your Logical volume:
chown oracle:oinstall /dev/rawvg/rawvg*
chmod 775 /dev/rawvg/rawvg*


Step 3:Create the configuration file for RAW DEVICE
create a text file orcl_raw.conf in /export/home/oracle

vi /export/home/oracle/orcl_raw.conf

system=/dev/rawvg/rawvg1
sysaux=/dev/rawvg/rawvg2
undotbs1=/dev/rawvg/rawvg3
temp=/dev/rawvg/rawvg4
example=/dev/rawvg/rawvg5
users=/dev/rawvg/rawvg6
redo1_1=/dev/rawvg/rawvg7
redo1_2=/dev/rawvg/rawvg8
red01_3=/dev/rawvg/rawvg9
control1=/dev/rawvg/rawvg10
control2=/dev/rawvg/rawvg11
control3=/dev/rawvg/rawvg12
spfile=/dev/rawvg/rawvg13
pwdfile=/dev/rawvg/rawvg14

Step 4:Create a Mapping file for Linux Understanding that it is RAW PARTITIONS

Linux does not support directly raw partitions, so we have to bind it explicitely to make linux understand that these are raw partitions.

DBCA_RAW_CONFIG=/export/home/oracle/raw_orcl.conf -- creation of mapping file
export DBCA_RAAW_CONFIG


vi /etc/sysconfig/rawdevices

/dev/raw/raw1 /dev/rawvg/rawvg1
/dev/raw/raw2 /dev/rawvg/rawvg2
/dev/raw/raw3 /dev/rawvg/rawvg3
/dev/raw/raw4 /dev/rawvg/rawvg4
/dev/raw/raw5 /dev/rawvg/rawvg5
/dev/raw/raw6 /dev/rawvg/rawvg6
/dev/raw/raw7 /dev/rawvg/rawvg7
/dev/raw/raw8 /dev/rawvg/rawvg8
/dev/raw/raw9 /dev/rawvg/rawvg9
/dev/raw/raw10 /dev/rawvg/rawvg10
/dev/raw/raw11 /dev/rawvg/rawvg11
/dev/raw/raw12 /dev/rawvg/rawvg12
/dev/raw/raw13 /dev/rawvg/rawvg13
/dev/raw/raw14 /dev/rawvg/rawvg14

#/sbin/service rawdevicess restart ----- to restart the rawdevices services
#/usr/bin/raw –qa ------ to view the binded raw devices

chown oracle:oinstall /dev/raw/raw*
chmod 775 /dev/raw/raw*

Step 5: RUN DBCA for creating Database
RUN THE DBCA AND CREATE THE DATABASE, MAKE SURE TO SELECT THE DATABASE TO BE CREATED ON RAW PARTITIONS.

**1.B)CREATING THE DATABASE WITH ASM ON LINUX:

Step 1: Create four partitions using fdisk utility like
/dev/sdb6
/dev/sdb7
/dev/sdb8
/dev/sdb9

Step 2:edit /etc/sysconfig/rawdevices and add following lines
/dev/raw/raw15 /dev/sdb6
/dev/raw/raw16 /dev/sbd7
/dev/raw/raw17 /dev/sdb8
/dev/raw/raw18 /dev/sdb9

Step 3:Now restart the raw devices services
/sbin/service rawdevices restart
To check it, /usr/bin/raw –qa

Step 4:Now we have to change the ownership to oracle user (software owner)
chown oracle:oinstall /dev/raw/raw*
chmod 775 /dev/raw/raw*

Step 5:Create the ASM Parameter file(i.e Parameter file for ASM Database)
#cd /export/home/oracle
#vi asminit.ora
Instance_name=+ASM
Instance_type=ASM
Asm_power_limit=1
Asm_diskstring=’/dev/raw/raw15’,’/dev/raw/raw16’.’/dev/raw/raw17’,’/dev/raw/raw18’
:wq

Step 6:Start Our ASM Instance
# cd $ORACLE_HOME/bin
./localconfig add => it will start the services for asm instance

Now login as Oracle USER and start the listener
$ lsnrctl start
$export ORACLE_SID=+ASM
$orapwd file=$ORACLE_HOME/dbs/orapw+ASM password=oracle
$sqlplus “/as sysdba”
>create spfile from pfile=’/export/home/oracle/asminit.ora’
>startup nomount
>create diskgroup dbgroup1 normal redundancy
Failgroup controller1 disk
‘/dev/raw/raw15’,
‘/dev/raw/raw16’
Failgroup controller2 disk
‘/dev/raw/raw17’,
‘/dev/raw/raw18’;

Step 7:Create the ASM Database using DBCA
* Open another terminal and run the dbca utility.

[ if after configuring the listner through netmgr,it is not working for connection string, then give following command on sql prompt,

>alter system register;

Cool your ASM Database is ready on Linux.Now lets try on Solaris platform.


** 2.A)DATABASE CREATION WITH RAW PARTITION ON SOLARIS :

 Make a replica
# metadb –a –f c1t1d0s6
#metadb –a –c 2 c1t1d0s7
#metadb –i  will display the information of replica
#metainit d4 1 4 c1t2d0s0 c1t2d0s1 c1t3d0s0 c1t4d0s1
#metainit d10 –p d4 500mb - system
#metainit d11 –p d4 500mb  sysaux
#metainit d12 –p d4 500mb  undotbs1
#metainit d13 –p d4 250mb  temp
#metainit d14 –p d4 160mb  example
#metainit d15 –p d4 120mb  users
#metainit d16 –p d4 120mb  redo1_1
#metainit d17 –p d4 120mb  redo1_2
#metainit d18 –p d4 120mb  control1
#metainit d19 –p d4 120mb  control2
#metainit d20 –p d4 5mb  spfile
#metainit d21 –p d4 5mb  pfile

 #chown oracle:oinstall /dev/md/rdsk/d*
 #chmod 775 /dev/md/rdsk/d*
 LOG IN AS ORACLE
 create a text file in ORACLE_HOME named dbname_raw.conf (where dbname is the name of the database u want to make)
$vi $ORACLE_HOME/dbname_raw.conf
System=/dev/md/rdsk/d10
Sysaux= /dev/md/rdsk/d11
Undotbs1=/dev/md/rdsk/d12
Temp=/dev/md/rdsk/d13
Example=/dev/md/rdsk/d14
Users=/dev/md/rdsk/d15
Redo1_1=/dev/md/rdsk/d16
Redo1_2=/dev/md/rdsk/d17
Control1=/dev/md/rdsk/d18
Control2=/dev/md/rdsk/d19
Spfile=/dev/md/rdsk/d20
Pfile=/dev/md/rdsk/d21
:wq

$export DBCA_RAW_CONFIG=$ORACLE_HOME/dbname_raw.conf
$dbca (enter)

**2.B)DATABASE CREATION WITH ASM ON SOLARIS :

 Create 4 slices named c1t2d0s3, c1t2d0s4,c1t2d0s5 and c1t2d0s6. we will use this slices for asm database creation.
 create init.ora file for asm
# cd /export/home
vi init.ora
instance_name=+ASM
instance_type=ASM
ASM_POWER_LIMIT=1
ASM_DISKSTRING=/dev/rdsk/c1t2d0s[3456]
:wq

#chown oracle:oinstall /dev/rdsk/c1t2d0s3
#chown oracle:oinstall /dev/rdsk/c1t2d0s4
#chown oracle:oinstall /dev/rdsk/c1t2d0s5
#chown oracle:oinstall /dev/rdsk/c1t2d0s6
#chmod 775 /dev/rdsk/c1t2d0s3
#chmod 775 /dev/rdsk/c1t2d0s4
#chmod 775 /dev/rdsk/c1t2d0s5
#chmod 775 /dev/rdsk/c1t2d0s6

 #cd $ORACLE_HOME/bin
#./localconfig add

 log out and log in as oracle user
$export ORACLE_SID=+ASM
$sqlplus “/as sysdba”
>create spfile from pfile=’/export/home/init.ora’
>startup nomount
> create diskgroup dbgroup1 normal redundancy
Failgroup controller1 disk
‘/dev/rdsk/c1t2d0s3’,
‘/dev/rdsk/c1t2d0s4’
Failgroup controller2 disk
‘/dev/rdsk/c1t2d0s5’,
‘/dev/rdsk/c1t2d0s6’;
>exit
$dbca (enter)


Hope it helps in understanding RAW and ASM better.

Best regards,

Rafi.

No comments:

Post a Comment