{"id":190,"date":"2009-06-07T11:33:16","date_gmt":"2009-06-07T16:33:16","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=190"},"modified":"2012-03-27T12:48:36","modified_gmt":"2012-03-27T17:48:36","slug":"migrating-from-raw-devices-to-asmlib","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2009\/06\/07\/migrating-from-raw-devices-to-asmlib\/","title":{"rendered":"Migrating from raw devices to ASMLIB"},"content":{"rendered":"<p>Oracle\u2019s 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\u2019s task list the need to decide on which disks to place which datafiles.<br \/>\nIt 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.<br \/>\nThe disks provided are the subject of this document.<br \/>\nASM 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).<br \/>\nSince 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.<br \/>\n1.\tGet your kernel version<br \/>\n2.\tNavigate your browser to http:\/\/www.oracle.com\/technology\/tech\/linux\/asmlib\/index.html and select your platform from downloads section of the page<br \/>\n3.\tDownload the \u201cLibrary and Tools\u201d rpm\u2019s, and then the kernel driver for your kernel obtained above.<br \/>\n4.\tCopy these to your database host.<br \/>\n5.\tInstall them<\/p>\n<pre lang=\"text\">\r\n[root@linux5 oracleasm-2.0.5]# rpm -Uvh oracleasm-support-2.1.2-1.el5.i386.rpm\r\nPreparing...                ########################################### [100%]\r\n   1:oracleasm-support      ########################################### [100%]\r\n [root@linux5 oracleasm-2.0.5]# rpm -Uvh oracleasm-2.6.18-92.el5-2.0.5-1.el5.i686.rpm\r\nPreparing...                ########################################### [100%]\r\n   1:oracleasm-2.6.18-92.el5########################################### [100%]\r\n[root@linux5 oracleasm-2.0.5]# rpm -Uvh oracleasmlib-2.0.3-1.el5.i386.rpm\r\nPreparing...                ########################################### [100%]\r\n   1:oracleasmlib           ########################################### [100%]\r\n<\/pre>\n<p>6.\tConfigure the ASMLibrary<\/p>\n<pre lang=\"text\">\r\n[root@linux5 oracleasm-2.0.5]# \/etc\/init.d\/oracleasm configure\r\nConfiguring the Oracle ASM library driver.\r\n\r\nThis will configure the on-boot properties of the Oracle ASM library\r\ndriver.  The following questions will determine whether the driver is\r\nloaded on boot and what permissions it will have.  The current values\r\nwill be shown in brackets ('[]').  Hitting <ENTER> without typing an\r\nanswer will keep that current value.  Ctrl-C will abort.\r\n\r\nDefault user to own the driver interface []: oracle\r\nDefault group to own the driver interface []: dba\r\nStart Oracle ASM library driver on boot (y\/n) [n]: y\r\nScan for Oracle ASM disks on boot (y\/n) [y]: y\r\nWriting Oracle ASM library driver configuration: done\r\nInitializing the Oracle ASMLib driver:                     [  OK  ]\r\nScanning the system for Oracle ASMLib disks:               [  OK  ]\r\n[root@linux5 oracleasm-2.0.5]# \/etc\/init.d\/oracleasm scandisks\r\nScanning the system for Oracle ASMLib disks:               [  OK  ]\r\n[root@linux5 oracleasm-2.0.5]# \/etc\/init.d\/oracleasm listdisks\r\n<\/pre>\n<p>As shown above, our ASMLib stack has been successfully configured, but we have no disks that are \u201clabeled\u201d as ASMLib devices.  We will configure that now.<\/p>\n<p>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.<\/p>\n<pre lang=\"text\">\r\n[root@linux5 oracleasm-2.0.5]# ls -lrt \/dev\/raw\r\ntotal 0\r\ncrw------- 1 oracle dba    162, 3 Jan 15 16:29 raw3\r\ncrw------- 1 oracle dba    162, 4 Jan 15 16:29 raw4\r\ncrw-r----- 1 root   oracle 162, 1 Jan 15 16:29 raw1\r\ncrw-r--r-- 1 oracle oracle 162, 2 Jan 15 16:29 raw2\r\n<\/pre>\n<p>We also show our configuration in ASM.<\/p>\n<pre lang=\"text\">\r\nSQL> select name from v$asm_diskgroup;\r\n\r\nNAME\r\n------------------------------\r\nASM_LOCAL\r\n\r\nSQL> select path from v$asm_disk;\r\n\r\nPATH\r\n--------------------------------------------------------------------------------\r\n\/dev\/raw\/raw3\r\n\/dev\/raw\/raw4\r\n<\/pre>\n<p>We can migrate our existing raw devices using one of two different methodologies.  <\/p>\n<p>\u2022\tOne is very fast, but requires minimal downtime (less than an hour)<br \/>\n\u2022\tThe other one is slower, but requires no downtime (provided you have some excess capacity in your diskgroup with which to \u201cjuggle\u201d).<\/p>\n<p>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:<\/p>\n<p>1.  Label new unused disks as ASMLIB disks (see below)<br \/>\n2.  Add these disks to the diskgroup<br \/>\n3.  Let the rebalance operation complete<br \/>\n4.  Delete the old non-asmlib disks from the diskgroup<br \/>\n5.  Let the rebalance complete<\/p>\n<p>Now, on to the method that allows you to convert existing disks to ASMLIB.<\/p>\n<p>Begin by shutting down both all database instances using ASM and the ASM instance itself.  <\/p>\n<p>You will lose data if you don\u2019t do this!!!<\/p>\n<p>We then \u201cunbind\u201d our current raw device mappings.<\/p>\n<pre lang=\"text\">\r\nlinux5:oracle:+ASM:\/home\/oracle>raw \/dev\/raw\/raw3 0 0\r\n\/dev\/raw\/raw3:  bound to major 0, minor 0\r\nlinux5:oracle:+ASM:\/home\/oracle>raw \/dev\/raw\/raw4 0 0\r\n\/dev\/raw\/raw4:  bound to major 0, minor 0\r\nlinux5:oracle:orcl:\/home\/oracle>ls -lrt \/dev\/raw\r\ntotal 0\r\ncrw-r----- 1 root   dba 162, 1 Jan 30 22:36 raw1\r\ncrw-r----- 1 oracle dba 162, 2 Jan 30 22:56 raw2\r\nlinux5:oracle:orcl:\/home\/oracle>\r\n<\/pre>\n<p>We then attempt to \u201crename\u201d (insert an ASMLib \u201clabel\u201d 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!!!)<\/p>\n<pre lang=\"text\">\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm renamedisk \/dev\/loop3 VOL1\r\nWARNING: Changing the label of an disk marked for ASM is a very dangerous\r\n         operation.  If this is really what you mean to do, you must\r\n         ensure that all Oracle and ASM instances have ceased using\r\n         this disk.  Otherwise, you may LOSE DATA.\r\nIf you really wish to change the label, rerun with the force-renamedisk command.\r\nRenaming disk \"\/dev\/loop3\" to \"VOL1\":                      [FAILED]\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm force-renamedisk \/dev\/loop3 VOL1\r\nRenaming disk \"\/dev\/loop3\" to \"VOL1\":                      [  OK  ]\r\n<\/pre>\n<p>We once again scan for disks, and see that ASMLib now \u201crecognizes\u201d our device as eligible for use.<\/p>\n<pre lang=\"text\">\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm scandisks\r\nScanning the system for Oracle ASMLib disks:               [  OK  ]\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm listdisks\r\nVOL1\r\n<\/pre>\n<p>We then proceed to do this with our other device current in use by a raw device mapping.<\/p>\n<pre lang=\"text\">\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm force-renamedisk \/dev\/loop4 VOL2\r\nRenaming disk \"\/dev\/loop4\" to \"VOL2\":                      [  OK  ]\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm scandisks\r\nScanning the system for Oracle ASMLib disks:               [  OK  ]\r\nlinux5:oracle:+ASM:\/home\/oracle>\/etc\/init.d\/oracleasm listdisks\r\nVOL1\r\nVOL2\r\n<\/pre>\n<p>We then restart our ASM instance, and see that our \u201cnew\u201d devices are in use.<\/p>\n<pre lang=\"text\">\r\nSQL> startup\r\nASM instance started\r\n\r\nTotal System Global Area   83886080 bytes\r\nFixed Size                  1265912 bytes\r\nVariable Size              57454344 bytes\r\nASM Cache                  25165824 bytes\r\nASM diskgroups mounted\r\nSQL> select path from v$asm_disk;\r\n\r\nPATH\r\n--------------------------------------------------------------------------------\r\nORCL:VOL1\r\nORCL:VOL2\r\n<\/pre>\n<p>We finally restart our database instance that is using ASM, and see that it does not \u201ccomplain\u201d.<\/p>\n<pre lang=\"text\">\r\nSQL> startup\r\nORACLE instance started.\r\n\r\nTotal System Global Area  603979776 bytes\r\nFixed Size                  1268896 bytes\r\nVariable Size             163578720 bytes\r\nDatabase Buffers          436207616 bytes\r\nRedo Buffers                2924544 bytes\r\nDatabase mounted.\r\nDatabase opened.\r\n<\/pre>\n<p>Our migration to ASMLib has been completed successfully!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oracle\u2019s 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\u2019s task list the need to decide on which disks to place which datafiles. It is&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2009\/06\/07\/migrating-from-raw-devices-to-asmlib\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,22],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/190"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":14,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":2065,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/190\/revisions\/2065"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}