Alfredo Krieg's DBA blog - Oracle ACE: Hands on practice ASM

Sunday, June 9, 2013

Hands on practice ASM

Today I want to share with you an ASM exercise which includes how to add an additional disk to our VM RAC nodes, prepare the disk, add the disk to ASM configuration and create a new diskgroup using this disk.

The very first step is to have our VM machines turned off. Then go into your VM host server's terminal and get into ASM shared disks location.


alfredo@alfredo-N56VM:~$ cd /u04

alfredo@alfredo-N56VM:/u04$ ls

VirtualBox

alfredo@alfredo-N56VM:/u04$ cd VirtualBox/

alfredo@alfredo-N56VM:/u04/VirtualBox$ ls

ol5-112-rac

alfredo@alfredo-N56VM:/u04/VirtualBox$ cd ol5-112-rac/

alfredo@alfredo-N56VM:/u04/VirtualBox/ol5-112-rac$ ls

asm1.vdi  asm2.vdi  asm3.vdi  asm4.vdi


Then create the new VM shared disk and assign it to your VM machines.


alfredo@alfredo-N56VM:/u04/VirtualBox/ol5-112-rac$ VBoxManage createhd --filename asm5.vdi --size 1024 --format VDI --variant Fixed

0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Disk image created. UUID: f317a4fb-d132-49fa-8572-76ca7a509e04

alfredo@alfredo-N56VM:/u04/VirtualBox/ol5-112-rac$ VBoxManage storageattach ol5-112-rac1 --storagectl "SATA" --port 5 --device 0 --type hdd --medium asm5.vdi --mtype shareable

alfredo@alfredo-N56VM:/u04/VirtualBox/ol5-112-rac$ VBoxManage modifyhd asm5.vdi --type shareable

alfredo@alfredo-N56VM:/u04/VirtualBox/ol5-112-rac$ VBoxManage storageattach ol5-112-rac2 --storagectl "SATA" --port 5 --device 0 --type hdd --medium asm5.vdi --mtype shareable

alfredo@alfredo-N56VM:/u04/VirtualBox/ol5-112-rac$ VBoxManage modifyhd asm5.vdi --type shareable


Now turn your on your node 1, open a terminal as root and format the disk.


[oracle@ol5-112-rac1 ~]$ su -
Password: 
[root@ol5-112-rac1 ~]# cd /dev
[root@ol5-112-rac1 dev]# ls sd*
sda  sda1  sda2  sdb  sdb1  sdc  sdc1  sdd  sdd1  sde  sde1  sdf  sdf1  sdg  sdg1  sdh
[root@ol5-112-rac1 dev]# fdisk /dev/sdh
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): 
Using default value 130

Command (m for help): p

Disk /dev/sdh: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1         130     1044193+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


Turn on the second VM node.
The next step is to add the newly partitioned disk to ASM.


[root@ol5-112-rac1 dev]# /usr/sbin/oracleasm listdisks
DISK1
DISK2
DISK3
DISK4
[root@ol5-112-rac1 dev]# /usr/sbin/oracleasm createdisk DISK5 /dev/sdh1
Writing disk header: done
Instantiating disk: done
[root@ol5-112-rac1 dev]# /usr/sbin/oracleasm listdisks
DISK1
DISK2
DISK3
DISK4
DISK5
[root@ol5-112-rac1 dev]# exit



At this point the new disk is already added to ASM configuration; let's login to ASM instance and confirm that new disk is present.


[oracle@ol5-112-rac2 ~]$ . oraenv
ORACLE_SID = [RAC2] ? +ASM2
The Oracle base for ORACLE_HOME=/u01/app/11.2.0/grid is /u01/app/oracle
[oracle@ol5-112-rac2 ~]$ crsctl status resource -t
--------------------------------------------------------------------------------
NAME           TARGET  STATE        SERVER                   STATE_DETAILS       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
               ONLINE  ONLINE       ol5-112-rac1                                 
               ONLINE  ONLINE       ol5-112-rac2                                 
ora.LISTENER.lsnr
               ONLINE  ONLINE       ol5-112-rac1                                 
               ONLINE  ONLINE       ol5-112-rac2                                 
ora.asm
               ONLINE  ONLINE       ol5-112-rac1                                 
               ONLINE  ONLINE       ol5-112-rac2             Started             
ora.eons
               ONLINE  ONLINE       ol5-112-rac1                                 
               ONLINE  ONLINE       ol5-112-rac2                                 
ora.gsd
               OFFLINE OFFLINE      ol5-112-rac1                                 
               OFFLINE OFFLINE      ol5-112-rac2                                 
ora.net1.network
               ONLINE  ONLINE       ol5-112-rac1                                 
               ONLINE  ONLINE       ol5-112-rac2                                 
ora.ons
               ONLINE  ONLINE       ol5-112-rac1                                 
               ONLINE  ONLINE       ol5-112-rac2                                 
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.LISTENER_SCAN1.lsnr
      1        ONLINE  ONLINE       ol5-112-rac1                                 
ora.oc4j
      1        OFFLINE OFFLINE                                                   
ora.ol5-112-rac1.vip
      1        ONLINE  ONLINE       ol5-112-rac1                                 
ora.ol5-112-rac2.vip
      1        ONLINE  ONLINE       ol5-112-rac2                                 
ora.rac.db
      1        ONLINE  ONLINE       ol5-112-rac2             Open                
      2        ONLINE  ONLINE       ol5-112-rac1                                 
ora.rac.reports.svc
      1        ONLINE  ONLINE       ol5-112-rac1                                 
ora.scan1.vip
      1        ONLINE  ONLINE       ol5-112-rac1                                 
[oracle@ol5-112-rac2 ~]$ sqlplus / as sysasm


SQL*Plus: Release 11.2.0.1.0 Production on Sun Jun 9 16:06:27 2013

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Real Application Clusters and Automatic Storage Management options

SQL> set lines 1000
SQL> column path format a50
SQL> SELECT PATH,NAME,GROUP_NUMBER,DISK_NUMBER,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB FROM V$ASM_DISK;

PATH                                               NAME                           GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE    REDUNDA      OS_MB   TOTAL_MB    FREE_MB
-------------------------------------------------- ------------------------------ ------------ ----------- ------- ------------ ------- -------- ------- ---------- ---------- ----------
/dev/oracleasm/disks/DISK5                                                                   0           0 CLOSED  PROVISIONED  ONLINE  NORMAL   UNKNOWN       1019          0          0
/dev/oracleasm/disks/DISK4                         DATA_0003                                 1           3 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4439
/dev/oracleasm/disks/DISK3                         DATA_0002                                 1           2 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4439
/dev/oracleasm/disks/DISK2                         DATA_0001                                 1           1 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4444
/dev/oracleasm/disks/DISK1                         DATA_0000                                 1           0 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4406



You can see the DISK5 present in the ASM system view, the HEADER_STATUS is 'PROVISIONED'. The PROVISIONED status implies that an additional platform-specific action has been taken by an administrator to make the disk available for ASM.

Now, let's drop DISK4 from DATA diskgroup, this will free DISK4 for our new configuration.


SQL> select * from V$ASM_DISKGROUP;

GROUP_NUMBER NAME                           SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE       TYPE     TOTAL_MB    FREE_MB HOT_USED_MB COLD_USED_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB OFFLINE_DISKS COMPATIBILITY            DATABASE_COMPATIBILITY                                        V
------------ ------------------------------ ----------- ---------- -------------------- ----------- ------ ---------- ---------- ----------- ------------ ----------------------- -------------- ------------- ------------------------------------------------------------ ------------------------------------------------------------ -
           1 DATA                                   512       4096 1048576 MOUNTED     EXTERN      20456      17728           0         2728 0          17728             0 11.2.0.0.0               10.1.0.0.0 N



SQL> ALTER DISKGROUP DATA DROP DISK DATA_0003;

Diskgroup altered.

SQL> SELECT PATH,NAME,GROUP_NUMBER,DISK_NUMBER,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB FROM V$ASM_DISK;

PATH                                               NAME                           GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE    REDUNDA      OS_MB   TOTAL_MB    FREE_MB
-------------------------------------------------- ------------------------------ ------------ ----------- ------- ------------ ------- -------- ------- ---------- ---------- ----------
/dev/oracleasm/disks/DISK5                                                                   0           0 CLOSED  PROVISIONED  ONLINE  NORMAL   UNKNOWN       1019          0          0
/dev/oracleasm/disks/DISK4                         DATA_0003                                 1           3 CACHED  MEMBER       ONLINE  DROPPING UNKNOWN       5114       5114       4546
/dev/oracleasm/disks/DISK3                         DATA_0002                                 1           2 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4404
/dev/oracleasm/disks/DISK2                         DATA_0001                                 1           1 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4409
/dev/oracleasm/disks/DISK1                         DATA_0000 1           0 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114 5114       4369


You can see the STATE of DISK4 is DROPPING, in this stage ASM will rebalance all the data from DISK4 into the disk of diskgroup DATA. In order to speed this operation we are going to modify the rebalance power of the diskgroup.


SQL> ALTER DISKGROUP DATA REBALANCE POWER 5;

Diskgroup altered.

SQL> SELECT PATH,NAME,GROUP_NUMBER,DISK_NUMBER,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB FROM V$ASM_DISK;


PATH                                               NAME                           GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE    REDUNDA      OS_MB   TOTAL_MB    FREE_MB
-------------------------------------------------- ------------------------------ ------------ ----------- ------- ------------ ------- -------- ------- ---------- ---------- ----------
/dev/oracleasm/disks/DISK5                                                                   0           0 CLOSED  PROVISIONED  ONLINE  NORMAL   UNKNOWN       1019          0          0
/dev/oracleasm/disks/DISK4                                                                   0           1 CLOSED  FORMER       ONLINE  NORMAL   UNKNOWN       5114          0          0
/dev/oracleasm/disks/DISK3                         DATA_0002                                 1           2 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4213
/dev/oracleasm/disks/DISK2                         DATA_0001                                 1           1 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4218
/dev/oracleasm/disks/DISK1                         DATA_0000                                 1           0 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4185

SQL> show parameter power

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_power_limit                      integer     1
SQL> ALTER DISKGROUP DATA REBALANCE POWER 1;

Diskgroup altered.


After modifying the rebalance power to 5 ASM will provide more resources to the rebalance process, this results in faster rebalance times. You can see that DISK4's header status is now 'FORMER' this means a disk was once part of a disk group but has been dropped cleanly from the group. It may be added to a new disk group with the ALTER DISKGROUP statement.

Be sure to modify back the power of the disk group DATA to 1.

Now let's create a new disk group named FRA using DISK4 & DISK5.


SQL> CREATE DISKGROUP FRA EXTERNAL REDUNDANCY DISK '/dev/oracleasm/disks/DISK4' NAME FRA_0000, '/dev/oracleasm/disks/DISK5' NAME FRA_0001;

Diskgroup created.

SQL> SELECT PATH,NAME,GROUP_NUMBER,DISK_NUMBER,MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,REDUNDANCY,OS_MB,TOTAL_MB,FREE_MB FROM V$ASM_DISK;

PATH                                               NAME                           GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU MODE_ST STATE    REDUNDA      OS_MB   TOTAL_MB    FREE_MB
-------------------------------------------------- ------------------------------ ------------ ----------- ------- ------------ ------- -------- ------- ---------- ---------- ----------
/dev/oracleasm/disks/DISK4                         FRA_0000                                  2           0 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       5072
/dev/oracleasm/disks/DISK3                         DATA_0002                                 1           2 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4215
/dev/oracleasm/disks/DISK2                         DATA_0001                                 1           1 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4218
/dev/oracleasm/disks/DISK1                         DATA_0000                                 1           0 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       5114       5114       4183
/dev/oracleasm/disks/DISK5                         FRA_0001                                  2           1 CACHED  MEMBER       ONLINE  NORMAL   UNKNOWN       1019       1019       1009

SQL> select * from V$ASM_DISKGROUP;

GROUP_NUMBER NAME                           SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE       TYPE     TOTAL_MB    FREE_MB HOT_USED_MB COLD_USED_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB OFFLINE_DISKS COMPATIBILITY            DATABASE_COMPATIBILITY                                        V
------------ ------------------------------ ----------- ---------- -------------------- ----------- ------ ---------- ---------- ----------- ------------ ----------------------- -------------- ------------- ------------------------------------------------------------ ------------------------------------------------------------ -
           1 DATA                                   512       4096              1048576 MOUNTED     EXTERN      15342      12616           0         2726                       0          12616             0 11.2.0.0.0               10.1.0.0.0                                                    N
           2 FRA                                    512       4096              1048576 MOUNTED     EXTERN       6133       6081           0           52                       0           6081             0 10.1.0.0.0               10.1.0.0.0                                                    N

SQL> 

ALTER DISKGROUP FRA SET ATTRIBUTE 'compatible.asm'='11.2.0.0.0';

SQL> ALTER DISKGROUP FRA SET ATTRIBUTE 'compatible.asm'='11.2.0.0.0';

Diskgroup altered.

SQL> select * from V$ASM_DISKGROUP;

GROUP_NUMBER NAME                           SECTOR_SIZE BLOCK_SIZE ALLOCATION_UNIT_SIZE STATE       TYPE     TOTAL_MB    FREE_MB HOT_USED_MB COLD_USED_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB OFFLINE_DISKS COMPATIBILITY            DATABASE_COMPATIBILITY                                        V
------------ ------------------------------ ----------- ---------- -------------------- ----------- ------ ---------- ---------- ----------- ------------ ----------------------- -------------- ------------- ------------------------------------------------------------ ------------------------------------------------------------ -
           1 DATA                                   512       4096              1048576 MOUNTED     EXTERN      15342      12616           0         2726                       0          12616             0 11.2.0.0.0               10.1.0.0.0                                                    N
           2 FRA                                    512       4096              1048576 MOUNTED     EXTERN       6133       6079           0           54                       0           6079             0 11.2.0.0.0               10.1.0.0.0                                                    N

SQL> 



FRA disk group is ready to host our flash recovery area for archivelogs and backups.

This is a small but useful example of the ASM functionality.

Thanks,
Alfredo





Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home