對rman命令report obsolete的一點說明

      原文轉自:http://jiujian.blog.51cto.com/444665/1165766

       

   之前誤以爲歸檔的備份集超過備份保留策略後,report obsolete 會報其過期.於是設置了備份冗餘策略爲1,備份兩次歸檔,發起report obsolete 命令希望能看到過期的歸檔備份集,但結果卻未顯示該備份集obsolete,看來有必要好好研究下,於是有下文。

一 先看看report obsolete命令的官方說明

Lists full backups, data file copies, and archived redo log files recorded in the 
RMAN repository that can be deleted because they are no longer needed  The command works 
in two steps:
 
For each data file that has been backed up, RMAN identifies the oldest full 
backup, level 0 backup, or image copy that is not obsolete under the 
retention policy. Any backup of the data file older than the one identified in 
this step is considered obsolete.
Any archived redo log files and level 1 incremental backups that are older 
than the oldest nonobsolete full backup are considered obsolete. These files 
are obsolete because no full or level 0 backup exists to which they can be 
applied. Incremental level 1 backups or archived redo log files are not 
considered obsolete if they can be applied to nonobsolete level 0 or full 
backups.

第一段:

report obsolete命令用於列出rman資料庫中能夠被刪除的全備份、數據文件拷貝和歸檔日誌記錄。
report obsolete 命令有兩個過程

第二段:
對數據文件備份的處理:對於每一個已經備份的數據文件,rman會在保留策略內標識出一個最老的的全數據備份或者0級別備份,如果其它任何數據文件備份比已標識的備份還老則再這一步直接認作obsolete

第三段
對歸檔日誌文件或者增量備份處理:
首先應該有一個參照,這個參照就是保留策略內最老的非obsolete 全備份或者0級備份。
如果歸檔文件或者增量備份比標識的非obsolete且最老的full backup 還老,則視爲obsolete。
如果歸檔文件或者增量備份能夠被應用在一個非obsolete的全備份或者0級別備份,則歸檔及增量備份爲非obsolete,反之則爲obsolete。


二 驗證

 

1 當前數據庫備份保留策略配置如下

RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name CRM are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;

2 當前數據庫的obsolete備份集情況如下:

RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
no obsolete backups found


3 備份數據庫的所有歸檔兩次

RMAN> run{ 
2> allocate channel c1 type disk; 
3> backup  archivelog all format '/backup/arch2_%T_%U';
4> release channel c1;  
5> }
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
allocated channel: c1
channel c1: SID=131 device type=DISK
Starting backup at 2013-03-27 16:15:47
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=124 RECID=843 STAMP=811181727
input archived log thread=1 sequence=125 RECID=844 STAMP=811181727
input archived log thread=1 sequence=126 RECID=845 STAMP=811181728
input archived log thread=1 sequence=127 RECID=846 STAMP=811181729
input archived log thread=1 sequence=128 RECID=847 STAMP=811181729
input archived log thread=1 sequence=129 RECID=848 STAMP=811181730
input archived log thread=1 sequence=130 RECID=849 STAMP=811181747
channel c1: starting piece 1 at 2013-03-27 16:15:48
channel c1: finished piece 1 at 2013-03-27 16:15:49
piece handle=/backup/arch2_20130327_0mo5j9lj_1_1 tag=TAG20130327T161547 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2013-03-27 16:15:49
Starting Control File and SPFILE Autobackup at 2013-03-27 16:15:49
piece handle=/backup/c-3599153036-20130327-04 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-03-27 16:15:50
released channel: c1
RMAN> run{ 
2> allocate channel c1 type disk; 
3> backup  archivelog all format '/backup/arch2_%T_%U';
4> release channel c1;  
5> }
allocated channel: c1
channel c1: SID=131 device type=DISK
Starting backup at 2013-03-27 16:15:56
current log archived
channel c1: starting archived log backup set
channel c1: specifying archived log(s) in backup set
input archived log thread=1 sequence=124 RECID=843 STAMP=811181727
input archived log thread=1 sequence=125 RECID=844 STAMP=811181727
input archived log thread=1 sequence=126 RECID=845 STAMP=811181728
input archived log thread=1 sequence=127 RECID=846 STAMP=811181729
input archived log thread=1 sequence=128 RECID=847 STAMP=811181729
input archived log thread=1 sequence=129 RECID=848 STAMP=811181730
input archived log thread=1 sequence=130 RECID=849 STAMP=811181747
input archived log thread=1 sequence=131 RECID=850 STAMP=811181756
channel c1: starting piece 1 at 2013-03-27 16:15:56
channel c1: finished piece 1 at 2013-03-27 16:15:57
piece handle=/backup/arch2_20130327_0oo5j9ls_1_1 tag=TAG20130327T161556 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 2013-03-27 16:15:57
Starting Control File and SPFILE Autobackup at 2013-03-27 16:15:57
piece handle=/backup/c-3599153036-20130327-05 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-03-27 16:15:58
released channel: c1


4 再次查看report obsolete的顯示,發現無任何歸檔備份集obsolete情況。

注意:到此爲止,數據庫還未做過全備份,即缺乏比較的參照物“the oldest nonobsolete full backup”。


RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           838    2013-03-27 16:09:54
  Backup Piece       847    2013-03-27 16:09:54 /backup/c-3599153036-20130327-03
Backup Set           840    2013-03-27 16:15:50
  Backup Piece       849    2013-03-27 16:15:50 /backup/c-3599153036-20130327-04


  
5 做一次數據庫全備份(即讓數據庫產生一個“the oldest nonobsolete full backup”)


RMAN> run{ 
2> allocate channel c1 type disk; 
3> backup  database format '/backup/fulldb_%T_%U';
4> release channel c1;  
5> }
allocated channel: c1
channel c1: SID=131 device type=DISK
Starting backup at 2013-03-27 16:16:58
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00004 name=/oracle/CRM/test2/USERS4.dbf
input datafile file number=00001 name=/oracle/CRM/test2/SYSTEM1.dbf
input datafile file number=00002 name=/oracle/CRM/test2/SYSAUX2.dbf
input datafile file number=00005 name=/oracle/CRM/test2/pos1.dbf
input datafile file number=00003 name=/oracle/CRM/test2/UNDOTBS33.dbf
input datafile file number=00006 name=/oracle/CRM/test2/ERP6.dbf
input datafile file number=00009 name=/oracle/CRM/test2/pos2.dbf
input datafile file number=00007 name=/oracle/CRM/test2/USER017.dbf
input datafile file number=00008 name=/oracle/CRM/test2/TEST8.dbf
channel c1: starting piece 1 at 2013-03-27 16:16:58
channel c1: finished piece 1 at 2013-03-27 16:19:43
piece handle=/backup/fulldb_20130327_0qo5j9nq_1_1 tag=TAG20130327T161658 comment=NONE
channel c1: backup set complete, elapsed time: 00:02:46
Finished backup at 2013-03-27 16:19:44
Starting Control File and SPFILE Autobackup at 2013-03-27 16:19:44
piece handle=/backup/c-3599153036-20130327-06 comment=NONE
Finished Control File and SPFILE Autobackup at 2013-03-27 16:19:47
released channel: c1


6 數據庫的日誌情況如下(可發現當前oracle最後一個歸檔seq號爲131)


SQL> select group#,archived,sequence#,status from v$Log;
    GROUP# ARC  SEQUENCE# STATUS
---------- --- ---------- ----------------
         1 YES        129 INACTIVE
         2 YES        130 INACTIVE
         3 YES        131 INACTIVE
         4 NO         132 CURRENT


現在我們發起report obsolete命令,則系統內所有歸檔備份集和歸檔文件會和這個保留策略內”the oldest nonobsolete full backup“做比較 凡是無用的歸檔備份集和歸檔日誌則在rman資料庫內標記爲obsolete。

 

RMAN> report obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           837    2013-03-27 16:09:48
  Backup Piece       846    2013-03-27 16:09:48 /backup/fulldb1_20130327_0ho5j95g_1_1
Archive Log          844    2013-03-27 16:15:27 /oracle/archive/1_125_810495590.dbf
Backup Set           838    2013-03-27 16:09:54
  Backup Piece       847    2013-03-27 16:09:54 /backup/c-3599153036-20130327-03
Archive Log          843    2013-03-27 16:15:27 /oracle/archive/1_124_810495590.dbf
Archive Log          845    2013-03-27 16:15:28 /oracle/archive/1_126_810495590.dbf
Archive Log          846    2013-03-27 16:15:29 /oracle/archive/1_127_810495590.dbf
Archive Log          847    2013-03-27 16:15:29 /oracle/archive/1_128_810495590.dbf
Archive Log          848    2013-03-27 16:15:30 /oracle/archive/1_129_810495590.dbf
Archive Log          849    2013-03-27 16:15:47 /oracle/archive/1_130_810495590.dbf
Backup Set           839    2013-03-27 16:15:48
  Backup Piece       848    2013-03-27 16:15:48 /backup/arch2_20130327_0mo5j9lj_1_1
Backup Set           840    2013-03-27 16:15:50
  Backup Piece       849    2013-03-27 16:15:50 /backup/c-3599153036-20130327-04
Archive Log          850    2013-03-27 16:15:56 /oracle/archive/1_131_810495590.dbf
Backup Set           841    2013-03-27 16:15:56
  Backup Piece       850    2013-03-27 16:15:56 /backup/arch2_20130327_0oo5j9ls_1_1
Backup Set           842    2013-03-27 16:15:58
  Backup Piece       851    2013-03-27 16:15:58 /backup/c-3599153036-20130327-05


總結:
1 歸檔備份集如果obsolete,,則恢復數據庫時該備份集所包含的歸檔無須被應用到保留策略內最舊非obsolete的一個全備份。

2 歸檔文件如果obsolete,則這些歸檔文件在數據庫進行恢復時無須被應用到備份保留策略內最舊非obsolete的一個全庫備份上。

發佈了103 篇原創文章 · 獲贊 8 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章