You are on page 1of 16

ASM HANDS-ON TRAINING

Lab 9 Migrating Raw and Block Devices to ASMLib


Alejandro Vargas | Principal Support Consultant
Oracle Advanced Customer Services

INDEX

Summary.......................................................................................................................................................................2
Create a Flash Recovery Area Diskgroup on The Available Block Devices.................................................................3
Remove raw devices configuration...............................................................................................................................4
Stop rawdevices and reboot the servers.......................................................................................................................6
Label the devices as oracle asm disks .........................................................................................................................8
Start the database and Check.....................................................................................................................................10
Scripts..........................................................................................................................................................................13

1/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib

Summary

ASMLib is best practice on Linux, it may happen that a database server that was configured a couple of years ago with
ASM 10g R1 is still using raw devices, or that a new ASM 10g R2 or even 11g was configured using block devices instead
of ASM.

This lab explain the procedure to migrate these devices to ASMLib.

The first step is to install ASMLib rpm’s and to configure ASMLib on the server. We already finish that part of the
procedure on lab 2 “Install and Configure ASMLib”

These are the steps required to complete the migration:

• Remove raw devices configuration


• Stop service rawdevices and reboot the ervers
• Label the devices as oracle asm disks
• Reconfigure discovery disk string

2/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib

Create a Flash Recovery Area Diskgroup on The Available Block Devices


In order to migrate block devices that are already in use we will create a diskgroup on the 3 available devices we still
have, after that we will migrate them to use ASMLib.

Check the available block devices

SQL> @chkblk.sql

DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE PATH


----------- ------- ------------ ------- -------- --------------------
8 CLOSED CANDIDATE ONLINE NORMAL /dev/sdf1
10 CLOSED CANDIDATE ONLINE NORMAL /dev/sdh1
9 CLOSED CANDIDATE ONLINE NORMAL /dev/sdg1

Connect to the ASM instance and create a diskgroup and move the database Flash Recovery Area to it.

SQL> create diskgroup FRADG external redundancy disk '/dev/sdf1','/dev/sdh1','/dev/sdg1';

Diskgroup created.

SQL> @chkblk

DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE PATH


----------- ------- ------------ ------- -------- --------------------
0 CACHED MEMBER ONLINE NORMAL /dev/sdf1
2 CACHED MEMBER ONLINE NORMAL /dev/sdg1
1 CACHED MEMBER ONLINE NORMAL /dev/sdh1

Connect to database sati’s and set it’s Flash recovery Area to be located on the FRADG diskgroup

3/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
SQL> show parameters recovery_file_dest

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +DATADGNR

SQL> alter system set db_recovery_file_dest='+FRADG' scope=both;

System altered.

SQL> show parameters recovery_file_dest

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
db_recovery_file_dest string +FRADG

Remove raw devices configuration


First we will check the devices configured as raw devices

@chkraw;
DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE PATH
----------- ------- ------------ ------- -------- ------------------------------
1 CACHED MEMBER ONLINE NORMAL /dev/raw/raw4
0 CACHED MEMBER ONLINE NORMAL /dev/raw/raw3
1 CACHED MEMBER ONLINE NORMAL /dev/raw/raw2
0 CACHED MEMBER ONLINE NORMAL /dev/raw/raw1

@chkdgraw;
PATH NAME

4/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
--------------- ------
/dev/raw/raw4 ARCHDG
/dev/raw/raw3 ARCHDG
/dev/raw/raw2 DATADG
/dev/raw/raw1 DATADG

On older systems raw devices are configured on the file /etc/sysconfig/rawdevices

On our Linux 5 environment they are binded to loop devices on startup using the raw command.

We will change the script that make the binding so that they will remain as loop devices only

The original script The new script


#!/bin/ksh #!/bin/ksh
# chgloop # chgloop2
# ------- # -------------
# setup loop devices and bind them to raw devices # setup loop devices for ASMLib
# #
losetup /dev/loop1 /u01/app/asm_loop_devices/fs_dsk1 losetup /dev/loop1 /u01/app/asm_loop_devices/fs_dsk1
losetup /dev/loop2 /u01/app/asm_loop_devices/fs_dsk2 losetup /dev/loop2 /u01/app/asm_loop_devices/fs_dsk2
losetup /dev/loop3 /u01/app/asm_loop_devices/fs_dsk3 losetup /dev/loop3 /u01/app/asm_loop_devices/fs_dsk3
losetup /dev/loop4 /u01/app/asm_loop_devices/fs_dsk4 losetup /dev/loop4 /u01/app/asm_loop_devices/fs_dsk4

raw /dev/raw/raw1 /dev/loop1 chmod 660 /dev/loop[1-4]


raw /dev/raw/raw2 /dev/loop2
raw /dev/raw/raw3 /dev/loop3
raw /dev/raw/raw4 /dev/loop4

raw -qa
chmod 660 /dev/raw/raw[1-4]
chown oracle:dba /dev/raw/raw[1-4]

5/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
Then we will change the startup script on /etc/rc.local

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/opt/desktop/obi_cc_script/obidata.sh
ls /dev/sd?1 | grep -v sda | xargs chown oracle:dba
ls /dev/sd?1 | grep -v sda | xargs chmod 660

# configure loop devices


/root/chgloop2

Stop rawdevices and reboot the servers

We will stop database, ASM and reboot the system

[oracle@asmxpt ~]$ ./stopsati

Database dismounted.
ORACLE instance shut down.

[oracle@asmxpt ~]$ ./stopasm


ASM diskgroups dismounted
ASM instance shutdown

6/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
[root@asmxpt ~]# reboot

Broadcast message from root (pts/1) (Thu Feb 12 02:03:40 2009):

The system is going down for reboot NOW!

Once the system comes up, check the loop devices, we did configure loop devices from 1 to 4

[oracle@asmxpt ~]$ ls -l /dev/loop*


brw-r----- 1 root disk 7, 0 Feb 12 02:05 /dev/loop0
brw-r----- 1 root disk 7, 1 Feb 12 02:05 /dev/loop1
brw-r----- 1 root disk 7, 2 Feb 12 02:05 /dev/loop2
brw-r----- 1 root disk 7, 3 Feb 12 02:05 /dev/loop3
brw-r----- 1 root disk 7, 4 Feb 12 02:05 /dev/loop4
brw-r----- 1 root disk 7, 5 Feb 12 02:05 /dev/loop5
brw-r----- 1 root disk 7, 6 Feb 12 02:05 /dev/loop6
brw-r----- 1 root disk 7, 7 Feb 12 02:05 /dev/loop7

Check defined ASM disks

[root@asmxpt ~]# ./chkasmdisks


ASM disk VOL1 based on /dev/sdb1 [8, 17]
ASM disk VOL2 based on /dev/sdc1 [8, 33]
ASM disk VOL3B based on /dev/sdd1 [8, 49]
ASM disk VOL4 based on /dev/sde1 [8, 65]

7/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib

Label the devices as oracle asm disks

Stamp the loop devices as ASM disks

[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/loop1 VOLOOP1


Renaming disk "/dev/loop1" to "VOLOOP1": [ OK ]
[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/loop2 VOLOOP2
Renaming disk "/dev/loop2" to "VOLOOP2": [ OK ]
[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/loop3 VOLOOP3
Renaming disk "/dev/loop3" to "VOLOOP3": [ OK ]
[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/loop4 VOLOOP4
Renaming disk "/dev/loop4" to "VOLOOP4": [ OK ]

Stamp the block devices as ASM disks also

[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/sdf1 VOLBLK1


Renaming disk "/dev/sdf1" to "VOLBLK1": [ OK ]
[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/sdg1 VOLBLK2
Renaming disk "/dev/sdg1" to "VOLBLK2": [ OK ]
[root@asmxpt ~]# /etc/init.d/oracleasm force-renamedisk /dev/sdh1 VOLBLK3
Renaming disk "/dev/sdh1" to "VOLBLK3": [ OK ]

List ASM disks

[root@asmxpt ~]# /etc/init.d/oracleasm listdisks


VOL1
VOL2
VOL3B
VOL4
VOLBLK1

8/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
VOLBLK2
VOLBLK3
VOLOOP1
VOLOOP2
VOLOOP3
VOLOOP4

Check ASM disks base devices

[root@asmxpt ~]# ./chkasmdisks


ASM disk VOL1 based on /dev/sdb1 [8, 17]
ASM disk VOL2 based on /dev/sdc1 [8, 33]
ASM disk VOL3B based on /dev/sdd1 [8, 49]
ASM disk VOL4 based on /dev/sde1 [8, 65]
ASM disk VOLBLK1 based on /dev/sdf1 [8, 81]
ASM disk VOLBLK2 based on /dev/sdg1 [8, 97]
ASM disk VOLBLK3 based on /dev/sdh1 [8, 113]
ASM disk VOLOOP1 based on /dev/loop1 vcs1 [7, 1]
ASM disk VOLOOP2 based on /dev/loop2 vcs2 [7, 2]
ASM disk VOLOOP3 based on /dev/loop3 vcs3 [7, 3]
ASM disk VOLOOP4 based on /dev/loop4 vcs4 [7, 4]

Start the Listener and ASM instance

[oracle@asmxpt ~]$ ./startlsnr


[oracle@asmxpt ~]$ ./startasm
ASM instance started

Total System Global Area 125829120 bytes


Fixed Size 1266176 bytes
Variable Size 99397120 bytes

9/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
ASM Cache 25165824 bytes
ASM diskgroups mounted

Use ASMCMD to Check status of Disk Groups after Migration

We can see that all disk groups were successfully mounted. We had set the parameter asm_diskstring to include the
string “ORCL:VOL*” that worked fine for all the stamped devices.

[oracle@asmxpt ~]$ asmcmd lsdg


State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED EXTERN N N 512 4096 1048576 1000 947 0 947 0 ARCHDG/
MOUNTED EXTERN N N 512 4096 1048576 1000 948 0 948 0 DATADG/
MOUNTED NORMAL N N 512 4096 1048576 8188 4662 2047 1307 0 DATADGNR/
MOUNTED EXTERN N N 512 4096 1048576 2000 1944 0 1944 0 DATAONFS/
MOUNTED EXTERN N N 512 4096 1048576 6141 6087 0 6087 0 FRADG/

Start the database and Check

[oracle@asmxpt ~]$ ./startsati


ORACLE instance started.

Total System Global Area 369098752 bytes


Fixed Size 1267548 bytes
Variable Size 113248420 bytes
Database Buffers 251658240 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened.

10/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib

[oracle@asmxpt ~]$ sql

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Feb 12 02:59:22 2009

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> archive log list


Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 80
Next log sequence to archive 82
Current log sequence 82
SQL> alter system archive log current;

System altered.

SQL> exit

Check that the current log was archived on the FRADG disk group

[oracle@asmxpt ~]$ asmcmd ls fradg/sati/archivelog/2009_02_12/


thread_1_seq_79.256.678595657

11/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
thread_1_seq_80.257.678595665
thread_1_seq_81.258.678595667
thread_1_seq_82.259.678596379

12/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib

Scripts

Chkraw.sql

-- chkraw.sql
-- Check ASM disks configured on raw devices
set pages 50000 lines 120
col path for a15
select disk_number,mount_status,header_status,mode_status,state,path
from v$asm_disk
where path like '%raw%';

Chkblk.sql

-- chkblk.sql
-- Check ASM disks configured on block devices
set pages 50000 lines 120
col path for a15
select disk_number,mount_status,header_status,mode_status,state,path
from v$asm_disk
where path like '%sd%';

Chkdgraw.sql

-- chkdgraw.sql
-- Check ASM diskgroup built on raw devices
set pages 50000 lines 120
col path for a15
select a.path,b.NAME from v$asm_disk a, v$asm_diskgroup b
where a.GROUP_NUMBER=b.GROUP_NUMBER and

13/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
a.path like '%raw%' ;

Chkasmdisks

#!/bin/ksh
# chkasmdisks
# Map ASM disks to its base devices
# ---------------------------------
/etc/init.d/oracleasm querydisk `/etc/init.d/oracleasm listdisks` | cut -f2,10,11 -d" " |
perl -pe 's/"(.*)".*\[(.*), *(.*)\]/$1 $2 $3/g;' | while read v_asmdisk v_minor v_major
do
v_device=`ls -la /dev | grep " $v_minor, *$v_major " | awk '{print $10}'`
echo "ASM disk $v_asmdisk based on /dev/$v_device [$v_minor, $v_major]"
done

Startlsnr

#!/bin/ksh
# ---------
# startlsnr
# ---------
export ORACLE_BASE=/u01/app/oracle/10g_db
export ORACLE_HOME=/u01/app/oracle/10g_db
export BASE_PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/java/jre1.5.0_10/bin:
/home/oracle/bin:/sbin:/usr/sbin:/etc/init.d:/home/oracle
export PATH=${ORACLE_HOME}/bin:${BASE_PATH}

clear
lsnrctl start LISTENER_ASMXPT
lsnrctl status LISTENER_ASMXPT
lsnrctl services LISTENER_ASMXPT

14/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
# ---------
# eof startlsnr

Startasm

#!/bin/ksh
# ---------
# startasm
# ---------
export ORACLE_BASE=/u01/app/oracle/10g_db
export ORACLE_HOME=/u01/app/oracle/10g_db
export ORACLE_SID=+ASM
export BASE_PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/java/jre1.5.0_10/bin:
/home/oracle/bin:/sbin:/usr/sbin:/etc/init.d:/home/oracle
export PATH=${ORACLE_HOME}/bin:${BASE_PATH}

clear
sqlplus -s / as sysdba<<eof
startup
exit
eof
# ---------
# eof startasm

Startsati

#!/bin/ksh
# ---------
# startsati
# ---------
export ORACLE_BASE=/u01/app/oracle/10g_db

15/16
ASM HANDS-ON TRAINING
Lab 9 Migrating Raw and Block Devices to ASMLib
export ORACLE_HOME=/u01/app/oracle/10g_db
export ORACLE_SID=sati
export BASE_PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/java/jre1.5.0_10/bin:
/home/oracle/bin:/sbin:/usr/sbin:/etc/init.d:/home/oracle
export PATH=${ORACLE_HOME}/bin:${BASE_PATH}

clear
sqlplus -s / as sysdba<<eof
startup
exit
eof
# ---------
# eof startsati

End of Lab9

16/16

You might also like