暂无图片
暂无图片
5
暂无图片
暂无图片
暂无图片

RMAN delete obsolete参数研究

原创 szrsu 2022-09-01
2335

delete obsolete 是把旧于备份保留策略定义的备份数据同时也更新RMAN资料库以及控制文件,同时也应用于数据文件、控制文件、也有控制文件,是通过CONFIGURE RETENTION POLICY 来定义的策略的。

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

所以,针对Primary需要保存最近的archivelog,以便standby出现archivelog gap时过来取,或者有部署goldengate,需要至少保留3天的归档时,最好不要用delete noprompt obsolete; 这个命令。

以下是测试过程:

1、切多次日志

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.


2、查看归档日志文件

[root@single19c 2022_09_01]# ls -lrt
total 35524
-rw-r----- 1 oracle oinstall 3851264 Sep 1 23:17 o1_mf_1_37_kk1m7pf5_.arc
-rw-r----- 1 oracle oinstall 32485376 Sep 1 23:19 o1_mf_1_38_kk1md7sh_.arc
-rw-r----- 1 oracle oinstall 2048 Sep 1 23:19 o1_mf_1_39_kk1mdc4c_.arc
-rw-r----- 1 oracle oinstall 28672 Sep 1 23:19 o1_mf_1_40_kk1mdglx_.arc
-rw-r----- 1 oracle oinstall 2048 Sep 1 23:19 o1_mf_1_41_kk1mdjot_.arc


3、RMAN 全备

[oracle@single19c ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Sep 1 23:21:45 2022
Version 19.16.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.

connected to target database: S19C (DBID=560979251)

RMAN> backup database format '/u01/backup/full_db_%U_%T.ba' tag=full_db;

Starting backup at 01-SEP-22
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=65 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oradata/S19C/system01.dbf
input datafile file number=00003 name=/u01/app/oradata/S19C/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oradata/S19C/undotbs01.dbf
input datafile file number=00007 name=/u01/app/oradata/S19C/users01.dbf
channel ORA_DISK_1: starting piece 1 at 01-SEP-22
channel ORA_DISK_1: finished piece 1 at 01-SEP-22
piece handle=/u01/backup/full_db_0416kbuc_4_1_1_20220901.ba tag=FULL_DB comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 01-SEP-22

Starting Control File and SPFILE Autobackup at 01-SEP-22
piece handle=/u01/arch/S19C/autobackup/2022_09_01/o1_mf_s_1114255344_kk09cjrg_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 01-SEP-22

RMAN> list backup;


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


BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 10.20M DISK 00:00:00 24-AUG-22
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20220824T221301
Piece Name: /u01/arch/S19C/autobackup/2022_08_24/o1_mf_s_1113603181_kjddhfw5_.bkp
SPFILE Included: Modification time: 24-AUG-22
SPFILE db_unique_name: S19C
Control File Included: Ckp SCN: 2430579 Ckp time: 24-AUG-22

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 10.17M DISK 00:00:01 24-AUG-22
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20220824T223427
Piece Name: /u01/app/oradata/S19C/standby_02160gbj_2_1_1.ctl
Standby Control File Included: Ckp SCN: 2434188 Ckp time: 24-AUG-22

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 10.20M DISK 00:00:00 24-AUG-22
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20220824T223429
Piece Name: /u01/arch/S19C/autobackup/2022_08_24/o1_mf_s_1113604469_kjdfqot9_.bkp
SPFILE Included: Modification time: 24-AUG-22
SPFILE db_unique_name: S19C
Control File Included: Ckp SCN: 2434200 Ckp time: 24-AUG-22

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
4 Full 1.48G DISK 00:00:32 01-SEP-22
BP Key: 4 Status: AVAILABLE Compressed: NO Tag: FULL_DB
Piece Name: /u01/backup/full_db_0416kbuc_4_1_1_20220901.ba
List of Datafiles in backup set 4
File LV Type Ckp SCN Ckp Time Abs Fuz SCN Sparse Name
---- -- ---- ---------- --------- ----------- ------ ----
1 Full 3038848 01-SEP-22 NO /u01/app/oradata/S19C/system01.dbf
3 Full 3038848 01-SEP-22 NO /u01/app/oradata/S19C/sysaux01.dbf
4 Full 3038848 01-SEP-22 NO /u01/app/oradata/S19C/undotbs01.dbf
7 Full 3038848 01-SEP-22 NO /u01/app/oradata/S19C/users01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
5 Full 10.23M DISK 00:00:00 01-SEP-22
BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20220901T112224
Piece Name: /u01/arch/S19C/autobackup/2022_09_01/o1_mf_s_1114255344_kk09cjrg_.bkp
SPFILE Included: Modification time: 01-SEP-22
SPFILE db_unique_name: S19C
Control File Included: Ckp SCN: 3038927 Ckp time: 01-SEP-22

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 1 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_22_kjdcyzjs_.arc
Archive Log 2 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_23_kjddv5dp_.arc
Backup Set 1 24-AUG-22
Backup Piece 1 24-AUG-22 /u01/arch/S19C/autobackup/2022_08_24/o1_mf_s_1113603181_kjddhfw5_.bkp
Archive Log 3 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_24_kjddwfsn_.arc
Backup Set 2 24-AUG-22
Backup Piece 2 24-AUG-22 /u01/app/oradata/S19C/standby_02160gbj_2_1_1.ctl
Archive Log 4 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_25_kjdgx8mm_.arc
Backup Set 3 24-AUG-22
Backup Piece 3 24-AUG-22 /u01/arch/S19C/autobackup/2022_08_24/o1_mf_s_1113604469_kjdfqot9_.bkp
Archive Log 6 25-AUG-22 /u01/arch/S19C/archivelog/2022_08_25/o1_mf_1_26_kjdp49wk_.arc
Archive Log 8 25-AUG-22 /u01/arch/S19C/archivelog/2022_08_25/o1_mf_1_27_kjf5snk1_.arc
Archive Log 10 25-AUG-22 /u01/arch/S19C/archivelog/2022_08_25/o1_mf_1_28_kjfgc7cw_.arc
Archive Log 12 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_29_kjjf267c_.arc
Archive Log 14 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_31_kjjlo1sx_.arc
Archive Log 15 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_30_kjjlnzsq_.arc
Archive Log 17 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_32_kjjlo3yl_.arc
Archive Log 20 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_33_kjjm25hy_.arc
Archive Log 22 27-AUG-22 /u01/arch/S19C/archivelog/2022_08_27/o1_mf_1_34_kjlv6m6l_.arc
Archive Log 24 27-AUG-22 /u01/arch/S19C/archivelog/2022_08_27/o1_mf_1_35_kjlvh45z_.arc
Archive Log 26 27-AUG-22 /u01/arch/S19C/archivelog/2022_08_27/o1_mf_1_36_kjlvh56j_.arc
Archive Log 28 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_37_kk1m7pf5_.arc
Archive Log 30 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_38_kk1md7sh_.arc
Archive Log 31 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_39_kk1mdc4c_.arc
Archive Log 34 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_40_kk1mdglx_.arc
Archive Log 36 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_41_kk1mdjot_.arc

做好全备之后,之前产生的归档日志都会标记为过期

5、删除过期备份

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
-------------------- ------ ------------------ --------------------
Archive Log 1 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_22_kjdcyzjs_.arc
Archive Log 2 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_23_kjddv5dp_.arc
Backup Set 1 24-AUG-22
Backup Piece 1 24-AUG-22 /u01/arch/S19C/autobackup/2022_08_24/o1_mf_s_1113603181_kjddhfw5_.bkp
Archive Log 3 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_24_kjddwfsn_.arc
Backup Set 2 24-AUG-22
Backup Piece 2 24-AUG-22 /u01/app/oradata/S19C/standby_02160gbj_2_1_1.ctl
Archive Log 4 24-AUG-22 /u01/arch/S19C/archivelog/2022_08_24/o1_mf_1_25_kjdgx8mm_.arc
Backup Set 3 24-AUG-22
Backup Piece 3 24-AUG-22 /u01/arch/S19C/autobackup/2022_08_24/o1_mf_s_1113604469_kjdfqot9_.bkp
Archive Log 6 25-AUG-22 /u01/arch/S19C/archivelog/2022_08_25/o1_mf_1_26_kjdp49wk_.arc
Archive Log 8 25-AUG-22 /u01/arch/S19C/archivelog/2022_08_25/o1_mf_1_27_kjf5snk1_.arc
Archive Log 10 25-AUG-22 /u01/arch/S19C/archivelog/2022_08_25/o1_mf_1_28_kjfgc7cw_.arc
Archive Log 12 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_29_kjjf267c_.arc
Archive Log 14 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_31_kjjlo1sx_.arc
Archive Log 15 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_30_kjjlnzsq_.arc
Archive Log 17 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_32_kjjlo3yl_.arc
Archive Log 20 26-AUG-22 /u01/arch/S19C/archivelog/2022_08_26/o1_mf_1_33_kjjm25hy_.arc
Archive Log 22 27-AUG-22 /u01/arch/S19C/archivelog/2022_08_27/o1_mf_1_34_kjlv6m6l_.arc
Archive Log 24 27-AUG-22 /u01/arch/S19C/archivelog/2022_08_27/o1_mf_1_35_kjlvh45z_.arc
Archive Log 26 27-AUG-22 /u01/arch/S19C/archivelog/2022_08_27/o1_mf_1_36_kjlvh56j_.arc
Archive Log 28 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_37_kk1m7pf5_.arc
Archive Log 30 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_38_kk1md7sh_.arc
Archive Log 31 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_39_kk1mdc4c_.arc
Archive Log 34 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_40_kk1mdglx_.arc
Archive Log 36 01-SEP-22 /u01/arch/S19C/archivelog/2022_09_01/o1_mf_1_41_kk1mdjot_.arc

Do you really want to delete the above objects (enter YES or NO)? yes

6、再次查看归档日志

[root@single19c 2022_09_01]# ll -hrt
total 0

RMAN> list archivelog all;

specification does not match any archived log in the repository

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

最后修改时间:2022-09-01 11:43:49
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论