Monday, February 13, 2012

ASM Move ASM Disk from one disk group to another, when using ASMlib rename the ASM Disk

1. determine the disk group asm disk that you want to move, this SQL will provide a list of the ASM diskgroups and their associated disks, ensure that you use the size values to determine that if you remove a disk from the disk group that you have enough free space to do so.

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
order by dg.name, d.name ;


2. Select the disk to remove, in this case we will select RECO3 to remove from the RECO Disk Group.

set head off
set linesize 100

set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
   and dg.name = 'RECO'
order by dg.name, d.name ;

RECO RECO1 RECO1 EXTERN
ORCL:RECO1
NORMAL 24999 24999 15606

RECO RECO2 RECO2 EXTERN
ORCL:RECO2
NORMAL 24999 24999 15605


RECO RECO3 RECO3 EXTERN
ORCL:RECO3
NORMAL 24999 24999 15607


3. Remove the ASM disk from the disk group

SQL> alter diskgroup RECO drop disk RECO3 ;

Diskgroup altered.


4. monitor the disk group rebal operation that removes the disk until complete.

SQL> select * from v$asm_operation;

GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- -----------
ERROR_CODE
--------------------------------------------
3 REBAL RUN 1 1 570 10189 903 10

1 row selected.


SQL> select * from v$asm_operation;

no rows selected


5. ensure the disk is no longer part of the diskgroup

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
and dg.name = 'RECO'
order by dg.name, d.name ;

NAME NAME LABEL TYPE
------------------------------ ------------------------------ ------------------------------- ------
PATH
----------------------------------------------------------------------------------------------------
STATE OS_MB TOTAL_MB FREE_MB
-------- ---------- ---------- ----------
RECO RECO1 RECO1 EXTERN
ORCL:RECO1
NORMAL 24999 24999 10912

RECO RECO2 RECO2 EXTERN
ORCL:RECO2
NORMAL 24999 24999 10909


6. To rename the ASM disk removed to match the disk names of the disk group you are putting the disk into
in this example we are taking the disk from RECO (disk RECO3) and putting into the DATA disk group, some may want to rename the ASM disk from RECO03 to DATA5 to match the new diskgroup
** DATA4 Name is already used as an ASM disk name, but not and ASM lib disk name.

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
and dg.name = 'DATA'
order by dg.name, d.name ;


NAME NAME LABEL TYPE
------------------------------ ------------------------------ ------------------------------- ------
PATH
----------------------------------------------------------------------------------------------------
STATE OS_MB TOTAL_MB FREE_MB
-------- ---------- ---------- ----------
DATA DATA1 DATA1 EXTERN
ORCL:DATA1
NORMAL 24999 24999 8192


DATA DATA2 DATA2 EXTERN
ORCL:DATA2
NORMAL 24999 24999 8193

DATA DATA3 DATA3 EXTERN
ORCL:DATA3
NORMAL 24999 24999 8195

DATA DATA4 STAGEASMDATA4 EXTERN
ORCL:STAGEASMDATA4
NORMAL 24995 24995 8192


7. Ensure the name we want to use is not used in an ASM Name already.

set linesize 100
set pagesize 1000
column disk_group_name format a20
column disk_file_path format a30
column disk_file_name format a20
column disk_file_fail_group format a20
SELECT
NVL(a.name, '[CANDIDATE]') disk_group_name
, b.path disk_file_path
, b.name disk_file_name
, b.failgroup disk_file_fail_group
FROM
v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
ORDER BY
a.name;

DISK_GROUP_NAME DISK_FILE_PATH     DISK_FILE_NAME FILE_FAIL_GROUP
--------------- ------------------ -------------- ---------------DATA            ORCL:STAGEASMDATA4 DATA4          DATA4
DATA            ORCL:DATA1         DATA1          DATA1
DATA            ORCL:DATA2         DATA2          DATA2
DATA            ORCL:DATA3         DATA3          DATA3
OCR_VOTE        ORCL:OCR_VOTE01    OCR_VOTE01     OCR_VOTE01
OCR_VOTE        ORCL:OCR_VOTE03    OCR_VOTE03     OCR_VOTE03
OCR_VOTE        ORCL:OCR_VOTE02    OCR_VOTE02     OCR_VOTE02
RECO            ORCL:RECO2         RECO2          RECO2
RECO            ORCL:RECO1         RECO1          RECO1

** As we see here the ASMlib name and DISKFILE NAME do not match, this will cause as disk name issue so we have to give our new disk a different name to avoid a duplicate name in the ASM instance.
In our case we will use DATA5 as it is not used already.


8. When using ASM lib you can rename the disk using ASM lib best to do as root, when using OS level, check the OS level name and change it there for most operating systems there is no change need unless the device name changes. When using the OS check the device name which would be the disk path as they can be name when using multi path so use the configuration there to rename.

[root]# /etc/init.d/oracleasm querydisk -p RECO3
Disk "RECO3" is a valid ASM disk
/dev/sdk1: LABEL="RECO3" TYPE="oracleasm"

[root]# /etc/init.d/oracleasm force-renamedisk RECO3 DATA5
Renaming disk "RECO3" to "DATA5": [ OK ]


9. list the disks if using ASMlib, to ensure the disk is renamed.

[root]# /etc/init.d/oracleasm listdisks
DATA1
DATA2
DATA3
DATA5
OCR_VOTE01
OCR_VOTE02
OCR_VOTE03
RECO1
RECO2
STAGEASMDATA4


10. Ensure disk is a candidate disk now to be added to a diskgroup.

set linesize 100
set pagesize 1000
column disk_group_name format a20
column disk_file_path format a30
column disk_file_name format a20
column disk_file_fail_group format a20
SELECT
NVL(a.name, '[CANDIDATE]') disk_group_name
, b.path disk_file_path
, b.name disk_file_name
, b.failgroup disk_file_fail_group
FROM
v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
ORDER BY
a.name;

DISK_GROUP_NAME DISK_FILE_PATH DISK_FILE_NAME FILE_FAIL_GROUP
--------------- ------------------ -------------- ---------------
DATA ORCL:STAGEASMDATA4 DATA4 DATA4
DATA ORCL:DATA1 DATA1 DATA1
DATA ORCL:DATA2 DATA2 DATA2
DATA ORCL:DATA3 DATA3 DATA3
OCR_VOTE ORCL:OCR_VOTE01 OCR_VOTE01 OCR_VOTE01
OCR_VOTE ORCL:OCR_VOTE03 OCR_VOTE03 OCR_VOTE03
OCR_VOTE ORCL:OCR_VOTE02 OCR_VOTE02 OCR_VOTE02
RECO ORCL:RECO2 RECO2 RECO2
RECO ORCL:RECO1 RECO1 RECO1
[CANDIDATE] ORCL:DATA5


9. Add disk to disk to group, in our case disk DATA4 to diskgroup DATA

SQL> alter diskgroup DATA add disk 'ORCL:DATA5' ;

Diskgroup altered.


10. Monitor Rebal operation that is bringing in the new disk


SQL> select * from v$asm_operation;

GROUP_NUMBER OPERA STAT POWER ACTUAL SOFAR EST_WORK EST_RATE EST_MINUTES
------------ ----- ---- ---------- ---------- ---------- ---------- ---------- -----------
ERROR_CODE
--------------------------------------------
1 REBAL RUN 1 1 682 13467 987 12

SQL> select * from v$asm_operation;

no rows selected


11. Ensure the disk is now part of the diskgroup

set linesize 100
set pagesize 1000
select dg.name, d.name, d.label, dg.type, d.path, d.state, d.OS_MB, d.TOTAL_MB, d.FREE_MB
from v$asm_disk d, v$asm_diskgroup dg
where dg.group_number = d.group_number
and dg.name = 'DATA'
order by dg.name, d.name ;

NAME NAME LABEL TYPE
------------------------------ ------------------------------ ------------------------------- ------
PATH
----------------------------------------------------------------------------------------------------
STATE OS_MB TOTAL_MB FREE_MB
-------- ---------- ---------- ----------
DATA DATA1 DATA1 EXTERN
ORCL:DATA1
NORMAL 24999 24999 11525

DATA DATA2 DATA2 EXTERN
ORCL:DATA2
NORMAL 24999 24999 11525

DATA DATA3 DATA3 EXTERN
ORCL:DATA3
NORMAL 24999 24999 11525

DATA DATA4 STAGEASMDATA4 EXTERN
ORCL:STAGEASMDATA4
NORMAL 25995 25995 11985

DATA DATA5 DATA5 EXTERN
ORCL:DATA5
NORMAL 24999 24999 11527