Friday, January 30, 2015

Adding/Dropping a disk in an ASM Disk Group


Adding/Dropping a disk in an ASM Disk Group
One of the big selling points of ASM is the ability to reconfigure the storage online.
This is basically achievable because ASM distributes data across all disks in a disk group evenly, and assuming you have enough space, you can happily drop disks in a disk group and ASM will seamlessly migrate the data to the existing disks in the disk group.
Check Existing Space/Disks.

SQL> select sum(total_mb)/1024,sum(free_mb)/1024
  2  from V$ASM_DISK;

SUM(TOTAL_MB)/1024 SUM(FREE_MB)/1024
------------------ -----------------
59.042968755        37.560546875

Now Add New Two Disks to existing Disk Group. I have added two Disks of 5GB size.
SQL>  alter diskgroup  data add disk
  2  '/dev/oracleasm/disks/DISK5',
  3   '/dev/oracleasm/disks/DISK6';

Now again Check Space/Disks
SQL> select sum(total_mb)/1024,sum(free_mb)/1024
  2  from V$ASM_DISK;

SUM(TOTAL_MB)/1024 SUM(FREE_MB)/1024
------------------ -----------------
          69.03125        47.5429688
So, we see here that DATA_0005 and DATA_0006 are two disks (luns) in disk group 1.I have enough space so safely i can delete newly added disks.
alter diskgroup data drop disk DATA_0005; 
Diskgroup altered.
alter diskgroup data drop disk DATA_0006; 
Diskgroup altered.
This alter diskgroup command essentially shuffles extents from the disk you are removing and distributes them to the remaining disks in your disk group. While the operation is continuing you can check V$ASM_OPERATION for the progress you are making:

SQL> select * from v$asm_operation;
GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE  EST_MINUTES
------------ ----- ---- ----- ----- ------ -------  ---------- ----------
    4 REBAL RUN     1  1   100   42234       1007     41
Most of the columns here are self explanatory, however the SOFAR column tells you the number of Allocation Units (au) that have been moved, the EST_WORK and EST_RATE are also in au and au/minute.
Once the rebalance has moved all the Allocation Units the disk is removed from the disk group:

SQL>  select group_number, name, TOTAL_MB, FREE_MB
from V$asm_disk_stat;

GROUP_NUMBER NAME                             TOTAL_MB    FREE_MB
------------ ------------------------------ ---------- ----------
           1 DATA_0003                           15115      10498
           1 DATA_0002                           15115      10468
           1 DATA_0001                           15115      10467
           1 DATA_0000                           15115      10468
           1 DATA_0005                            5114       3392
           1 DATA_0004                            5114       3391

Dropping a disk in a disk group seemed to work as advertised, the real benefit of course, is instead of it being just a disk you were dropping but that it was a lun representing a whole storage array, then this has real potential for allowing you to upgrade storage or even migrate to a different storage platform entirely.

No comments:

Post a Comment