在rman恢复中incarnation的概念
摘要
本文主要介绍incarnation的由来,在rman恢复中的作用,以及相关rman恢复的注意事项。
概念说明
从10g开始,incarnation被引入,用于跨越resetlogs进行恢复,由此可见,此概念在rman中可以找到相关使用轨迹。
Resetlogs命令表示一个数据库逻辑生存期的结束和另一个数据库逻辑生存期的开始,Oracle把这个数据库逻辑生存期称为incarnation;每次使用resetlogs打开数据库,就会使incarnation + 1,也就是产生一个新的incarnation;如果想要恢复到之前incarnation的scn/time,就需要先恢复到之前的incarnation;
下图来源官方文档,可以自行理解incarnation在 rman恢复的作用,其中灰色线是数据库rman恢复之后的运行路径。

实验环节
初识incarnation
在rman中可以可以通过list incarnation命令查看当前数据库有多少化身,新创建的数据库默认只有1条记录,下面所示2条记录,代表数据库做过rman不完全恢复,即进行过alter database open resetlogs操作。
[oracle@redhat3 ~]$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 18 10:10:37 2019 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: TEST (DBID=2274480208, not open) RMAN> list incarnation; using target database control file instead of recovery catalog List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 2274480208 PARENT 4483656 11-JUL-19
2 2 TEST 2274480208 CURRENT 4504768 11-JUL-19
对数据库进行不完全恢复
首先对数据库进行rman备份,此处不做过多说明。
查看现有rman备份,可知数据文件6的scn为457020,即数据最小可指定恢复SCN号为457020,(实验一中会给出说明),最大可指定SCN号为归档文件的25号的4597382(下面会进行演示),所以指定SCN号恢复时,SCN区间应在457020-4597382之间。
RMAN> list backup; List of Backup Sets
=================== BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
1 Full 237.04M DISK 00:01:08 18-JUL-19
BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20190718T093005
Piece Name: /u01/app/rmanbak/db_TEST_20190718_01u6uu0u_1
List of Datafiles in backup set 1
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
2 Full 4596984 18-JUL-19 /u01/app/oracle/oradata/test/sysaux01.dbf
4 Full 4596984 18-JUL-19 /u01/app/oracle/oradata/test/users01.dbf
7 Full 4596984 18-JUL-19 /u01/app/oracle/oradata/test/sde01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 307.69M DISK 00:01:10 18-JUL-19
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20190718T093005
Piece Name: /u01/app/rmanbak/db_TEST_20190718_02u6uu0u_1
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 4596985 18-JUL-19 /u01/app/oracle/oradata/test/system01.dbf
8 Full 4596985 18-JUL-19 /u01/app/oracle/oradata/test/UNDO2.DBF BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
3 Full 1.47M DISK 00:00:00 18-JUL-19
BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20190718T093005
Piece Name: /u01/app/rmanbak/db_TEST_20190718_03u6uu3b_1
List of Datafiles in backup set 3
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
6 Full 4597020 18-JUL-19 /u01/app/oracle/oradata/test/tbs_1.dbf
。。。。。。。。。。。。。 List of Archived Logs in backup set 11
Thrd Seq Low SCN Low Time Next SCN Next Time
---- ------- ---------- --------- ---------- ---------
1 24 4597222 18-JUL-19 4597382 18-JUL-19
1 25 4597382 18-JUL-19 4597393 18-JUL-19
实验一 验证最小可指定SCN号
注意我们指定的SCN为4597019,比上述数据文件6的scn457020还少1,报错为找不到文件6的备份。
个人理解,在restore database时,rman只能找到scn为457020的文件6,并没有比其SCN小的数据文件备份,所以报错,而其他几个数据文件在备份时,SCN号小于4597019,可以在recover database进行增量恢复。说白了就是文件6最小的SCN是从457020开始。
注:RMAN-06023 错也有可能是其他原因导致,此处实验只是为证明恢复时指定SCN问题!!!!
[oracle@redhat3 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 18 10:26:56 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2274480208, not open)
RMAN> run{
2> set until scn 4597019;
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 18-JUL-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/18/2019 10:26:59
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 6 found to restore
下面指定SCN 4597020恢复成功。
RMAN> run{
2> set until scn 4597020;
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 18-JUL-19
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
。。。。。。。。。。
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 18-JUL-19
Starting recover at 18-JUL-19
using channel ORA_DISK_1
starting media recovery
。。。。。。。
Finished recover at 18-JUL-19
实验二 incarnation增长
在SCN区间457020-4597382中,选一个进行不完全恢复,然后resetlogs,查看incarnation会+1。指定4597300进行恢复。
可以发现在resetlogs后,执行list incarnation后,确认增加1条,且Reset SCN 4597301,比指定的4597300大1。数据库开启一个新的生命周期,在list incarnation命令中第3条记录的status 字段为CURRENT。
RMAN> run{
2> set until scn 4597300;
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 18-JUL-19
using channel ORA_DISK_1
。。。。。。。。。。。。。。。。
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 18-JUL-19
Starting recover at 18-JUL-19
using channel ORA_DISK_1
starting media recovery
。。。。。。。。。。。。
media recovery complete, elapsed time: 00:00:02
Finished recover at 18-JUL-19
RMAN> alter database open resetlogs;
database opened
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 2274480208 PARENT 4483656 11-JUL-19
2 2 TEST 2274480208 PARENT 4504768 11-JUL-19
3 3 TEST 2274480208 CURRENT 4597301 18-JUL-19
实验三 incarnation reset
在实验二中,我们看到incarnation已经+1,如果在此时,需要重新恢复库至4597300之前的SCN号,将会出现什么情况?
清理之前恢复的数据文件,日志文件(不要清理控制文件)
如下所示,直接进行恢复,提示RMAN-20208,其实提示的也很清楚,就是告诉我们,控制文件里面已经记录过比这个SCN大的resetlogs,需要恢复的SCN不在当前数据库生命周期中。如需恢复,则需要把SCN重置到自己的生命周期中。
[oracle@redhat3 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 18 11:17:23 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2274480208, not open)
RMAN> list incarnation;
using target database control file instead of recovery catalog List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 2274480208 PARENT 4483656 11-JUL-19
2 2 TEST 2274480208 PARENT 4504768 11-JUL-19
3 3 TEST 2274480208 CURRENT 4597301 18-JUL-19 RMAN> run{
2> set until scn 4597280;
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 18-JUL-19
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 07/18/2019 11:17:56
RMAN-20208: UNTIL CHANGE is before RESETLOGS change
通过reset 命令可以重置数据库的生命周期。在重置后,可以看到第2号记录的STATUS字段调整为CURRENT。这时再进行恢复则正常。
[oracle@redhat3 ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jul 18 11:23:55 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2274480208, not open)
RMAN> list incarnation; using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 2274480208 PARENT 4483656 11-JUL-19
2 2 TEST 2274480208 PARENT 4504768 11-JUL-19
3 3 TEST 2274480208 CURRENT 4597301 18-JUL-19 RMAN> reset database to incarnation 2; database reset to incarnation 2 RMAN> list incarnation; List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 TEST 2274480208 PARENT 4483656 11-JUL-19
2 2 TEST 2274480208 CURRENT 4504768 11-JUL-19
3 3 TEST 2274480208 ORPHAN 4597301 18-JUL-19 RMAN> run{
2> set until scn 4597280;
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 18-JUL-19
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
。。。。。。。。。。。
总结
通过上述的实验,我们可得出以下结论:
1、rman恢复如指定SCN,则需要通过查看备份中数据文件的最大SCN号最为起点。
2、在resetlogs后,如要恢复之前的SCN,则需要进行reset前身。(如果控制文件是重新恢复的,则不需要)
3、实践是检验真理的唯一标准,作为DBA,多多动手实验才是王道。
在rman恢复中incarnation的概念的更多相关文章
- 记录一则RMAN恢复到历史备份(多个incarnation)
环境: OEL 5.7 + Oracle 11.2.0.4 1.直接restore到想要恢复的时间点报错: RMAN> sql "alter session set nls_date_ ...
- Oracle Rman恢复
(转自:http://blog.chinaunix.net/uid-14779297-id-1988309.html) RMAN的基本概念 Target Database:就是需要RMAN对其进行备份 ...
- Oracle DB 使用RMAN恢复目录
• 对恢复目录和RMAN 资料档案库控制文件的使用进行比较• 创建和配置恢复目录• 在恢复目录中注册数据库• 同步恢复目录• 使用RMAN 存储脚本• 备份恢复目录• 创建虚拟专用目录 RMAN 资料 ...
- rman恢复方案和oracle异机恢复
这篇文章主要介绍了rman恢复方案和oracle异机恢复,需要的朋友可以参考下 注:①恢复的前提是已经做好备份②完全恢复数据库是数据库遇到故障,在恢复时候没有丢失任何已经提交事物数据的恢复不完全恢复数 ...
- Oracle - RMAN备份 之 incarnation的实验和小结
对于RMAN恢复我一直都不是很明白,因为,老是搞不清楚不完全恢复该怎么进行,今天,通过这个实验即是对不完全恢复的实践,也是希望搞清楚incarnation到底是怎么工作的.很可惜,本人对Oracle的 ...
- 12c RAC 用Rman 恢复到异机单实例
准备工作 原服务器软件部署:Redhat 6.6 + Oracle 12.2.0.1 rac Oracle12c单实例安装 1.创建恢复服务器,设置大于原库数据大小的磁盘容量.设置相同的服务器主机名参 ...
- RAC+asm通过rman恢复到单实例+asm
1.恢复参数文件,并修改参数文件 参数文件指名几个最简单的就行,我的参数文件如下: 2.恢复控制文件,并启动数据库到mount 如果是把备份集从别的服务器拷贝到本地恢复的服务器的目录,使用下面的语句指 ...
- oracle rman恢复数据库 方式恢复到异地数据库
目的:从某个环境中,获取相关文件,放到异地机器使用rman 恢复. 情况说明:XX系统使用的是oracle数据库,现已从服务器拉下来相关文件,依靠这些文件来早本地的测试机上恢复数据库,方便进行数据 ...
- RMAN恢复目录
是否使用RMAN恢复目录(Recovery Catalog 你可能从其他人或书上听过RMAN恢复目录(也有可能是其他名字,RMAN Recovery Catalog的翻译较多较杂,以下简称恢复目录), ...
随机推荐
- 关于powerdesigner中的data types说明
原文:关于powerdesigner中的data types说明 这一堆的数据类型看着真是头大,弄个表格对照一下. Numeric data types Standard datatype DBMS- ...
- 基于VUE实现的新闻后台管理系统-二
基础环境及最后的开发效果已完成说明,接下来就开始配置. ¶npm初始化 新建项目文件夹VueDemo,在其内执行如下脚本 npm init -y 安装vue-cli构建包 yarn add vue-c ...
- Add-AppxProvisionedPackage
原文: Add-AppxProvisionedPackage Adds an app package (.appx) that will install for each new user to a ...
- wp8.1之拍照(获取焦点,使用后置摄像头)
wp8.1 没有像wp8一样直接用启动器开启摄像头,他要开启摄像头要借助CaptureElement呈现来自捕获设备(如照相机或网络摄像机)的流.今天讲讲如何打开摄像头,获取焦点,以及拍照.废话不多说 ...
- IdHTTP设置SSL证书,乱码问题也解决了
要跟银行做接口,需要使用delphi来post数据,但对方提供的是https开头的网址,需要使用证书,对方已提供证书了,但是还是调用不成功,使用的是idhttp和TIdSSLIOHandlerSock ...
- D7下FastMM的使用
原文出处:http://hi.baidu.com/showwindows/blog/item/5b7ac601c487c605728da573.html FastMM 快速MM:-),在D2006和2 ...
- c# json key转大小写
有需求需要将json的字段转换为小写,使用正则表达式实现,代码如下 正则表达式为 \"[a-zA-Z0-9]+\"\s*: MatchCollection ms = Regex ...
- 取得文件夹内容信息(使用IShellFolder接口)
翻译自MSDN 2005 -> Win32 和 COM 开发 -> User Interface -> Windows User Experience -> Windows S ...
- Eric Linux - 1 Basic concepts of linux
Computer basic Computer 5 parts CPU Input Output Memory External storage device. CPU RISC: Reduced I ...
- MongoDB自学日记1——基本操作
作为一个做底层及后台研发的,最近对NoSQL却产生了浓厚的兴趣,加入了一个DBA群,据说北京排的上号的DBA都在里面,然而里面基本都是Oracle系的,MySQL和MongoDB系的少之又少.学习靠不 ...