其他分享
首页 > 其他分享> > 历史备份过多使用delete obsolete方式找不到过期备份信息???

历史备份过多使用delete obsolete方式找不到过期备份信息???

作者:互联网

一套生产环境DB,每周日进行一次0级全备,其余每周6天都是增量备份。

但是磁盘告警,备份目录使用率>90%, 检查备份脚本是定期删除8天前的过期备份信息!!!

发现的问题: 最早的备份信息是3周前的备份信息??? 删除脚本失效了???

1. 准备操作,手工执行清理8天前的rman备份信息。

run
{
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;
delete noprompt obsolete device type disk;
}
执行之后无报错! 但是未删除任何信息???
是不是21天前的备份信息,根本不在控制文件中???
使用catalog 注册一下备份片信息
catalog start with '/bak';
yes --发现n多备份信息,可以被注册,说明什么,说明21天前的很多备份信息,确实在控制文件中不存在了???

参数

控制文件默认保留时间7天,也就是说,当控制文件积累到一定大小的程度时,会自动清理备份记录信息(不会删除备份文件,只是删除控制文件中记录的备份信息)
以及归档信息
SQL> show parameter control_file_record_keep_time NAME TYPE VALUE ------------------------------------ ---------------------- ------------------------------ control_file_record_keep_time integer 7

    Relation between RMAN retention period and control_file_record_keep_time (Doc ID 397269.1)
    RMAN backup keeps the backup metadata information in the reusable section of the controlfile. It depends on the parameter CONTROL_FILE_RECORD_KEEP_TIME. CONTROL_FILE_RECORD_KEEP_TIME specifies the minimum number of days before a reusable recordin the control file can be reused. In the event a new record needs to be added to a reusable section and there is not enough space then it will delete the oldest record, which are aged enough. 

    Backup retention policy is the rule to set regarding which backups must be retained (whether on disk or other backup media) to meet the recovery and other requirements.
If the CONTROL_FILE_RECORD_KEEP_TIME is less than the retention policy then it may overwrite reusable records prior to obsoleting them in the RMAN metadata. Therefor it is recommended that the CONTROL_FILE_RECORD_KEEP_TIME should set to a higher value than the retention policy.
    Please note the default control_file_record_keep_time is 7 day
NOTE: Best practice is to NOT set control_file_record_keep_time to a value greater than 10. If you need retention greater than this in the controlfile, you should use an RMAN catalog.
   Formula
    CONTROL_FILE_RECORD_KEEP_TIME = retention period + level 0 backup interval + 1
   For e.g.
    e.q. level 0 backup once a week with retention policy of a recovery windows of 14 days then in this case the CONTROL_FILE_RECORD_KEEP_TIME should be 14+7+1=22
    To be on safer side you can always add + 2 or 3 days to above formula.
Ideally its recommended to configure a recovery catalog so that information about the backups are present in recovery catalog even though the controlfile section gets reused based on the control_file_record_keep_time due to space pressure.

SQL> select * from V$CONTROLFILE_RECORD_SECTION;
有人会问? 为什么超出默认的7天? 但是备份信息还是保留呢? 空间足够没必要覆盖,备份信息过多才会自动清理。
那么如何处理??? 1.不建议直接跳转加大参数,无法调整清理备份信息在进行调整;
SQL> alter system set control_file_record_keep_time=31 sid='*';
2.备份的定时任务是否有必要进行调整,及时清理多余的备份信息;
3.可以脚本中加上RMAN> catalog start with '/bak/' noprompt;

searching for all files that match the pattern /bak/

List of Files Unknown to the Database
=====================================
File Name: /bak/0buvkgth
File Name: /bak/0cuvkgtk
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /bak/0buvkgth
File Name: /bak/0cuvkgtk

 

使用catalog 注册后,再次执行删除语法,可以执行,但是执行删除8天前的日志,但是却保留了2周的备份信息!!!

每周一次备份

 2.由于机制问题,按照时间窗口,清理过期的备份,清理8天前,也就是存在

上周5的增倍,上周6的全备-至今, 最初的理解是,删除8天前,应该是只保留上周5-至今的备份信息; 

但是oracle 定义的过期是,保留8天的恢复窗口内,可以使用备份恢复到任意时刻! 包括本次最早的一天,上周5,如果仅仅只保留最近8天的备份,最近的全备是上周6,无法恢复到上周5的数据。  因此保留8天恢复窗口,配合每周一次增量备份,等同于保留2次RMAN全备数据!!!

标签:control,备份,obsolete,信息,record,file,retention,delete
来源: https://www.cnblogs.com/lvcha001/p/12842093.html