對rman命令report obsolete的一點說明

來源:互聯網
上載者:User

 

    之前誤以為歸檔的備份組超過備份保留原則後,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 當前Database Backup保留原則配置如下
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的一個全庫備份上。
 

 

 

 

 

本文出自 “myblog” 部落格,請務必保留此出處http://jiujian.blog.51cto.com/444665/1165766

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.