`

Oracle Incarnation 详解与Rman跨resetlogs版本恢复(原创)

 
阅读更多

Oracle Incarnation 详解
先 解释一下我对incarnation的理解吧,incarnation,我把这个叫做数据库实体,不知道其他人怎么个叫法,从含义上看,它指的是一个重置 scn后的数据库场景。一个数据库在刚开始被创建出来时,scn号为1,随着运行,scn不断单调递增,Oracle就是根据scn描述数据库的整个发展 进程,可以说scn就是数据库的时间轴。当数据库正常运行,或者执行完全恢复时,scn只会单调递增直到最新的scn,这样数据库中所有的数据都按照时间 的顺序改变着,但如果数据库出现了人为误操作,需要执行不完全恢复,这时候就得用以前备份的所有数据文件将数据版本回到以前,然后从那个起点开始应用日 志,直到出现人为故障之前的那一刻,但这时,scn并未到达最新的scn,而是到了之前的某个scn,在这一刻,人为故障还未发生。在完成recover .. until .. 的操作后,所有的数据文件通过应用日志到了统一的一点,但数据库暂时还不能正常打开,因为控制文件中记录的是最新的scn,与应用日志后的数据文件并不一 致,因此无法直接打开数据库回到原始的状态,必须通过resetlogs的方式强制控制文件、重做日志文件以及数据文件的scn一致,此时新打开的数据库 中第一个scn等于应用日志到的最后一条日志的scn号+1(在告警日志文件中可以看到RESETLOGS after incomplete recovery UNTIL CHANGE 145936 这样的信息,打开数据库后的scn则为145937)。数据库每次resetlogs之后,scn和日志序列号都被重置,因此每次resetlogs都会 产生一个新的incarnation,而incarnation的信息存储在控制文件中,在rman中可以通过list incarnation看到实体信息。
Oracle在控制文件中记录实体信息,一方面可以清楚的看到数据实体的发展过程(毕竟resetlogs 对数据库是一个具有较大影响的动作,必须能够清楚的查看到数据库生命期内出现的所有实体信息),另一方面,也可以通过reset database命令选择在rman中将要操作的数据库实体,进而将数据库恢复到某个以前实体对应的数据生命期,这个功能在以前8i的时候是不支持的,从 9i开始,可以重置实体到以前,使用resetlogs之前的备份进行数据库恢复。

Rman跨resetlogs版本恢复

RMAN> startup nomount;

RMAN> sql 'alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
--因为rman默认以环境变量来读取时间格式,与sqlplus的固定格式不同,所以,此处要设定时间格式变量。
RMAN> restore controlfile from autobackup until time '2009-03-10 18:15:00';
注意,仍然需要适当的还原控制文件。
RMAN> alter database mount;
RMAN> restore database;
RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> recover database until time '2009-03-10 18:15:00';

 

此时,出现以下错误:

RMAN-03002: recover 命令 (在 03/10/2009 19:21:19 上) 失败
RMAN-20207: UNTIL TIME 或 RECOVERY WINDOW 在 RESETLOGS 时间之前

 

20207 错误:默认的认为until time或RECOVERY WINDOW的时间不能早于resetlogs的时间. 既然resetlogs了,就不认识之前的归档日志信息了。把之前的归档日志排除在可供恢复的选择之外了。这只是默认的行为,可能处于节省系统资源的考 虑,毕竟resetlogs之前的数据再利用可能很小。

 

其解决可按以下方法处理:

1.找到数据库的当前incarnation号:

RMAN> list incarnation of database "test";

数据库原型列表
DB 关键字  Inc 关键字 DB 名  DB ID            STATUS  重置 SCN  重置时间
------- ------- -------- ---------------- --- ---------- ----------
1       1       TEST     1978860036       PARENT  1          30-8月 -05
2       2       TEST     1978860036       PARENT  534907     05-3月 -09
3       3       TEST     1978860036       PARENT  762990     10-3月 -09
4       4       TEST     1978860036       PARENT  764885     10-3月 -09
5       5       TEST     1978860036       PARENT  765443     10-3月 -09
6       6       TEST     1978860036       PARENT  767488     10-3月 -09
7       7       TEST     1978860036       PARENT  771807     10-3月 -09
8       8       TEST     1978860036       PARENT  774320     10-3月 -09
9       9       TEST     1978860036       PARENT  779541     10-3月 -09
10      10      TEST     1978860036       PARENT  782000     10-3月 -09
11      11      TEST     1978860036       PARENT  783792     10-3月 -09
12      12      TEST     1978860036       CURRENT 801599     10-3月 -09  --此行原型(incarnation)号状态为current,即当前

 
所以,数据库的前一个(resetlogs之前)原型号为11.

我们重新启动数据库到mount状态(因为需要知道是重置哪个库,所以要挂载)

 

2.重置数据库到前一个原型(注意:此时的控制文件已经在前面的步骤中,还原到了适当的时间点。实际上,我们应该在nomount前还原控制文件)

RMAN> reset database to incarnation 11;

将数据库重置为原型 11

RMAN> sql "alter session set nls_date_format=''yyyy-mm-dd hh24:mi:ss''";
RMAN> restore database;
RMAN> recover database until time '2009-03-10 18:15:00';
RMAN> alter database open resetlogs;  (此时,数据库的incarnation编号将再次上涨)

数据库正常打开

 

参考至:http://www.linuxidc.com/Linux/2011-09/42737.htm

本文原创,转载请注明出处、作者

如有错误,欢迎指正

邮箱:czmcj@163.com

0
1
分享到:
评论

相关推荐

    Incarnation

    Incarnation

    Spring 实践(Spring in Practice).pdf版本

    In this respect, Spring is like JEE and even its earlier J2EE incarnation. Spring’s approach—based on POJOs, dependency injection, and support for a wide variety of third-party libraries—proved to...

    SQL in Nutshell ed1

    Since its first incarnation in the 1970s, Structured Query Language (SQL) has been developed hand in hand with the information boom, and as a result, is the most widely used database manipulation ...

    Concurrent Programming in Mac OS X and iOS with Grand Central Dispatch

    To Steven Paul Jobs: From Mac OS’s very first incarnation, to the present one, wherein the legacy of NeXTSTEP still lives, his relationship with Apple is forever entrenched in OS X (and iOS)....

    Beginning ios 5 development

    So, you want to write iPhone, iPod touch, and iPad... With the release of iOS 5, and the latest incarnation of the iOS software development kit (SDK), things have only gotten better and more interesting.

    【6】Going deeper with convolutions.pdf

    One particular incarnation used in our submission for ILSVRC14 is called GoogLeNet, a 22 layers deep network, the quality of which is assessed in the context of classification and detection.

    DS306_v1.3.pdf CiA Draft Standard 306

    The usage of devices in a communication network requires configuration of ...concrete incarnation of a device configuration. The Module Data Sheet describes modules of devices with a modular structure.

    Going Deeper with Convolutions

    One particular incarnation used in our submission for ILSVRC14 is called GoogLeNet, a 22 layers deep network, the quality of which is assessed in the context of classification and detection

    Windows程序设计英文版

    As you probably know, Windows 98 is the latest incarnation of the graphical operating system that has become the de facto standard for IBM-compatible personal computers built around 32-bit Intel ...

    Inside ASP.NET Web Matrix

    In its latest incarnation, ASP.NET, it provides a complete solution for building almost any type of interactive user interface, as well as for implementing extensive back-end processing operations...

    umi-project:只是带来Linux来创造更美好的世界-开源

    MI可能是“ Maths Infos”,“ Mission Impossible”,“ Micro Imagination”,“ Museum Incarnation”,...,“ Mandela Ideologie”,...,“ MagneIsapèt”:),...; 但实际上是在Linux中,在Debian中,在...

    Knowledge Graphs.pdf

    modern incarnation of the phrase stems from the 2012 announcement of the Google Knowledge Graph [458], followed by further announcements of the development of knowledge graphs by Airbnb [82], Amazon ...

    php 开发入门

    PHP5 is the latest incarnation of PHP (PHP: Hypertext Preprocessor)—a programming language devised by Rasmus Lerdorf in 1994 for building dynamic, interactive Web sites. Since then, it's been ...

    中小企业品牌策略 英文

    Brand and Brand Strategy Views on SMEs.In marketing terms, the "brand" is the symbolic incarnation of everything associated with a product or service.This article has pointed out the value of brand ...

    Java Program Design: Principles, Polymorphism, and Patterns

    The design of a simplified banking program is introduced in chapter 1 in a non-object-oriented incarnation and the example is carried through all chapters. You can see the object orientation develop ...

    程序设计语言第四版(英文版)

    Knowledge of these core features and of their incarnation in today's languages is a basic foundation to be an effective programmer and to better understand computer science today.

    MMX-密码学的数学基础-英文版-Jeffrey+Hoffstein.pdf

    modern incarnation of the ancient art of codes and ciphers. Underlying the birth of modern cryptography is a great deal of fascinating mathematics, some of which has been developed for cryptographic ...

    Social Machines

    This book introduces the reader to the pitfalls and promises of artificial intelligence (AI) in its modern incarnation and the growing trend of systems to “reach off the Web” into the real world....

    eBook Visual C#2010 Step by Step

    The latest incarnation of the language, C# 4.0, provides further enhancements that improve its interoperability with other languages and technologies. These features include support for named and ...

Global site tag (gtag.js) - Google Analytics