>進入 2、檢測還原狀態shell腳本 [python] --我們用一個shell腳本來檢測多個DB當天最終的還原狀態成功與否,并將當前的所有記錄輸出到ck_restore.log日志 --腳本尾部發送郵件列出當天所有進行resto" />
歡迎進入Oracle社區論壇,與200萬技術人員互動交流 >>進入 2、檢測還原狀態shell腳本 [python] --我們用一個shell腳本來檢測多個DB當天最終的還原狀態成功與否,并將當前的所有記錄輸出到ck_restore.log日志 --腳本尾部發送郵件列出當天所有進行restore之后
歡迎進入Oracle社區論壇,與200萬技術人員互動交流 >>進入
2、檢測還原狀態shell腳本
[python]
--我們用一個shell腳本來檢測多個DB當天最終的還原狀態成功與否,并將當前的所有記錄輸出到ck_restore.log日志
--腳本尾部發送郵件列出當天所有進行restore之后的所有狀態,是一個多個DB restore 的summary report.
$ more ck_restore.sh
##====================================================================
## File name: ck_restore.sh
## Usage: ck_restore.sh
## Desc:
## The script uses to check RMAN restore log for current day
## and send mail to DBA
##====================================================================
#!/bin/bash
if [ -f ~/.bash_profile ];
then
. ~/.bash_profile
fi
REV_DIR=/u01/comm_scripts
dt=`date '+%F'`
cat /dev/null >${REV_DIR}/ck_restore.log
cat ${REV_DIR}/db_restore_rman.log | grep "${dt}" 》${REV_DIR}/ck_restore.log
total=`cat ${REV_DIR}/ck_restore.log |wc -l`
suc=`grep SUCCEED ${REV_DIR}/ck_restore.log |wc -l`
fail=`grep FAILED ${REV_DIR}/ck_restore.log |wc -l`
echo ""》ck_restore.log
echo -e "The total DB of current recovery is $total in `hostname` \n"》${REV_DIR}/ck_restore.log
echo -e "The number of succee is : ${suc} \n"》${REV_DIR}/ck_restore.log
echo -e "The number of fail is : ${fail} \n"》${REV_DIR}/ck_restore.log
mail -s "RMAN restore summary for `hostname` at `date +'%a %b %d %Y'`" dba@12306.com <${REV_DIR}/ck_restore.log
3、部署還原shell腳本到crontab
[python]
--首先將多個需要自動restore的DB封裝到一個單獨的文件,如下:
--最后調用ck_restore.sh 腳步檢測所有DB restore狀態并發送RMAN summary report郵件
$ more full_resotre_by_rman.sh
#!/bin/bash
/u01/comm_scripts/db_restore_rman_catalog.sh BC1200
/u01/comm_scripts/db_restore_rman_catalog.sh AF2630
/u01/comm_scripts/ck_restore.sh
--部署到crontab
--注,無論是備份還是恢復腳本,我們都是通過Bak server的crontab來部署以減輕Prod的壓力
#Rman restore database
0 3 * * 1-6 /u01/comm_scripts/full_resotre_by_rman.sh
[1] [2]
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com