script of check repair ASM DISKGROUP

tengrid發表於2009-11-20

用於check repair DISKGROUP用

[@more@]

#!/bin/sh

export ORACLE_BASE=/oracle/app
export ORA_ASM_HOME=${ORACLE_BASE}/11gR1/db
export ORACLE_SID=+ASM24


function repair_dg(){
sqlstr="alter diskgroup $2 check DISK "
x=`expr $1 * 8`
i=`expr $x - 8`
if [ $1 -eq 9 ];then
j=70
else
j=`expr $x - 1`
fi

while ((i<=j))
do
if [ $i -eq $j ];then
flag=`printf '%04d' $i`
sqlstr1=$sqlstr" DATA_"$flag
((i=i+1))
continue
fi
flag=`printf '%04d' $i`
sqlstr=$sqlstr" $2_"$flag","
((i=i+1))
done

echo $sqlstr1" repair;" >/tmp/repair_dg_$1.sql

$ORA_ASM_HOME/bin/sqlplus -S "/ as sysdba" <select 'begin: '||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
SELECT SYS_CONTEXT ('userenv', 'sid') from dual;
;
select 'end: '||to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
exit
EOD
}


repair_dg 1 DATA &
repair_dg 2 DATA &
repair_dg 3 DATA &
repair_dg 4 DATA &
repair_dg 5 DATA &
repair_dg 6 DATA &
repair_dg 7 DATA &
repair_dg 8 DATA &
repair_dg 9 DATA &

解釋一下:
1,data這個diskgroup下有71個disk (DATA_0000--DATA_0070)
2,要求用9個併發同時執行check repair操作,
alter diskgroup check disk repair會做哪些事,在asm guide/sql reference中有說明
3,指令碼設定成前面8個指令碼每個檢查8個disk,最後一個檢查7個,共計8*8+7=71個
4,注意必須連asm instance才能執行
5,被check的dg必須mount

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/94384/viewspace-1028911/,如需轉載,請註明出處,否則將追究法律責任。

相關文章