我们知道Oracle数据库的RMAN备份类型有多种,我们可以从V$RMAN_BACKUP_JOB_DETAILS这个视图的INPUT_TYPE字段查看备份记录的备份类型,如果你看到备份记录的INPUT_TYPE为RECVR AREA的话,那么这个代表什么类型的RMAN备份呢?其实,一般来说,RECVR AREA表示快速闪回区(flash recovery area)备份,在Oracle 10g时,快速闪回区(flash recovery area)只能备份到磁带设备(tape),如果备份到硬盘时则会报错,具体错误如下所示:
RMAN-06603: 必须在磁盘设备上使用 RECOVERY AREA, RECOVERY FILES 或 DB_RECOVERY_FILE_DEST 指定 TO DESTINATION 选项
或
RMAN-06603: TO DESTINATION option must be specified with RECOVERY AREA, RECOVERY FILES or DB_RECOVERY_FILE_DEST on disk device
从Oracle 11g开始(新的特性),我们可以将快速闪回区(flash recovery area)备份到硬盘,下面我要说的是一个细节问题,一般RMAN备份时,很少备份快速闪回区(flash recovery area),但是使用DP(Data Protector)工具配置RMAN备份时,它自动生成的备份脚本会备份快速闪回区(flash recovery area),一个有意思的现象:如果你在 做RMAN 0级备份时,如果不备份快速闪回区(flash recovery area)的话,V$RMAN_BACKUP_JOB_DETAILS视图中备份记录的INPUT_TYPE字段为DB INCR,如果RMAN 0级备份时备份了快速闪回区(flash recovery area),那么INPUT_TYPE字段为RECVR AREA。
下面我们来测试一下,测试环境为Oracle 19c,测试脚本为rman_db_backup.sh,首先我们使用备份脚本做一个RMAN 0级备份,然后使用下面脚本查询备份记录:
SQL> SET LINESIZE 720;
SQL> COL CON_ID FOR 9999
SQL> COL STATUS FORMAT A9;
SQL> COL START_TIME FOR A19;
SQL> COL END_TIME FOR A19;
SQL> COL BACKUP_TYPE FOR A10;
SQL> COL SESSION_STAMP FOR 9999999
SQL> COL OUTPUT_DEVICE_TYPE FOR A8;
SQL> COL TIME_HR FOR 999.9
SQL> COL IN_GB FOR 9999.9
SQL> COL OUT_GB FOR 9999.9
SQL> COL IO_IN_RATE FOR A10;
SQL> COL IO_OUT_RATE FOR A10;
SQL> COL ELAPSED_MIN FOR 9999.9
SQL> SELECT CON_ID
2 , TO_CHAR(START_TIME, 'YYYY-MM-DD HH24:MI:SS') START_TIME
3 , TO_CHAR(END_TIME, 'YYYY-MM-DD HH24:MI:SS') END_TIME
4 --, SESSION_STAMP
5 , INPUT_TYPE BACKUP_TYPE
6 , STATUS
7 , INPUT_BYTES/1024/1024/1024 IN_GB
8 , INPUT_BYTES_PER_SEC_DISPLAY IO_IN_RATE
9 , OUTPUT_BYTES/1024/1024/1024 OUT_GB
10 , OUTPUT_BYTES_PER_SEC_DISPLAY IO_OUT_RATE
11 , ROUND(ELAPSED_SECONDS/60,2) ELAPSED_MIN
12 --, ROUND(ELAPSED_SECONDS/3600, 1) TIME_HR
13 , OUTPUT_DEVICE_TYPE
14 FROM V$RMAN_BACKUP_JOB_DETAILS
15 WHERE START_TIME > SYSDATE - 1
16 ORDER BY START_TIME ASC;
CON_ID START_TIME END_TIME BACKUP_TYP STATUS IN_GB IO_IN_RATE OUT_GB IO_OUT_RAT ELAPSED_MIN OUTPUT_D
------ ------------------- ------------------- ---------- --------- ------- ---------- ------- ---------- ----------- --------
1 2023-08-02 21:44:51 2023-08-02 21:47:37 DB INCR COMPLETED 7.9 48.55M 1.3 8.26M 2.77 DISK
1 row selected
如上所示,始BACKUP_TYPE(INPUT_TYPE)为DB INCR,接下来修改脚本,增加备份快速闪回区(flash recovery area)的脚本,如下所示:
.......
backup
format '${RMAN_BACKUP_PATH}/dbrecovery_%d_%s_%p_%u_%T.bkp'
recovery area;
.......
继续测试,RMAN备份过程中,你使用上面SQL脚本查询会看到,刚开始时,备份记录的BACKUP_TYPE(INPUT_TYPE)为DB INCR,后面就变成了RECVR AREA类型。
SQL> /
CON_ID START_TIME END_TIME BACKUP_TYP STATUS IN_GB IO_IN_RATE OUT_GB IO_OUT_RAT ELAPSED_MIN OUTPUT_D
------ ------------------- ------------------- ---------- --------- ------- ---------- ------- ---------- ----------- --------
1 2023-08-02 21:44:51 2023-08-02 21:47:37 DB INCR COMPLETED 7.9 48.55M 1.3 8.26M 2.77 DISK
1 2023-08-02 21:49:28 2023-08-02 21:49:34 DB INCR RUNNING .3 53.66M .0 6.17M .1 DISK
2 rows selected.
SQL> /
CON_ID START_TIME END_TIME BACKUP_TYP STATUS IN_GB IO_IN_RATE OUT_GB IO_OUT_RAT ELAPSED_MIN OUTPUT_D
------ ------------------- ------------------- ---------- --------- ------- ---------- ------- ---------- ----------- --------
1 2023-08-02 21:44:51 2023-08-02 21:47:37 DB INCR COMPLETED 7.9 48.55M 1.3 8.26M 2.77 DISK
1 2023-08-02 21:49:28 2023-08-02 21:52:25 RECVR AREA COMPLETED 7.9 45.52M 1.3 7.74M 2.95 DISK
2 rows selected.
另外我测试了一下RMAN全备,测试过程发现,RMAN全备过程中,备份或不备份快速闪回区(flash recovery area),BACKP_TYPE类型都是DB FULL。没有区别。如下截图所示。
接下来,我们单独测试一下备份快速闪回区(flash recovery area),发现其备份类型也是RECVR AREA
$ rman target /
Recovery Manager: Release 19.0.0.0.0 - Production on Wed Aug 2 22:32:05 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: KERRY (DBID=2058288915)
RMAN> BACKUP RECOVERY AREA TO DESTINATION '/db_backup/rman_backup';
Starting backup at 02-AUG-23
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=403 device type=DISK
specification does not match any archived log in the repository
specification does not match any datafile copy in the repository
specification does not match any backup set in the repository
backup cancelled because there are no files to backup
Finished backup at 02-AUG-23
RMAN> backup format 'rman_recovery_backup_%s:%t:%p.dbf' recovery area;
Starting backup at 02-AUG-23
using channel ORA_DISK_1
specification does not match any archived log in the repository
specification does not match any datafile copy in the repository
specification does not match any backup set in the repository
backup cancelled because there are no files to backup
Finished backup at 02-AUG-23
RMAN>
所以,如果下次你看到INPUT_TYPE字段为RECVR AREA的备份记录,不要以为这个备份记录一定就是一个快速闪回区(flash recovery area)备份,其实它还有可能是一个RMAN 0级备份。至于这个现象是一个bug,还是本身就是这种机制。目前我还没有看到相关官方资料。
原文始发于微信公众号(DBA闲思杂想录):RMAN的备份记录类型为RECVR AREA一定就是快速闪回区备份吗?
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/227979.html