Tuesday, November 6, 2012

Administration - ASM


Administration - ASM

To Start GUI to manage ASM instance
$ asmca

Starting and Stopping ASM Instances by Using srvctl

One node at a time:
$ srvctl start asm -n host01
$ srvctl start asm -n host02
$ srvctl status asm -n host01
$ srvctl status asm -n host02


All nodes simultaneously:

$ srvctl stop asm
$ srvctl status asm -n host01
$ srvctl status asm

Starting and Stopping ASM Instances by Using SQL*Plus

$ export ORACLE_SID=+ASM1
$ export ORACLE_HOME=/u01/app/11.2.0/grid
$ $ORACLE_HOME/bin/sqlplus / AS SYSASM

SQL> startup
ASM instance started

Total System Global Area  284565504 bytes
Fixed Size                  1312896 bytes
Variable Size             258086784 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted

Starting and Stopping ASM Instances Containing Cluster Files

crsctl stop crs 






Display disk-groups
set lines 100
col name format a10
col path         format a30
select   name
,        group_number
,        disk_number
,        mount_status
,        state
,        path
from     v$asm_disk
order    by group_number
/




Show disk space usage
select  name
,       group_number
,       disk_number
,       total_mb
,       free_mb
from    v$asm_disk
order   by group_number
/

Create a disk group
create diskgroup data1
external redundancy
disk '/dev/raw/raw1'
/

or with multiple raw partitions...

multiple disks
create diskgroup data2
external redundancy
disk     '/dev/raw/raw2'
,        '/dev/raw/raw3'
/

or with multiple fail groups...

create diskgroup data3
normal redundancy
failgroup controller1 disk '/dev/raw/raw4'
failgroup controller2 disk '/dev/raw/raw6'
/

Add a disk to a group
alter diskgroup data1
add disk '/dev/raw/raw4'
/

Drop a disk group
drop diskgroup '<name>'
/

Is ASM performing a balancing operation
select *
from v$asm_operation
/

Mount/dismount disk groups

alter diskgroup all mount
/

alter diskgroup data1 mount
/

alter diskgroup all dismount
/

alter diskgroup data1 dismount
/

Check the internal consistency of a diskgroup
alter diskgroup data1 check all
/

Show ASM Disk Usage
#!/usr/bin/ksh
#
# Title :       asmuse.ksh
# Description : Show ASM disk usage.
# Usage :       Configure the ASM SID & ASM Oracle Home before running.
#
#
 
export ORACLE_SID=<Enter ASM SID here>
export ORACLE_HOME=<Enter full path to ASM Oracle Home here>
export PATH=${PATH}:${ORACLE_HOME}/bin
export LD_LIBRARY_PATH=${ORACLE_HOME}/lib
export LC_ALL=en_GB
 
echo
echo
echo "  ASM Disk     % Full     Used (MB)       Free (MB)        Total (MB) "
echo "======================================================================"
 
asmcmd lsdg | \
 nawk -v sq="'" 'BEGIN { getline } {
        printf"  %s     \t %d%% \t %9"sq"d \t %9"sq"d \t %12"sq"d \n",$13,100-100*($9/$8),$8-$9,$9,$8
   }'
 
echo
echo
 
--------------------------------------------------------------------------------

Monitor space used in ASM Disk Groups

SET LINESIZE  145
SET PAGESIZE  9999
SET VERIFY    off
COLUMN group_name             FORMAT a20           HEAD 'Disk Group|Name'
COLUMN sector_size            FORMAT 99,999        HEAD 'Sector|Size'
COLUMN block_size             FORMAT 99,999        HEAD 'Block|Size'
COLUMN allocation_unit_size   FORMAT 999,999,999   HEAD 'Allocation|Unit Size'
COLUMN state                  FORMAT a11           HEAD 'State'
COLUMN type                   FORMAT a6            HEAD 'Type'
COLUMN total_mb               FORMAT 999,999,999   HEAD 'Total Size (MB)'
COLUMN used_mb                FORMAT 999,999,999   HEAD 'Used Size (MB)'
COLUMN pct_used               FORMAT 999.99        HEAD 'Pct. Used'
 
 
 
break on report on disk_group_name skip 1
compute sum label "Grand Total: " of total_mb used_mb on report
 
 
SELECT
    name                                     group_name
  , sector_size                              sector_size
  , block_size                               block_size
  , allocation_unit_size                     allocation_unit_size
  , state                                    state
  , type                                     type
  , total_mb                                 total_mb
  , (total_mb - free_mb)                     used_mb
  , ROUND((1- (free_mb / total_mb))*100, 2)  pct_used
FROM
    v$asm_diskgroup
ORDER BY
    name
/


No comments:

Post a Comment