The document contains SQL commands for managing Oracle ASM (Automatic Storage Management) disk groups, including creating, altering, and querying disk groups and disks. It includes commands for creating disk groups with different redundancy levels, adding and dropping disks, and retrieving information about disk usage and status. Additionally, it provides prompts for displaying various ASM-related statistics and operations.
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
5 views
ASM
The document contains SQL commands for managing Oracle ASM (Automatic Storage Management) disk groups, including creating, altering, and querying disk groups and disks. It includes commands for creating disk groups with different redundancy levels, adding and dropping disks, and retrieving information about disk usage and status. Additionally, it provides prompts for displaying various ASM-related statistics and operations.
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4
cat asm.
txt
--DISK group creation
--CREATE DISKGROUP E007DE1 EXTERNAL REDUNDANCY DISK '/dev/sdc7';
--create diskgroup N007N1 normal redundancy
failgroup fg1 disk '/dev/sdc9' name sdc9, '/dev/sdc10' name sdc10 failgroup fg2 disk '/dev/sdc11' name sdc11, '/dev/sdc12' name sdc12;
--create diskgroup H007H1 high redundancy
failgroup fg1 disk '/dev/sdc13' name sdc13, '/dev/sdc14' name sdc14 failgroup fg2 disk '/dev/sdc15' name sdc15, '/dev/sdc16' name sdc16 failgroup fg3 disk '/dev/sdc17' name sdc17, '/dev/sdc18' name sdc18;
---Adding disk to the diskgroup
--alter diskgroup N007N1 add failgroup fg1 disk '/dev/sdc19' name sdc19 failgroup fg2 disk '/dev/sdc20' name sdc20;
--drop disk from the disk group
--alter diskgroup N007N1 drop disk sdc19,sdc20;
--disk group information
set lines 300 select group_number,name,total_mb/1024 TOTAL_GB,(total_mb-free_mb)/1024 USED_GB, free_mb/1024 FREE_GB,round(free_mb/total_mb*100,2) FREE_PERCENT from v$asm_diskg roup;
--get disk information
select GROUP_NUMBER,name,HEADER_STATUS,OS_MB/1024,path,REDUNDANCY,FAILGROUP from v$asm_disk order by HEADER_STATUS; select GROUP_NUMBER,name,HEADER_STATUS,OS_MB/1024,path,REDUNDANCY,FAILGROUP from v$asm_disk where GROUP_NUMBER=3 order by FAILGROUP;
--candidate disk information
set lines 300 set pages 300 col path for a40 select path,OS_MB/1024 from v$asm_disk where HEADER_STATUS in ('FORMER','CANDIDA TE','PROVISIONED') order by 1;
--Not member disk info
select path,os_mb/1024,header_Status from v$asm_Disk where header_Status!='MEMBE R'; --re balance operation set lines 300 select * from v$asm_operation;
--connected DB information col INSTANCE_NAME form a20 col SOFTWARE_VERSION form a20 col COMPATIBLE_VERSION form a20 select * from v$asm_client;
---Dis mount disk
alter diskgroup DATA10 dismount; select name,state from v$asm_diskgroup;
set wrap off set lines 155 pages 9999 col "Group Name" for a6 Head "Group|Name" col "Disk Name" for a10 col "State" for a10 col "Type" for a10 Head "Diskgroup|Redundancy" col "Total GB" for 9,990 Head "Total|GB" col "Free GB" for 9,990 Head "Free|GB" col "Imbalance" for 99.9 Head "Percent|Imbalance" col "Variance" for 99.9 Head "Percent|Disk Size|Variance" col "MinFree" for 99.9 Head "Minimum|Percent|Free" col "MaxFree" for 99.9 Head "Maximum|Percent|Free" col "DiskCnt" for 9999 Head "Disk|Count"
prompt prompt ASM Disk Groups prompt ===============
SELECT g.group_number "Group"
, g.name "Group Name" , g.state "State" , g.type "Type" , g.total_mb/1024 "Total GB" , g.free_mb/1024 "Free GB" , 100*(max((d.total_mb-d.free_mb)/d.total_mb)-min((d.total_mb-d.free_mb)/d. total_mb))/max((d.total_mb-d.free_mb)/d.total_mb) "Imbalance" , 100*(max(d.total_mb)-min(d.total_mb))/max(d.total_mb) "Variance" , 100*(min(d.free_mb/d.total_mb)) "MinFree" , 100*(max(d.free_mb/d.total_mb)) "MaxFree" , count(*) "DiskCnt" FROM v$asm_disk d, v$asm_diskgroup g WHERE d.group_number = g.group_number and d.group_number <> 0 and d.state = 'NORMAL' and d.mount_status = 'CACHED' GROUP BY g.group_number, g.name, g.state, g.type, g.total_mb, g.free_mb ORDER BY 1;
prompt ASM Disks In Use
prompt ================
col "Group" for 999
col "Disk" for 999 col "Header" for a9 col "Mode" for a8 col "State" for a8 col "Created" for a10 Head "Added To|Diskgroup" --col "Redundancy" for a10 --col "Failure Group" for a10 Head "Failure|Group" col "Path" for a19 --col "ReadTime" for 999999990 Head "Read Time|seconds" --col "WriteTime" for 999999990 Head "Write Time|seconds" --col "BytesRead" for 999990.00 Head "GigaBytes|Read" --col "BytesWrite" for 999990.00 Head "GigaBytes|Written" col "SecsPerRead" for 9.000 Head "Seconds|PerRead" col "SecsPerWrite" for 9.000 Head "Seconds|PerWrite"
select group_number "Group"
, disk_number "Disk" , header_status "Header" , mode_status "Mode" , state "State" , create_date "Created" --, redundancy "Redundancy" , total_mb/1024 "Total GB" , free_mb/1024 "Free GB" , name "Disk Name" --, failgroup "Failure Group" , path "Path" --, read_time "ReadTime" --, write_time "WriteTime" --, bytes_read/1073741824 "BytesRead" --, bytes_written/1073741824 "BytesWrite" , read_time/reads "SecsPerRead" , write_time/writes "SecsPerWrite" from v$asm_disk_stat where header_status not in ('FORMER','CANDIDATE') order by group_number , disk_number /
Prompt File Types in Diskgroups
Prompt ======================== col "File Type" for a16 col "Block Size" for a5 Head "Block|Size" col "Gb" for 9990.00 col "Files" for 99990 break on "Group Name" skip 1 nodup
select g.name "Group Name"
, f.TYPE "File Type" , f.BLOCK_SIZE/1024||'k' "Block Size" , f.STRIPED , count(*) "Files" , round(sum(f.BYTES)/(1024*1024*1024),2) "Gb" from v$asm_file f,v$asm_diskgroup g where f.group_number=g.group_number group by g.name,f.TYPE,f.BLOCK_SIZE,f.STRIPED order by 1,2; clear break
prompt Instances currently accessing these diskgroups
prompt ============================================== col "Instance" form a8 select c.group_number "Group" , g.name "Group Name" , c.instance_name "Instance" from v$asm_client c , v$asm_diskgroup g where g.group_number=c.group_number /
prompt Free ASM disks and their paths
prompt ============================== col "Disk Size" form a9 select header_status "Header" , mode_status "Mode" , path "Path" , lpad(round(os_mb/1024),7)||'Gb' "Disk Size" from v$asm_disk where header_status in ('FORMER','CANDIDATE') order by path /
prompt Current ASM disk operations
prompt =========================== select * from v$asm_operation /