Saturday, February 2, 2008

Oracle ASM Management Overview

Oracle ASM Management Overview

This is to give a brief overview of managing ASM disk groups by providing some information on viewing the disk groups, listing files and directories in a disk group, create, rename and remove directories in a disk group as well as add and remove disks from the disk group.


List Disk Groups defined in ASM instance:

SQL> select name from v$asm_diskgroup ;

NAME
--------------------------------------------------------------------------------
P1CSM2_ASM_DG1

SQL>



List Directories in an ASM disk group:

-------------------------------------------------
-- script: see_asm_directories.sql
-- author: Michael Messina
-------------------------------------------------
set pagesize 0
set head off
set linesize 80
column diskgroup format a20
column name format a50
break on diskgroup NODUPLICATES

select adg.name '/' as diskgroup, LPAD(' ', 2*(level-1)) a.name as name
from v$asm_alias a,
v$asm_diskgroup adg
where adg.group_number = a.group_number
and a.alias_directory = 'Y'
start with parent_index = (select min(parent_index) from v$asm_alias)
connect by prior a.reference_index = a.parent_index ;

set pagesize 30
set head on
clear breaks


SQL> @see_asm_directories
P1CSM2_ASM_DG1/ CSP1
DATAFILE
CSP2
DATAFILE
CSP3

SQL>


List Files and their directories in ASM Disk Group:

-----------------------------------------------------------------------
-- script: see_asm_file_structure.sql
-- author: Michael Messina
-- date: 12/17/2007
--
-- Description: Lists Structure and Files of ASM Disk Groups
--
-- Instructions: Run from ASM Instance
-----------------------------------------------------------------------
set pagesize 0
set head off
set linesize 80
column diskgroup format a20
column name format a50
break on diskgroup NODUPLICATES

select adg.name '/' as diskgroup, LPAD(' ', 2*(level-1)) a.name as name
from v$asm_alias a,
v$asm_diskgroup adg
where adg.group_number = a.group_number
start with parent_index = (select min(parent_index) from v$asm_alias)
connect by prior reference_index = parent_index ;

clear breaks
set pagesize 30


SQL> @see_asm_file_structure
P1CSM2_ASM_DG1/ CSP1
DATAFILE
UNDOTBS1.257.1
UNDOTBS1.261.1
UNDOTBS1.265.1
UNDOTBS1.284.628437133
USERS.275.628437153
WCRSYS_TS.335.628461993
UDDISYS_TS.281.628462009
CSP2
DATAFILE
IC_METRIC.304.641245055
IC_SYSTEM.305.641245059
CONTENT_IFS_CTX_X.306.641245065
CONTENT_IFS_CTX_K.307.641245071
CONTENT_IFS_CTX_I.308.641245075
CONTENT_IFS_LOB_M.309.641245079
CONTENT_IFS_LOB_I.310.641245085
CONTENT_IFS_LOB_N.311.641245095
CONTENT_IFS_MAIN.318.641245105
CWSYS_MAIN_TBS.319.641245111
OVFMETRICSTBL.320.641245115
UMTBL.321.641245121
ESTERSTORE.322.641245125
ESSMLTBL.270.641245129
ESPERFTBL.323.641245133
ESORATEXT.317.641245139
ESNEWS.326.641245143
ESMRLMNR.329.641245147
ESINFREQIDX.330.641245151
ESFREQTBL.268.641245157
ESFREQIDX.328.641245161
ESBIGTBL.269.641245165
RTC_IM_INDEX.325.641245169
RTC_IM_DATA.327.641245177
RTC_REPORT_INDEX.315.641245187
RTC_REPORT_DATA.314.641245191
RTC_TRANSIENT_LOB_INDEX.324.641245195
RTC_TRANSIENT_LOB_DATA.272.641245201
RTC_TRANSIENT_INDEX.312.641245205
RTC_TRANSIENT_DATA.313.641245209
RTC_RECORDING_INDEX.316.641245215
RTC_RECORDING_DATA.331.641245219
RTC_DOCUMENT_INDEX.333.641245227
RTC_DOCUMENT_DATA.334.641245231
RTC_ARCHIVE_INDEX.271.641245235
RTC_ARCHIVE_DATA.273.641245241
RTC_TRANSACTION_INDEX.336.641245247
RTC_TRANSACTION_DATA.337.641245251
RTC_LOOKUP_INDEX.338.641245257
RTC_LOOKUP_DATA.339.641245261
OLTS_SVRMGSTORE.340.641245267
OLTS_DEFAULT.341.641245271
OLTS_CT_STORE.342.641245275
OLTS_BATTRSTORE.343.641245279
OLTS_ATTRSTORE.344.641245285
UDDISYS_TS.345.641245289
OCATS.346.641245293
BAM.347.641245297
ORABPEL.348.641245307
B2B_LOB.349.641245315
B2B_IDX.350.641245319
B2B_DT.351.641245323
B2B_RT.352.641245327
WCRSYS_TS.353.641245333
DSGATEWAY_TAB.354.641245339
DCM.355.641245343
DISCO_PTM5_CACHE.356.641245353
DISCO_PTM5_META.357.641245359
IAS_META.358.641245363
PORTAL_LOG.359.641245373
PORTAL_IDX.360.641245377
PORTAL_DOC.361.641245381
PORTAL.362.641245387
USERS.363.641245393
SYSAUX.364.641245397
UNDOTBS1.365.641245403
SYSTEM.366.641245411

78 rows selected.



Create a Directory in an ASM Disk Group from list of available ASM Disk Groups:

SQL> alter diskgroup P1CSM2_ASM_DG1 add directory '+P1CSM2_ASM_DG1/CSP3' ;

Diskgroup altered.

SQL> @see_asm_directories
P1CSM2_ASM_DG1/ CSP1
DATAFILE
CSP2
DATAFILE
CSP3


Rename a Directory in an ASM Disk Group from list of available ASM Disk Groups to another name:

SQL> alter diskgroup P1CSM2_ASM_DG1 rename directory '+P1CSM2_ASM_DG1/CSP3' TO '+P1CSM2_ASM_DG1/CSP4' ;

Diskgroup altered.

SQL> @see_asm_directories
P1CSM2_ASM_DG1/ CSP1
DATAFILE
CSP2
DATAFILE
CSP4


Remove/Drop file from ASM Disk Group using the fully qualified file name from see_asm_file_structure.sql script output:

SQL> alter diskgroup P1CSM2_ASM_DG1 drop file '+P1CSM2_ASM_DG1/CSP1/DATAFILE/UNDOTBS1.257.1';

Diskgroup altered.

SQL>



Remove/Drop a directory and all its contents from an ASM Disk Group using the fully qualified directory from see_asm_directories.sql script output:

SQL> alter diskgroup P1CSM2_ASM_DG1 drop directory '+P1CSM2_ASM_DG1/CSP4' FORCE;

Diskgroup altered.

SQL> @see_asm_directories
P1CSM2_ASM_DG1/ CSP1
DATAFILE
CSP2
DATAFILE

** Note can not remove a directory and its contents if created by default.

SQL> alter diskgroup P1CSM2_ASM_DG1 drop directory '+P1CSM2_ASM_DG1/CSP1' FORCE;
alter diskgroup P1CSM2_ASM_DG1 drop directory '+P1CSM2_ASM_DG1/CSP1' FORCE
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15177: cannot operate on system aliases



Add New Disk to Disk Group

SQL> ALTER DISKGROUP P1CSM2_ASM_DG1 ADD DISK '/dev/rrawlv01' NAME P1CSM2_ASM_DG1_0010 NOFORCE ; Diskgroup altered.



Remove a disk from an ASM disk group

SQL> ALTER DISKGROUP P1CSM2_ASM_DG1 DROP DISK P1CSM2_ASM_DG1_0000 ;Diskgroup altered.

No comments: