Nagios 被動檢測oracle Rman備份情況
Nagios 被動檢測oracle Rman備份情況
nagios監控伺服器ip:192.168.9.172
被監控伺服器ip:192.168.9.133
資料庫例項名:orcl
需要開通被監控伺服器到nagios監控伺服器的nsca埠:5667
被監控伺服器:
1. 準備Rman指令碼rman_orcl.rcv
crosscheck archivelog all;
crosscheck backup;
crosscheck copy;
delete noprompt obsolete;
delete noprompt expired archivelog all;
delete noprompt expired backup;
delete noprompt expired copy;
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup as compressed backupset database format '/backup/rman/orcl_full_%U'
plus archivelog skip inaccessible format '/backup/rman/orcl_ARC_%U';
delete noprompt archivelog all completed before 'sysdate-1';
backup current controlfile format '/backup/rman/grp1_control_bak_%T';
backup spfile format '/backup/rman/grp1_spfile_bak_%T';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
2.編輯backup_db的shell指令碼backup_db.sh
SIDNAME=orcl
source /home/oracle/prof_orcl
cd /backup/rman
#find /backup/rmanbak/ -name $SIDNAME"_"* -exec rm -rf {} \;
rm /backup/rmanbak/orcl_*
mv /backup/rman/$SIDNAME"_"* /backup/rmanbak/
logName=$SIDNAME"_rman"_`date +'%Y%m%d%H%M%S'`_full.log
cd /backup/rman
rman target / CMDFILE rman_$SIDNAME.rcv >> $logName
##################################
sh check_backup.sh
##################################
3.檢查備份情況日誌backup_status.log(自動生成)(備份成功)
192.168.9.133 Rman_Backup_GRP1 0 Backup Suess!
4.編輯檢查備份情況指令碼check_backup.sh
IP=192.168.9.133
SID=orcl
status=`sqlplus -silent "/as sysdba" <
set feedback off
set verify off
set heading off
set echo off
set pagesize 0
SELECT /*+ rule */ DECODE (
TRUNC (SYSDATE - start_time),
0, DECODE (
status,
'COMPLETED', '0',
'COMPLETED WITH WARNINGS','1',
'2'),
'2')
backup_status
FROM v\\$rman_backup_job_details
WHERE start_time = (SELECT MAX (start_time) FROM v\\$rman_backup_job_details);
exit;
eof`
output=`sqlplus -silent "/as sysdba" <
set feedback off
set verify off
set heading off
set echo off
set pagesize 0
SELECT /*+ rule */ DECODE (
TRUNC (SYSDATE - start_time),
0, DECODE (status,
'COMPLETED', 'Backup Suess!',
'COMPLETED WITH WARNINGS', 'Backup With Warnings!',
'Backup Failed!'),
'No Backup!')
backup_status
FROM v\\$rman_backup_job_details
WHERE start_time = (SELECT MAX (start_time) FROM v\\$rman_backup_job_details);
exit;
eof`
hostip=$IP
checkname="Rman_Backup_"$SID
#把rman備份資訊寫到目錄中去
echo -e "$hostip\t$checkname\t$status\t$output" > backup_status.log
#透過nsca方式把backup_status.log的內容傳到監控伺服器192.168.9.172
/usr/local/nagios/bin/send_nsca 192.168.9.172 -c /usr/local/nagios/etc/send_nsca.cfg < backup_status.log
5.編輯定期執行指令碼crontab
[oracle@orcl ~]$ crontab -l
0 22 * * * cd /backup/rman ; sh backup.sh
[oracle@orcl ~]$ cd /backup/rman
[oracle@orcl rman]$ ll
total 520688
-rw-r--r-- 1 oracle oinstall 389 Jul 28 09:44 backup.sh
-rw-r--r-- 1 oracle oinstall 50 Nov 10 09:20 backup_status.log
-rw-r--r-- 1 oracle oinstall 1428 Oct 15 16:18 check_backup.sh
-rw-r----- 1 oracle oinstall 61839872 Nov 9 21:00 orcl_ARC_dapn7432_1_1
-rw-r----- 1 oracle oinstall 1165312 Nov 9 21:01 orcl_ARC_dkpn7458_1_1
-rw-r----- 1 oracle oinstall 17596416 Nov 9 21:01 orcl_control_bak_20141109
-rw-r----- 1 oracle oinstall 197828608 Nov 9 21:01 orcl_full_dbpn743i_1_1
-rw-r----- 1 oracle oinstall 133578752 Nov 9 21:01 orcl_full_dcpn743i_1_1
-rw-r----- 1 oracle oinstall 113934336 Nov 9 21:01 orcl_full_ddpn743i_1_1
-rw-r----- 1 oracle oinstall 1196032 Nov 9 21:00 orcl_full_depn743i_1_1
-rw-r----- 1 oracle oinstall 1368064 Nov 9 21:00 orcl_full_dfpn743i_1_1
-rw-r----- 1 oracle oinstall 1515520 Nov 9 21:00 orcl_full_dgpn743j_1_1
-rw-r----- 1 oracle oinstall 1073152 Nov 9 21:00 orcl_full_dhpn743j_1_1
-rw-r----- 1 oracle oinstall 1277952 Nov 9 21:00 orcl_full_dipn743j_1_1
-rw-r----- 1 oracle oinstall 98304 Nov 9 21:00 orcl_full_djpn743q_1_1
-rw-r--r-- 1 oracle oinstall 13624 Nov 9 21:01 orcl_rman_20141109210001_full.log
-rw-r----- 1 oracle oinstall 98304 Nov 9 21:01 orcl_spfile_bak_20141109
-rw-r--r-- 1 oracle oinstall 954 Jul 22 09:47 rman_orcl.rcv
[oracle@amcxypjdbvm1 rman]$
nagios監控伺服器:
1. 會透過被動式check_dummy來檢測
[root@sznagios libexec]# ./check_dummy 0
OK
[root@sznagios libexec]# ./check_dummy 1
WARNING
[root@sznagios libexec]# ./check_dummy 2
CRITICAL
[root@sznagios libexec]# ./check_dummy 3
UNKNOWN
nagios監控伺服器ip:192.168.9.172
被監控伺服器ip:192.168.9.133
資料庫例項名:orcl
需要開通被監控伺服器到nagios監控伺服器的nsca埠:5667
被監控伺服器:
1. 準備Rman指令碼rman_orcl.rcv
crosscheck archivelog all;
crosscheck backup;
crosscheck copy;
delete noprompt obsolete;
delete noprompt expired archivelog all;
delete noprompt expired backup;
delete noprompt expired copy;
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup as compressed backupset database format '/backup/rman/orcl_full_%U'
plus archivelog skip inaccessible format '/backup/rman/orcl_ARC_%U';
delete noprompt archivelog all completed before 'sysdate-1';
backup current controlfile format '/backup/rman/grp1_control_bak_%T';
backup spfile format '/backup/rman/grp1_spfile_bak_%T';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
2.編輯backup_db的shell指令碼backup_db.sh
SIDNAME=orcl
source /home/oracle/prof_orcl
cd /backup/rman
#find /backup/rmanbak/ -name $SIDNAME"_"* -exec rm -rf {} \;
rm /backup/rmanbak/orcl_*
mv /backup/rman/$SIDNAME"_"* /backup/rmanbak/
logName=$SIDNAME"_rman"_`date +'%Y%m%d%H%M%S'`_full.log
cd /backup/rman
rman target / CMDFILE rman_$SIDNAME.rcv >> $logName
##################################
sh check_backup.sh
##################################
3.檢查備份情況日誌backup_status.log(自動生成)(備份成功)
192.168.9.133 Rman_Backup_GRP1 0 Backup Suess!
4.編輯檢查備份情況指令碼check_backup.sh
IP=192.168.9.133
SID=orcl
status=`sqlplus -silent "/as sysdba" <
set verify off
set heading off
set echo off
set pagesize 0
SELECT /*+ rule */ DECODE (
TRUNC (SYSDATE - start_time),
0, DECODE (
status,
'COMPLETED', '0',
'COMPLETED WITH WARNINGS','1',
'2'),
'2')
backup_status
FROM v\\$rman_backup_job_details
WHERE start_time = (SELECT MAX (start_time) FROM v\\$rman_backup_job_details);
exit;
eof`
output=`sqlplus -silent "/as sysdba" <
set verify off
set heading off
set echo off
set pagesize 0
SELECT /*+ rule */ DECODE (
TRUNC (SYSDATE - start_time),
0, DECODE (status,
'COMPLETED', 'Backup Suess!',
'COMPLETED WITH WARNINGS', 'Backup With Warnings!',
'Backup Failed!'),
'No Backup!')
backup_status
FROM v\\$rman_backup_job_details
WHERE start_time = (SELECT MAX (start_time) FROM v\\$rman_backup_job_details);
exit;
eof`
hostip=$IP
checkname="Rman_Backup_"$SID
#把rman備份資訊寫到目錄中去
echo -e "$hostip\t$checkname\t$status\t$output" > backup_status.log
#透過nsca方式把backup_status.log的內容傳到監控伺服器192.168.9.172
/usr/local/nagios/bin/send_nsca 192.168.9.172 -c /usr/local/nagios/etc/send_nsca.cfg < backup_status.log
5.編輯定期執行指令碼crontab
[oracle@orcl ~]$ crontab -l
0 22 * * * cd /backup/rman ; sh backup.sh
[oracle@orcl ~]$ cd /backup/rman
[oracle@orcl rman]$ ll
total 520688
-rw-r--r-- 1 oracle oinstall 389 Jul 28 09:44 backup.sh
-rw-r--r-- 1 oracle oinstall 50 Nov 10 09:20 backup_status.log
-rw-r--r-- 1 oracle oinstall 1428 Oct 15 16:18 check_backup.sh
-rw-r----- 1 oracle oinstall 61839872 Nov 9 21:00 orcl_ARC_dapn7432_1_1
-rw-r----- 1 oracle oinstall 1165312 Nov 9 21:01 orcl_ARC_dkpn7458_1_1
-rw-r----- 1 oracle oinstall 17596416 Nov 9 21:01 orcl_control_bak_20141109
-rw-r----- 1 oracle oinstall 197828608 Nov 9 21:01 orcl_full_dbpn743i_1_1
-rw-r----- 1 oracle oinstall 133578752 Nov 9 21:01 orcl_full_dcpn743i_1_1
-rw-r----- 1 oracle oinstall 113934336 Nov 9 21:01 orcl_full_ddpn743i_1_1
-rw-r----- 1 oracle oinstall 1196032 Nov 9 21:00 orcl_full_depn743i_1_1
-rw-r----- 1 oracle oinstall 1368064 Nov 9 21:00 orcl_full_dfpn743i_1_1
-rw-r----- 1 oracle oinstall 1515520 Nov 9 21:00 orcl_full_dgpn743j_1_1
-rw-r----- 1 oracle oinstall 1073152 Nov 9 21:00 orcl_full_dhpn743j_1_1
-rw-r----- 1 oracle oinstall 1277952 Nov 9 21:00 orcl_full_dipn743j_1_1
-rw-r----- 1 oracle oinstall 98304 Nov 9 21:00 orcl_full_djpn743q_1_1
-rw-r--r-- 1 oracle oinstall 13624 Nov 9 21:01 orcl_rman_20141109210001_full.log
-rw-r----- 1 oracle oinstall 98304 Nov 9 21:01 orcl_spfile_bak_20141109
-rw-r--r-- 1 oracle oinstall 954 Jul 22 09:47 rman_orcl.rcv
[oracle@amcxypjdbvm1 rman]$
nagios監控伺服器:
1. 會透過被動式check_dummy來檢測
[root@sznagios libexec]# ./check_dummy 0
OK
[root@sznagios libexec]# ./check_dummy 1
WARNING
[root@sznagios libexec]# ./check_dummy 2
CRITICAL
[root@sznagios libexec]# ./check_dummy 3
UNKNOWN
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1327157/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 檢查備份情況的指令碼指令碼
- Oracle RMAN備份實戰Oracle
- Oracle OCP(60):RMAN 備份Oracle
- oracle 12c rman備份pdbOracle
- 分享Oracle Rman的備份指令碼Oracle指令碼
- Oracle-無備份情況下,如何手動恢復控制檔案Oracle
- Oracle 備份恢復篇之RMAN catalogOracle
- 揭秘ORACLE備份之----RMAN之五(CATALOG)Oracle
- ORACLE DG從庫 Rman備份恢復Oracle
- Oracle RMAN備份以及壓縮原理分析Oracle
- oracle10g RMAN增量備份策略Oracle
- RMAN備份與恢復測試
- 【RMAN】RMAN備份至ASMASM
- Oracle 無備份情況下undo檔案損壞處理Oracle
- oracle資料庫使用rman備份指令碼Oracle資料庫指令碼
- Oracle ADG環境下的RMAN備份策略Oracle
- RMAN自動備份任務新增
- RMAN備份概述
- 【RMAN】RMAN的備份保留策略
- 【RMAN】Oracle12c以後rman 備份恢復命令參考Oracle
- Oracle Rman Catalog的建立方法和備份原理Oracle
- ORACLE NBU調取oracle rman指令碼備份歸檔不自動刪除歸檔Oracle指令碼
- RMAN備份恢復典型案例——RMAN備份&系統變慢
- RMAN備份進度
- rman 備份指令碼指令碼
- RMAN的備份原理
- Oracle 12.2中的索引統計被呼叫情況Oracle索引
- Oracle9i RMAN 的優缺點及RMAN 備份及恢復步驟Oracle
- rman 增量備份恢復
- RMAN備份恢復技巧
- 【rman備份策略】實驗
- 【RMAN】Oracle12c之後,rman備份Dataguard備端恢復可能出現邏輯錯誤Oracle
- 【RMAN】Oracle中如何備份控制檔案?備份控制檔案的方式有哪幾種?Oracle
- Oracle RMAN備份為什麼會大量使用temp表空間?Oracle
- Windows oracle 11g rman備份恢復到linux系統WindowsOracleLinux
- 【RMAN】同時建立多個備份(建立多重備份)
- 【RMAN】在備庫執行rman備份時報錯RMAN-06820 ORA-17629
- RMAN備份詳解(轉載)
- [20190522]rman備份問題.txt