重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4291|回复: 1
打印 上一主题 下一主题

[备份恢复] RMAN备份与恢复之删除过期备份

[复制链接]
跳转到指定楼层
楼主
发表于 2017-12-13 11:12:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

对于OBSOLETE的备份集做删除操作,按照如下步骤:

1.crosscheck backup;
用于核对数据库、表空间、数据文件、控制文件、归档日志、SPFILE的备份集,包括有效和无效的备份
2.report obsolete;(用于列出rman资料库中能够被删除的全备份、数据文件拷贝和归档日志记录
3.delete obsolete; (删除旧于备份保留策略定义的备份数据同时也更新RMAN资料库以及控制文件)
[oracle@strong ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Dec 12 03:17:07 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@strong ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Dec 12 03:17:14 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: YADATA (DBID=3819389340)

RMAN> crosscheck backup;
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=38 device type=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_annnn_TAG20170629T123027_do90m4ns_.bkp RECID=1 STAMP=947939428
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_nnndf_TAG20170629T123030_do90mcgo_.bkp RECID=2 STAMP=947939435
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_ncsnf_TAG20170629T123030_f2b4o019_.bkp RECID=3 STAMP=961867040
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_annnn_TAG20171204T171728_f2b4ob0w_.bkp RECID=4 STAMP=961867050
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_annnn_TAG20171205T085057_f2cvcldk_.bkp RECID=5 STAMP=961923058
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_nnndf_TAG20171205T085101_f2cvcpj3_.bkp RECID=6 STAMP=961923062
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_ncsnf_TAG20171205T085101_f2cvh15j_.bkp RECID=7 STAMP=961923169
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_annnn_TAG20171205T085250_f2cvh2tj_.bkp RECID=8 STAMP=961923170
Crosschecked 8 objects
使用crosscheck backup命令后,提示所有备份集都为available状态

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           1      29-JUN-17         
  Backup Piece       1      29-JUN-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_annnn_TAG20170629T123027_do90m4ns_.bkp
Backup Set           2      04-DEC-17         
  Backup Piece       2      04-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_nnndf_TAG20170629T123030_do90mcgo_.bkp
Backup Set           3      04-DEC-17         
  Backup Piece       3      04-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_ncsnf_TAG20170629T123030_f2b4o019_.bkp
Backup Set           4      04-DEC-17         
  Backup Piece       4      04-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_annnn_TAG20171204T171728_f2b4ob0w_.bkp
Backup Set           5      05-DEC-17         
  Backup Piece       5      05-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_annnn_TAG20171205T085057_f2cvcldk_.bkp
当发起report obsolete 命令查看过期的归档备份集,结果没有显示该备份集为obsolete,是因为参照数据库备份保留策略最老的非obsolete全备份或者0级备份

RMAN> show all; (显示数据库备份保留策略配置如下)


old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored


RMAN configuration parameters for database with db_unique_name YADATA are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_YADATA.f'; # default


RMAN> report obsolete;(数据库的obsolete备份集情况


RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1

no obsolete backups found

RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           1      29-JUN-17         
  Backup Piece       1      29-JUN-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_annnn_TAG20170629T123027_do90m4ns_.bkp
Backup Set           2      04-DEC-17         
  Backup Piece       2      04-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_nnndf_TAG20170629T123030_do90mcgo_.bkp
Backup Set           3      04-DEC-17         
  Backup Piece       3      04-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_ncsnf_TAG20170629T123030_f2b4o019_.bkp
Backup Set           4      04-DEC-17         
  Backup Piece       4      04-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_annnn_TAG20171204T171728_f2b4ob0w_.bkp
Backup Set           5      05-DEC-17         
  Backup Piece       5      05-DEC-17          /u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_annnn_TAG20171205T085057_f2cvcldk_.bkp
Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_annnn_TAG20170629T123027_do90m4ns_.bkp RECID=1 STAMP=947939428
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_06_29/o1_mf_nnndf_TAG20170629T123030_do90mcgo_.bkp RECID=2 STAMP=947939435
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_ncsnf_TAG20170629T123030_f2b4o019_.bkp RECID=3 STAMP=961867040
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_04/o1_mf_annnn_TAG20171204T171728_f2b4ob0w_.bkp RECID=4 STAMP=961867050
deleted backup piece
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_annnn_TAG20171205T085057_f2cvcldk_.bkp RECID=5 STAMP=961923058
Deleted 5 objects
当他执行delete obsolete时,提示有1个文件需要删除,那么这一个文件就是过期文件。

RMAN> crosscheck backupset;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_nnndf_TAG20171205T085101_f2cvcpj3_.bkp RECID=6 STAMP=961923062
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_ncsnf_TAG20171205T085101_f2cvh15j_.bkp RECID=7 STAMP=961923169
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/u01/app/oracle/fast_recovery_area/YADATA/backupset/2017_12_05/o1_mf_annnn_TAG20171205T085250_f2cvh2tj_.bkp RECID=8 STAMP=961923170
Crosschecked 3 objects

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

沙发
 楼主| 发表于 2017-12-13 17:09:28 | 只看该作者
下面是摘抄的一段关于report obsolet的描述
第一段:
report obsolete命令用于列出rman资料库中能够被删除的全备份、数据文件拷贝和归档日志记录。
report obsolete 命令有两个过程
第二段:
对数据文件备份的处理:对于每一个已经备份的数据文件,rman会在保留策略内标识出一个最老的的全数据备份或者0级别备份,如果其它任何数据文件备份比已标识的备份还老则再这一步直接认作obsolete
第三段
对归档日志文件或者增量备份处理:
首先应该有一个参照,这个参照就是保留策略内最老的非obsolete 全备份或者0级备份。
如果归档文件或者增量备份比标识的非obsolete且最老的full backup 还老,则视为obsolete。
如果归档文件或者增量备份能够被应用在一个非obsolete的全备份或者0级别备份,则归档及增量备份为非obsolete,反之则为obsolete。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-27 19:45 , Processed in 0.096671 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表