RMAN delete noprompt obsolete参数研究

RMAN delete noprompt obsolete参数研究

经过测试发现,delete noprompt obsolete;只会根据RMAN的保留策略为参考,如果在T0时间点存在多个归档日志,在T1时间点做了RMAN全备,此时report obsolete;那么T0时间点的归档日志都会被标记为过期,再根据保留策略RMAN会清理归档日志。

备注:如果有0级备份、1级备份,做完1级备份之后,会删除早前0级备份自动备份的控制文件、参数文件备份,0级备份到1级备份这一时间段的归档日志不会删除

具体测试如下:

1、切多次日志

SQL>alter system switch logfile;
SQL>alter system switch logfile;
SQL>alter system switch logfile;
SQL>alter system switch logfile;

2、查看归档日志文件

[root@ora19c arch]# ll
total 30236
-rw-r----- 1 ora11g oinstall 30945792 May 16 10:10 1_400_1002014785.dbf
-rw-r----- 1 ora11g oinstall     1024 May 16 10:10 1_401_1002014785.dbf
-rw-r----- 1 ora11g oinstall     1024 May 16 10:10 1_402_1002014785.dbf
-rw-r----- 1 ora11g oinstall     1024 May 16 10:10 1_403_1002014785.dbf

3、RMAN 全备

RMAN> backup database format '/u02/rman/full_db_%U_%T.bak' tag=full_db;  

Starting backup at 2019-05-16 10:10:56
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u02/app/oracle/oradata/orcl/ADMIN_5.dbf
input datafile file number=00001 name=/u02/app/oracle/oradata/orcl/system01.dbf
input datafile file number=00002 name=/u02/app/oracle/oradata/orcl/sysaux01.dbf
input datafile file number=00003 name=/u02/app/oracle/oradata/orcl/undotbs01.dbf
input datafile file number=00004 name=/u02/app/oracle/oradata/orcl/users01.dbf
input datafile file number=00006 name=/u02/app/oracle/oradata/orcl/TBS_6.dbf
input datafile file number=00007 name=/u02/app/oracle/oradata/orcl/TBS_INDEX_7.dbf
channel ORA_DISK_1: starting piece 1 at 2019-05-16 10:10:56
channel ORA_DISK_1: finished piece 1 at 2019-05-16 10:13:03
piece handle=/u02/rman/full_db_12u1m8dg_1_1_20190516.bak tag=FULL_DB comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:07
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 2019-05-16 10:13:04
channel ORA_DISK_1: finished piece 1 at 2019-05-16 10:13:05
piece handle=/u02/rman/full_db_13u1m8hf_1_1_20190516.bak tag=FULL_DB comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2019-05-16 10:13:05
RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
28      Full    4.19G      DISK        00:02:02     2019-05-16 10:12:58
        BP Key: 28   Status: AVAILABLE  Compressed: NO  Tag: FULL_DB
        Piece Name: /u02/rman/full_db_12u1m8dg_1_1_20190516.bak
  List of Datafiles in backup set 28
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/system01.dbf
  2       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/sysaux01.dbf
  3       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/undotbs01.dbf
  4       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/users01.dbf
  5       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/ADMIN_5.dbf
  6       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/TBS_6.dbf
  7       Full 16286604902445 2019-05-16 10:10:56 /u02/app/oracle/oradata/orcl/TBS_INDEX_7.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time    
------- ---- -- ---------- ----------- ------------ -------------------
29      Full    9.58M      DISK        00:00:02     2019-05-16 10:13:05
        BP Key: 29   Status: AVAILABLE  Compressed: NO  Tag: FULL_DB
        Piece Name: /u02/rman/full_db_13u1m8hf_1_1_20190516.bak
  SPFILE Included: Modification time: 2019-05-13 15:33:28
  SPFILE db_unique_name: ORCL
  Control File Included: Ckp SCN: 16286604902494   Ckp time: 2019-05-16 10:13:03

4、查看过期备份

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
-------------------- ------ ------------------ --------------------
Archive Log          395    2019-05-16 10:10:02 /u02/arch/1_400_1002014785.dbf
Archive Log          396    2019-05-16 10:10:11 /u02/arch/1_401_1002014785.dbf
Archive Log          397    2019-05-16 10:10:12 /u02/arch/1_402_1002014785.dbf
Archive Log          398    2019-05-16 10:10:13 /u02/arch/1_403_1002014785.dbf
做好全备之后,之前产生的归档日志都会标记为过期

5、删除过期备份

RMAN> delete noprompt 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
-------------------- ------ ------------------ --------------------
Archive Log          395    2019-05-16 10:10:02 /u02/arch/1_400_1002014785.dbf
Archive Log          396    2019-05-16 10:10:11 /u02/arch/1_401_1002014785.dbf
Archive Log          397    2019-05-16 10:10:12 /u02/arch/1_402_1002014785.dbf
Archive Log          398    2019-05-16 10:10:13 /u02/arch/1_403_1002014785.dbf
deleted archived log
archived log file name=/u02/arch/1_400_1002014785.dbf RECID=395 STAMP=1008411002
deleted archived log
archived log file name=/u02/arch/1_401_1002014785.dbf RECID=396 STAMP=1008411011
deleted archived log
archived log file name=/u02/arch/1_402_1002014785.dbf RECID=397 STAMP=1008411012
deleted archived log
archived log file name=/u02/arch/1_403_1002014785.dbf RECID=398 STAMP=1008411013
Deleted 4 objects

6、再次查看归档日志

[root@ora19c arch]# ll -hrt
total 0

RMAN> list archivelog all;

specification does not match any archived log in the repository

总结:T1时间点做RMAN全备,做完全备之后在T1时间点之前的归档日志、增量备份、控制文件参数文件备份都会标记为过期

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值