Custom Search . . .

Wednesday, April 1, 2009

How to crate ASM disk in linux


1. Creating files using "dd" command

[oracle@localhost asmdisks]$ su - root
Password:
[root@localhost ~]# mkdir /dbbackup/asmdiks


[root@localhost ~]# chown oracle:oinstall /dbbackup/asmdiks/
[root@localhost ~]#
[root@localhost ~]# su - oracle



[oracle@localhost ~]$ dd if=/dev/zero of=/dbbackup/asmdiks/_file_disk1 bs=1k count=1000000
1000000+0 records in
1000000+0 records out

[oracle@localhost ~]$ dd if=/dev/zero of=/dbbackup/asmdiks/_file_disk2 bs=1k count=1000000
1000000+0 records in
1000000+0 records out

[oracle@localhost ~]$ dd if=/dev/zero of=/dbbackup/asmdiks/_file_disk3 bs=1k count=1000000
1000000+0 records in
1000000+0 records out

[oracle@localhost ~]$ cd /dbbackup/asmdiks/

[oracle@localhost asmdiks]$ ls -lrt
total 3002964
-rw-r--r-- 1 oracle oinstall 1024000000 Mar 27 04:45 _file_disk1
-rw-r--r-- 1 oracle oinstall 1024000000 Mar 27 04:48 _file_disk2
-rw-r--r-- 1 oracle oinstall 1024000000 Mar 27 04:52 _file_disk3


2. Makeing RAW disk using "losetup" command


[oracle@localhost asmdiks]$ su - root
Password:


[root@localhost ~]# losetup /dev/loop1 /dbbackup/asmdiks/_file_disk1

[root@localhost ~]# losetup /dev/loop2 /dbbackup/asmdiks/_file_disk2

[root@localhost ~]# losetup /dev/loop3 /dbbackup/asmdiks/_file_disk3

[root@localhost ~]## raw /dev/raw/raw1 /dev/loop1
/dev/raw/raw1: bound to major 7, minor 1

[root@localhost ~]## raw /dev/raw/raw2 /dev/loop2
/dev/raw/raw2: bound to major 7, minor 2

[root@localhost ~]## raw /dev/raw/raw3 /dev/loop3
/dev/raw/raw3: bound to major 7, minor 3


4. Change Ownership of RAW Devices


Finally, let's change the ownership of all four RAW devices:

# chown oracle:dba /dev/raw/raw1
# chown oracle:dba /dev/raw/raw2
# chown oracle:dba /dev/raw/raw3
# chown oracle:dba /dev/raw/raw4

# chmod 775 /dev/raw/raw1
# chmod 775 /dev/raw/raw2
# chmod 775 /dev/raw/raw3
# chmod 775 /dev/raw/raw4


5. Startup Script


Before restarting your OS you need to write small script for enable your raw disk in /etc/init.d/


/sbin/losetup /dev/loop1 /asmdisks/_file_disk1; sleep 2

/sbin/losetup /dev/loop2 /asmdisks/_file_disk2; sleep 2
/sbin/losetup /dev/loop3 /asmdisks/_file_disk3; sleep 2
/sbin/losetup /dev/loop4 /asmdisks/_file_disk4; sleep 2

/usr/bin/raw /dev/raw/raw1 /dev/loop1; sleep 2
/usr/bin/raw /dev/raw/raw2 /dev/loop2; sleep 2
/usr/bin/raw /dev/raw/raw3 /dev/loop3; sleep 2
/usr/bin/raw /dev/raw/raw4 /dev/loop4; sleep 2

/bin/chown oracle:dba /dev/raw/raw1
/bin/chown oracle:dba /dev/raw/raw2
/bin/chown oracle:dba /dev/raw/raw3
/bin/chown oracle:dba /dev/raw/raw4

/bin/chmod 660 /dev/raw/raw1
/bin/chmod 660 /dev/raw/raw2
/bin/chmod 660 /dev/raw/raw3
/bin/chmod 660 /dev/raw/raw4

sleep 120

su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart"

su - $ORACLE_OWNER -c "lsnrctl start listener"

No comments: