使用RMAN備份時應如何處置歸檔記錄檔
昨天去某客戶部署RMAN備份,在跑shell指令碼的時候,提示找不到歸檔日誌,因為客戶那裡之前只對資料庫做EXPDP邏輯匯出備份,並且每天都自動刪除前一天的歸檔,每個歸檔的產生量大概在200M左右,因為考慮磁碟空間比較緊張,不得已而為之。
在我的指令碼中,是採用backup database format 'xxx' plus archivelog format 'xxx'的方式進行備份的,在執行RMAN指令碼時,由於是先對歸檔日誌進行備份,再對資料庫進行備份的,在指令碼的輸出日誌中,提示找不到35xxx的歸檔日誌,而現在最舊的還物理存在的歸檔日誌已經到36xxx了,也就是說,這1000多個日誌其實是已經被OS指令碼從物理上刪除了,後來檢驗了一下確實如此,每天產生的歸檔數量大約為40個左右,那麼一天的歸檔日誌就是800M左右 於是進入RMAN對歸檔日誌進行crosscheck,發現有7000多個歸檔日誌檢查結果是“failed”的(物理上已被刪除),命令如下:RMAN> crosscheck archivelog all; 再對這些expired的歸檔,從控制檔案資訊刪除掉RMAN> delete noprompt expired archivelog all; 然後再繼續跑指令碼,之後的備份就很順利,先把歸檔記錄備份完畢,接著是備份資料庫,最後是控制檔案和spfile
--------------------------------------推薦閱讀 --------------------------------------
RMAN 配置歸檔日誌刪除策略
Oracle基礎教程之通過RMAN複製資料庫
RMAN備份策略制定參考內容
RMAN備份學習筆記
OracleDatabase Backup加密 RMAN加密
--------------------------------------分割線 --------------------------------------
回來之後,我自己又做了一個測試,發現即便是當歸檔記錄檔未failted的時候,備份還是順利地進行下去了,下面看我自己的測試: 1. 先把歸檔日誌移動到別的目錄(類比日誌被物理刪除)[oracle@ora10g ~]$ cd $ORACLE_BASE/flash_recovery_area/ORA10G/archivelog[oracle@ora10g archivelog]$ lltotal 8drwxr-x--- 2 oracle oinstall 4096 Sep 24 11:46 2014_09_24
[oracle@ora10g archivelog]$ mv 2014_09_24/* .[oracle@ora10g archivelog]$ lltotal 6636drwxr-x--- 2 oracle oinstall 4096 Sep 24 11:59 2014_09_24
-rw-r----- 1 oracle oinstall 597504 Sep 24 11:46 o1_mf_1_10_b24ho39f_.arc-rw-r----- 1 oracle oinstall 5473792 Sep 24 11:35 o1_mf_1_3_b24gz52r_.arc-rw-r----- 1 oracle oinstall 373248 Sep 24 11:35 o1_mf_1_4_b24gz81d_.arc-rw-r----- 1 oracle oinstall 180224 Sep 24 11:35 o1_mf_1_5_b24gzbb6_.arc-rw-r----- 1 oracle oinstall 33792 Sep 24 11:35 o1_mf_1_6_b24gzd6y_.arc-rw-r----- 1 oracle oinstall 26624 Sep 24 11:35 o1_mf_1_7_b24gzky8_.arc-rw-r----- 1 oracle oinstall 1536 Sep 24 11:35 o1_mf_1_8_b24gzqnt_.arc-rw-r----- 1 oracle oinstall 57344 Sep 24 11:44 o1_mf_1_9_b24hjflc_.arc 這裡共有8個歸檔記錄檔被“刪除” 2. 進入RMAN,對歸檔日誌進行交叉校正[oracle@ora10g archivelog]$ exitexithost command complete RMAN> crosscheck archivelog all; released channel: ORA_DISK_1allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=145 devtype=DISKvalidation failed for archived log
archive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_3_b24gz52r_.arc recid=208 stamp=859116904validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_4_b24gz81d_.arc recid=209 stamp=859116904validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_5_b24gzbb6_.arc recid=210 stamp=859116906validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_6_b24gzd6y_.arc recid=211 stamp=859116908validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_7_b24gzky8_.arc recid=212 stamp=859116914validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_8_b24gzqnt_.arc recid=213 stamp=859116919validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_9_b24hjflc_.arc recid=214 stamp=859117453validation failed for archived logarchive log filename=/u01/app/oracle/flash_recovery_area/ORA10G/archivelog/2014_09_24/o1_mf_1_10_b24ho39f_.arc recid=215 stamp=859117603Crosschecked 8 objects 3. 不刪除expired的歸檔,直接跑RMAN備份指令碼這次並沒有報錯並提示xxx歸檔找不到,而是直接就完成了備份,產生了備份組297,與在客戶那裡碰到的情況有出入
--備份完成後,查看產生的備份組
[oracle@ora10g ~]$ cd /u01/orabackup/backupsets/[oracle@ora10g backupsets]$ ll -lrthtotal 1.6G......其他備份組(略)-rw-r----- 1 oracle oinstall 606K Sep 24 12:00 ora10g-4175411955_20140924_859118422_297.arc-rw-r----- 1 oracle oinstall 166M Sep 24 12:02 ora10g-4175411955_20140924_859118425_298.db-rw-r----- 1 oracle oinstall 610K Sep 24 12:02 ora10g-4175411955_20140924_859118562_299.arc-rw-r----- 1 oracle oinstall 7.3M Sep 24 12:02 ora10g-c-4175411955-20140924-01.ctl 可以看到,備份全部完成了,共產生了2個歸檔記錄備份集(arc),1個Database Backup集(db)以及控制檔案備份集(ctl),這裡有個細節要注意,由於我在指令碼中寫入了%s參數,從上面產生備份組產生的時間以及順序可以發現RMAN備份這樣一個順序:1. 對現有可以備份的資料庫歸檔記錄檔做一個備份2. 對資料庫進行備份3. 切換一下日誌,對完成全庫備份後的歸檔日誌再做一個備份(即使你沒有通過RMAN> sql "alter system archive log current";來手動切)4. 對控制檔案備份(包括spfile,產生在同一個備份組) 我們可以看一下詳細的日誌輸出,來對這個順序有更深刻的瞭解:Starting backup at 24-914current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting compressed archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=11 recid=216 stamp=859118422channel ORA_DISK_1: starting piece 1 at 24-914channel ORA_DISK_1: finished piece 1 at 24-914piece handle=/u01/orabackup/backupsets/ora10g-4175411955_20140924_859118422_297.arc tag=ARC_BAK comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:03Finished backup at 24-914 Starting backup at 24-914using channel ORA_DISK_1channel ORA_DISK_1: starting compressed full datafile backupsetchannel ORA_DISK_1: specifying datafile(s) in backupsetinput datafile fno=00001 name=/u01/app/oracle/oradata/ora10g/system01.dbfinput datafile fno=00003 name=/u01/app/oracle/oradata/ora10g/sysaux01.dbfinput datafile fno=00002 name=/u01/app/oracle/oradata/ora10g/undotbs01.dbfinput datafile fno=00005 name=/u01/app/oracle/oradata/ora10g/example01.dbfinput datafile fno=00006 name=/u01/app/oracle/oradata/ora10g/zlm01.dbfinput datafile fno=00004 name=/u01/app/oracle/oradata/ora10g/users01.dbfchannel ORA_DISK_1: starting piece 1 at 24-914channel ORA_DISK_1: finished piece 1 at 24-914piece handle=/u01/orabackup/backupsets/ora10g-4175411955_20140924_859118425_298.db tag=DB_BAK comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:02:16Finished backup at 24-914 Starting backup at 24-914current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting compressed archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=12 recid=217 stamp=859118561channel ORA_DISK_1: starting piece 1 at 24-914channel ORA_DISK_1: finished piece 1 at 24-914piece handle=/u01/orabackup/backupsets/ora10g-4175411955_20140924_859118562_299.arc tag=ARC_BAK comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 24-914 Starting Control File and SPFILE Autobackup at 24-914piece handle=/u01/orabackup/backupsets/ora10g-c-4175411955-20140924-01.ctl comment=NONEFinished Control File and SPFILE Autobackup at 24-914
更多詳情見請繼續閱讀下一頁的精彩內容: