Migrating from raw devices to ASMLIB

Oracle’s Automatic Storage Management (ASM) technology was introduced with releases 10.1 of its flagship database product. It was designed to remove from the database administrator’s task list the need to decide on which disks to place which datafiles.
It is effectively a database aware logical volume manager. The database administrator provides disk to a diskgroup, and any database instance on the node can use the storage management services provided by ASM.
The disks provided are the subject of this document.
ASM can use either raw character based devices or block based devices, which are accessed through a special kernel driver provided by Oracle called ASMLib. ASMLib bypasses standard host kernel I/O and performs direct writes to the underlying devices. Raw devices are a deprecated technology that were originally designed to allow a user to bypass the filesystem cache on a node and perform direct writes to a device via a character based stream. Raw devices proved to be difficult to manage over time, as standard filesystem utilities such as cp, mv, dns df were not available (since it is not, after all, a filesystem).
Since raw devices are deprecated, to move to block devices accessed via ASMLib, the following steps can be undertaken to migrate existing diskgroups using raw devices to ASMLib.
1. Get your kernel version
2. Navigate your browser to http://www.oracle.com/technology/tech/linux/asmlib/index.html and select your platform from downloads section of the page
3. Download the “Library and Tools” rpm’s, and then the kernel driver for your kernel obtained above.
4. Copy these to your database host.
5. Install them

[root@linux5 oracleasm-2.0.5]# rpm -Uvh oracleasm-support-2.1.2-1.el5.i386.rpm
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [100%]
 [root@linux5 oracleasm-2.0.5]# rpm -Uvh oracleasm-2.6.18-92.el5-2.0.5-1.el5.i686.rpm
Preparing...                ########################################### [100%]
   1:oracleasm-2.6.18-92.el5########################################### [100%]
[root@linux5 oracleasm-2.0.5]# rpm -Uvh oracleasmlib-2.0.3-1.el5.i386.rpm
Preparing...                ########################################### [100%]
   1:oracleasmlib           ########################################### [100%]

6. Configure the ASMLibrary

[root@linux5 oracleasm-2.0.5]# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver.

This will configure the on-boot properties of the Oracle ASM library
driver.  The following questions will determine whether the driver is
loaded on boot and what permissions it will have.  The current values
will be shown in brackets ('[]').  Hitting  without typing an
answer will keep that current value.  Ctrl-C will abort.

Default user to own the driver interface []: oracle
Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver:                     [  OK  ]
Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@linux5 oracleasm-2.0.5]# /etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
[root@linux5 oracleasm-2.0.5]# /etc/init.d/oracleasm listdisks

As shown above, our ASMLib stack has been successfully configured, but we have no disks that are “labeled” as ASMLib devices. We will configure that now.

We first show our current simplistic setup, which is four raw devices; two for our clusterware files (OCR and voting disk), and two in use by our ASM diskgroup.

[root@linux5 oracleasm-2.0.5]# ls -lrt /dev/raw
total 0
crw------- 1 oracle dba    162, 3 Jan 15 16:29 raw3
crw------- 1 oracle dba    162, 4 Jan 15 16:29 raw4
crw-r----- 1 root   oracle 162, 1 Jan 15 16:29 raw1
crw-r--r-- 1 oracle oracle 162, 2 Jan 15 16:29 raw2

We also show our configuration in ASM.

SQL> select name from v$asm_diskgroup;

NAME
------------------------------
ASM_LOCAL

SQL> select path from v$asm_disk;

PATH
--------------------------------------------------------------------------------
/dev/raw/raw3
/dev/raw/raw4

We can migrate our existing raw devices using one of two different methodologies.

• One is very fast, but requires minimal downtime (less than an hour)
• The other one is slower, but requires no downtime (provided you have some excess capacity in your diskgroup with which to “juggle”).

In this article, we will show the faster method with minimal downtime. However, briefly, using the method that requires additional disk space means you have to perform the following steps:

1. Label new unused disks as ASMLIB disks (see below)
2. Add these disks to the diskgroup
3. Let the rebalance operation complete
4. Delete the old non-asmlib disks from the diskgroup
5. Let the rebalance complete

Now, on to the method that allows you to convert existing disks to ASMLIB.

Begin by shutting down both all database instances using ASM and the ASM instance itself.

You will lose data if you don’t do this!!!

We then “unbind” our current raw device mappings.

linux5:oracle:+ASM:/home/oracle>raw /dev/raw/raw3 0 0
/dev/raw/raw3:  bound to major 0, minor 0
linux5:oracle:+ASM:/home/oracle>raw /dev/raw/raw4 0 0
/dev/raw/raw4:  bound to major 0, minor 0
linux5:oracle:orcl:/home/oracle>ls -lrt /dev/raw
total 0
crw-r----- 1 root   dba 162, 1 Jan 30 22:36 raw1
crw-r----- 1 oracle dba 162, 2 Jan 30 22:56 raw2
linux5:oracle:orcl:/home/oracle>

We then attempt to “rename” (insert an ASMLib “label” in the disk header). This fails, as it sees that the device already has ORCLDISK in the header of the device. As such, we use the force-renamedisk command (once again, ensure no databases are accessing the diskgroup prior to doing this!!!)

linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm renamedisk /dev/loop3 VOL1
WARNING: Changing the label of an disk marked for ASM is a very dangerous
         operation.  If this is really what you mean to do, you must
         ensure that all Oracle and ASM instances have ceased using
         this disk.  Otherwise, you may LOSE DATA.
If you really wish to change the label, rerun with the force-renamedisk command.
Renaming disk "/dev/loop3" to "VOL1":                      [FAILED]
linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm force-renamedisk /dev/loop3 VOL1
Renaming disk "/dev/loop3" to "VOL1":                      [  OK  ]

We once again scan for disks, and see that ASMLib now “recognizes” our device as eligible for use.

linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm listdisks
VOL1

We then proceed to do this with our other device current in use by a raw device mapping.

linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm force-renamedisk /dev/loop4 VOL2
Renaming disk "/dev/loop4" to "VOL2":                      [  OK  ]
linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks:               [  OK  ]
linux5:oracle:+ASM:/home/oracle>/etc/init.d/oracleasm listdisks
VOL1
VOL2

We then restart our ASM instance, and see that our “new” devices are in use.

SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1265912 bytes
Variable Size              57454344 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted
SQL> select path from v$asm_disk;

PATH
--------------------------------------------------------------------------------
ORCL:VOL1
ORCL:VOL2

We finally restart our database instance that is using ASM, and see that it does not “complain”.

SQL> startup
ORACLE instance started.

Total System Global Area  603979776 bytes
Fixed Size                  1268896 bytes
Variable Size             163578720 bytes
Database Buffers          436207616 bytes
Redo Buffers                2924544 bytes
Database mounted.
Database opened.

Our migration to ASMLib has been completed successfully!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.