之前误以为归档的备份集超过备份保留策略后,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
7 现在我们发起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的一个全库备份上。