rman RETENTION POLICY 7天 保留了两周全备的原因

$RMAN target $TARGET_CONNECT_STR catalog $CATALOG_CONNECT_STR msglog $RMAN_LOG_FILE append << EOF

CONFIGURE BACKUP OPTIMIZATION OFF;

CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;

CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 10G;

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

CONFIGURE ENCRYPTION FOR DATABASE OFF;

CONFIGURE ENCRYPTION ALGORITHM 'AES256';

configure controlfile autobackup on;

show all;

crosscheck archivelog all;

delete force noprompt obsolete device type disk;

RUN {

DELETE noprompt archivelog all backed up 1 times to device type disk;

BACKUP

$BACKUP_TYPE

SKIP INACCESSIBLE

TAG $BACKUP_TAG

DATABASE

plus ARCHIVELOG;

}

EOF

  1. 可能是restore point,但不影响备份文件

RMAN> DELETE noprompt archivelog all backed up 1 times to device type disk;

released channel: ORA_DISK_1

released channel: ORA_DISK_2

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=2846 instance=XXXXXXXXXX1 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=6814 instance=XXXXXXXXXX1 device type=DISK

RMAN-08139: warning: archived redo log not deleted, needed for guaranteed restore point
archived log file name=+RECO01/XXXXXXXXXX/ARCHIVELOG/2023_10_26/thread_1_seq_13223.32836.1151254093 thread=1 sequence=13223

RMAN-08138: warning: archived log not deleted - must create more backups

archived log file name=+RECO01/XXXXXXXXXX/ARCHIVELOG/2023_10_31/thread_1_seq_13327.29560.1151635197 thread=1 sequence=13327

RMAN-08138: warning: archived log not deleted - must create more backups

archived log file name=+RECO01/XXXXXXXXXX/ARCHIVELOG/2023_10_31/thread_1_seq_13328.24688.1151647955 thread=1 sequence=13328
------thread_1 看完看thread_2,10月26-31号之间guaranteed restore point呢???

RMAN-08139: warning: archived redo log not deleted, needed for guaranteed restore point
archived log file name=+RECO01/XXXXXXXXXX/ARCHIVELOG/2023_10_26/thread_2_seq_12865.5217.1151254339 thread=2 sequence=12865

RMAN-08138: warning: archived log not deleted - must create more backups

archived log file name=+RECO01/XXXXXXXXXX/ARCHIVELOG/2023_10_31/thread_2_seq_12975.19172.1151640019 thread=2 sequence=12975

RMAN-08138: warning: archived log not deleted - must create more backups

List of Archived Log Copies for database with db_unique_name XXXXXXXXXX

=====================================================================

---GRP

INCARNA CREATED GUA GRPNAME STORAGE_SIZE_GB PDB CLE CON_NAME

3 2023-10-26 YES SNAPSHOT_20231026 108 YES NO XXX

-----另一个环境创建了许多GRP 又没有保留

channel ORA_DISK_16: SID=3304 instance=uat1 device type=DISK

RMAN-08137: warning: archived log not deleted, needed for standby or upstream capture process

archived log file name=+RECO01/UAT/ARCHIVELOG/2023_10_30/thread_1_seq_18710.23426.1151580577 thread=1 sequence=18710

RMAN-08137: warning: archived log not deleted, needed for standby or upstream capture process

archived log file name=+RECO01/UAT/ARCHIVELOG/2023_10_30/thread_1_seq_18711.24534.1151580589 thread=1 sequence=18711

  1. 7天变14天的原因。

另外每周日做全备,平日做增量,如果CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;那么30号即使做了全备也没用,需要保留22号的备份,所以最长可能在5号,需要保留14天的两个全备。

RDBMS 12.2.0.1

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

之前,一直认为这句话的意思是保留7天(7天内)的备份。虽然之前在操作数据库的时候,发现了这样设置,7天前的备份,甚至10天前的备份仍旧没有被删除,当是比较纳闷,也没有多想,知道今天重新看了rman的文档,才发现之前自己的理解是错误的(可能和自己没上过任何的Oracle培训课程有关,自己理解有误)。

原文地址:(看了下面的官方解释,就明白了)

https://docs.oracle.com/en/database/oracle/oracle-database/12.2/bradv/rman-backup-concepts.html#GUID-A2C982AA-5385-4A45-B0D4-20C1CEFE3DED

8.9.1 About the Recovery Window

A recovery window is a period that begins with the current time and extends backward in time to the point of recoverability. The point of recoverability is the earliest time for a hypothetical point-in-time recovery, that is, the earliest point to which you can recover following a media failure.

For example, if you implement a recovery window of 1 week, then RMAN retains full backups and required incremental backups and archived logs so that the database can be recovered up to 7 days in the past. You implement this retention policy as follows:

CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;

This command ensures that for each data file, one backup that is older than the point of recoverability is retained. For example, if the recovery window is 7, then there must always exist one backup of each data file that satisfies the following condition:

SYSDATE - BACKUP CHECKPOINT TIME >= 7

All backups older than the most recent backup that satisfied this condition are obsolete.

Assume the retention policy illustrated in Figure 8-4. The retention policy has the following aspects:

The recovery window is 7 days.

Database backups are scheduled every two weeks on these days:

January 1

January 15

January 29

February 12

The database runs in ARCHIVELOG mode, and archived logs are saved on disk only if needed for the retention policy.

Figure 8-4 Recovery Window, Part 1

Description of "Figure 8-4 Recovery Window, Part 1"

As illustrated in Figure 8-4, the current time is January 23 and the point of recoverability is January 16. Hence, the January 15 backup is needed for recovery, and so are the archived logs from log sequence 500 through 850. The logs before 500 and the January 1 backup are obsolete because they are not needed for recovery to a point within the window.

Assume the same scenario a week later, as depicted in Figure 8-5.

Figure 8-5 Recovery Window, Part 2

Description of "Figure 8-5 Recovery Window, Part 2"

In this scenario, the current time is January 30 and the point of recoverability is January 23. Note how the January 15 backup is not obsolete even though a more recent backup (January 29) exists in the recovery window. This situation occurs because restoring the January 29 backup does not enable you to recover to the earliest time in the window, January 23. To ensure recoverability to any point in the window, you must save the January 15 backup and all archived logs from sequence 500 to 1150.

测试:

设置的备份的recover window是 7天 。备份的文件如下:有12月27日的,1月3日的,1月7日的,2月14日的,3月28日的。

[oracle@test backup]$ ll

total 13593292

-rw-r----- 1 oracle oinstall 95455744 Mar 28 10:02 arch_D-TEST_id-2261741601_S-148_T-1_A-2291989017_b1ttid5r

-rw-r----- 1 oracle oinstall 314243584 Feb 14 12:14 arc_TEST_20190214_agtprvur_1_1

-rw-r----- 1 oracle oinstall 1153178624 Mar 28 09:58 arc_TEST_20190328_aqtticm4_2261741601_1_1

-rw-r----- 1 oracle oinstall 1061452800 Mar 28 09:58 arc_TEST_20190328_artticm5_2261741601_1_1

-rw-r----- 1 oracle oinstall 11264 Mar 28 09:58 arc_TEST_20190328_astticuf_2261741601_1_1

-rw-r-----. 1 oracle oinstall 1597956096 Dec 27 12:10 fulldb_TEST_20181227_8btlqoq9_1_1

-rw-r-----. 1 oracle oinstall 1556865024 Jan 3 12:08 fulldb_TEST_20190103_8jtmd7ec_1_1

-rw-r----- 1 oracle oinstall 1532657664 Jan 7 12:09 fulldb_TEST_20190107_8stmnoua_1_1

-rw-r----- 1 oracle oinstall 1195073536 Feb 14 12:10 fulldb_TEST_20190214_actprv69_1_1

-rw-r----- 1 oracle oinstall 2080890880 Feb 14 12:12 fulldb_TEST_20190214_adtprv69_1_1

-rw-r----- 1 oracle oinstall 1220780032 Mar 28 09:52 fulldb_TEST_20190328_anttic4j_2261741601_1_1

-rw-r----- 1 oracle oinstall 2110922752 Mar 28 09:53 fulldb_TEST_20190328_aottic4k_2261741601_1_1

drwxrwxr-x. 3 oracle oinstall 85 Mar 28 09:43 scripts

按照我之前的理解,今天是3月28日,保留7天的备份,delete obsolete后,3月21日之前的备份会被删除。实际上没有被删除

RMAN> report obsolete;

RMAN retention policy will be applied to the command

RMAN retention policy is set to recovery window of 7 days

Report of obsolete backups and copies

Type Key Completion Time Filename/Handle


Backup Set 250 27-DEC-18

Backup Piece 257 27-DEC-18 /data/backup/fulldb_TEST_20181227_8btlqoq9_1_1

Backup Set 259 03-JAN-19

Backup Piece 266 03-JAN-19 /data/backup/fulldb_TEST_20190103_8jtmd7ec_1_1

Backup Set 268 07-JAN-19

Backup Piece 275 07-JAN-19 /data/backup/fulldb_TEST_20190107_8stmnoua_1_1

RMAN> delete obsolete;

RMAN retention policy will be applied to the command

RMAN retention policy is set to recovery window of 7 days

using channel ORA_DISK_1

Deleting the following obsolete backups and copies:

Type Key Completion Time Filename/Handle


Backup Set 250 27-DEC-18

Backup Piece 257 27-DEC-18 /data/backup/fulldb_TEST_20181227_8btlqoq9_1_1

Backup Set 259 03-JAN-19

Backup Piece 266 03-JAN-19 /data/backup/fulldb_TEST_20190103_8jtmd7ec_1_1

Backup Set 268 07-JAN-19

Backup Piece 275 07-JAN-19 /data/backup/fulldb_TEST_20190107_8stmnoua_1_1

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

deleted backup piece

backup piece handle=/data/backup/fulldb_TEST_20181227_8btlqoq9_1_1 RECID=257 STAMP=995976009

deleted backup piece

backup piece handle=/data/backup/fulldb_TEST_20190103_8jtmd7ec_1_1 RECID=266 STAMP=996580813

deleted backup piece

backup piece handle=/data/backup/fulldb_TEST_20190107_8stmnoua_1_1 RECID=275 STAMP=996926411

Deleted 3 objects

RMAN>

可以看到2月14日的备份还是存在的。因为设置的策略是保留恢复db的时间窗口是7天,意思是能恢复7天内的db,也就是最早能恢复到3月21日的db的状态。要恢复到3月21日,但是没有3月21日的备份,所以会用到2月14日的备份,2月14日到3月21的数据的差异,是通过2月14日到3月21日的归档来进行恢复的。到这里,这个问题算是搞清楚了,之前自己的理解是有误的。

[oracle@test backup]$ ll

total 9015664

-rw-r----- 1 oracle oinstall 95455744 Mar 28 10:02 arch_D-TEST_id-2261741601_S-148_T-1_A-2291989017_b1ttid5r

-rw-r----- 1 oracle oinstall 314243584 Feb 14 12:14 arc_TEST_20190214_agtprvur_1_1

-rw-r----- 1 oracle oinstall 1153178624 Mar 28 09:58 arc_TEST_20190328_aqtticm4_2261741601_1_1

-rw-r----- 1 oracle oinstall 1061452800 Mar 28 09:58 arc_TEST_20190328_artticm5_2261741601_1_1

-rw-r----- 1 oracle oinstall 11264 Mar 28 09:58 arc_TEST_20190328_astticuf_2261741601_1_1

-rw-r----- 1 oracle oinstall 1195073536 Feb 14 12:10 fulldb_TEST_20190214_actprv69_1_1

-rw-r----- 1 oracle oinstall 2080890880 Feb 14 12:12 fulldb_TEST_20190214_adtprv69_1_1

-rw-r----- 1 oracle oinstall 1220780032 Mar 28 09:52 fulldb_TEST_20190328_anttic4j_2261741601_1_1

-rw-r----- 1 oracle oinstall 2110922752 Mar 28 09:53 fulldb_TEST_20190328_aottic4k_2261741601_1_1

drwxrwxr-x. 3 oracle oinstall 85 Mar 28 09:43 scripts

相关推荐
远歌已逝33 分钟前
维护在线重做日志(二)
数据库·oracle
HPC_fac1305206781633 分钟前
以科学计算为切入点:剖析英伟达服务器过热难题
服务器·人工智能·深度学习·机器学习·计算机视觉·数据挖掘·gpu算力
yaoxin5211232 小时前
第二十七章 TCP 客户端 服务器通信 - 连接管理
服务器·网络·tcp/ip
qq_433099402 小时前
Ubuntu20.04从零安装IsaacSim/IsaacLab
数据库
Dlwyz2 小时前
redis-击穿、穿透、雪崩
数据库·redis·缓存
工业甲酰苯胺4 小时前
Redis性能优化的18招
数据库·redis·性能优化
没书读了5 小时前
ssm框架-spring-spring声明式事务
java·数据库·spring
i道i5 小时前
MySQL win安装 和 pymysql使用示例
数据库·mysql
小怪兽ysl5 小时前
【PostgreSQL使用pg_filedump工具解析数据文件以恢复数据】
数据库·postgresql
wqq_9922502776 小时前
springboot基于微信小程序的食堂预约点餐系统
数据库·微信小程序·小程序