热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

RMAN基于SCN或特定时间点的不完全恢复

---------------------------------------byacdante--------------------------------------前提&#


---------------------------------------by acdante--------------------------------------

前提:

数据库已开启归档:

SQL> archive log list

Database log mode           Archive Mode

Automatic archival            Enabled

Archive destination           /u01/app/oracle/product/11.2.0/db_1/dbs/arch

Oldest online log sequence     23

Next log sequence to archive   25

Current log sequence        25

SQL>

 

一、         RMAN备份脚本

Level0备份脚本

vim rman_bak_level0.sh 

#! /bin/bash 

export ORACLE_BASE=$ORACEL_BASE

export ORACLE_HOME=$ORACLE_HOME 

export PATH=$ORACLE_HOME/bin:$PATH 

export ORACLE_SID=orcl 

export NLS_LANG='AMERICAN_AMERICA.ZHS16GBK' 

rman target / <

run{ 

allocate channel c1 type disk; 

allocate channel c2 type disk; 

backup incremental level 0 database format &#39;/u01/backup/level0_%d_%s_%p_%u.bak&#39;; 

sql &#39;alter system archive log current&#39;; 

backup archivelog all delete input format &#39;/u01/backup/archivelog_%d_%s_%p_%u.bak&#39;; 

crosscheck backup; 

delete noprompt obsolete; 

release channel c1; 

release channel c2; 

>>EOF 

 

 

Level1备份脚本

vim rman_bak_level1.sh  

#! /bin/bash 

export ORACLE_BASE&#61;$ORACLE_BASE 

export ORACLE_HOME&#61;$ORACLE_HOME 

export PATH&#61;$ORACLE_HOME/bin:$PATH 

export ORACLE_SID&#61;orcl

export NLS_LANG&#61;&#39;AMERICAN_AMERICA.ZHS16GBK&#39; 

rman target / <

run{ 

allocate channel c1 type disk; 

allocate channel c2 type disk; 

backup incremental level 1 database format &#39;/u01/backup/level1_%d_%s_%p_%u.bak&#39;; 

sql &#39;alter system archive log current&#39;; 

backup archivelog all delete input format &#39;/u01/backup/archivelog_%d_%s_%p_%u.bak&#39;; 

crosscheck backup; 

delete noprompt obsolete; 

release channel c1; 

release channel c2; 

>>EOF 

 

Level2备份脚本

vim rman_bak_level2.sh 

#! /bin/bash 

export ORACLE_SID&#61;orcl 

export NLS_LANG&#61;&#39;AMERICAN_AMERICA.ZHS16GBK&#39; 

$ORACLE_HOME/bin/rman target / <

run{ 

allocate channel c1 type disk; 

allocate channel c2 type disk; 

backup incremental level 2 database format &#39;/u01/backup/level2_%d_%s_%p_%u.bak&#39;; 

sql &#39;alter system archive log current&#39;; 

backup archivelog all delete input format &#39;/u01/backup/archivelog_%d_%s_%p_%u.bak&#39;; 

crosscheck backup; 

delete noprompt obsolete; 

release channel c1; 

release channel c2; 

>>EOF 

 

 

二、备份数据库测试

1.执行0级备份

  [oracle&#64;oracle scripts]$ ll

total 12

-rwxr--r-- 1 oracle oinstall 600 Oct 18 12:46 rman_bak_level0.sh

-rwxr--r-- 1 oracle oinstall 600 Oct 18 12:46 rman_bak_level1.sh

-rwxr--r-- 1 oracle oinstall 532 Oct 18 12:46 rman_bak_level2.sh

[oracle&#64;oracle scripts]$

 [oracle&#64;oracle scripts]$ sh rman_bak_level0.sh

   查看备份日志&#xff0c;成功备份

7de41e925431ca8d901f3118abd910cf0cb67045

2.创建表level0

SQL> create table level0 as select * from scott.emp;

 

Table created.

eb3520d42bb7bc862c838e9e010d8043bab04ec6

3.执行1级增量备份

[oracle&#64;oracle scripts]$ date

Wed Oct 18 12:58:19 CST 2017

[oracle&#64;oracle scripts]$ sh rman_bak_level1.sh

查看备份日志&#xff0c;成功备份

0f9b2f287bc2c69b5db23a7f5dc1b7a45958cf7c

4.创建表level1

SQL> create table level1 as select * from scott.dept;

Table created.

SQL> !date

Wed Oct 18 13:01:15 CST 2017

5.执行2级增量备份

[oracle&#64;oracle scripts]$ sh rman_bak_level2.sh

查看备份日志&#xff0c;成功备份

deb37f438b1f24217e184797a7dfc64427180644

2c25d96cebe89fc19025836f9eb7f3d0f859148a

三、模拟数据丢失

1. truncate table level0

SQL> truncate table level0;

Table truncated.

 

由于truncate删除表不经过回收站&#xff0c;又没有闪回&#xff0c;在本地进行恢复&#xff0c;这里需要根据备份来进行不完全恢复。我这里TRUNCATE表LEVEL0。

2.关闭数据库&#xff0c;启动到MOUNT

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  836976640 bytes

Fixed Size                  1348160 bytes

Variable Size           629149120 bytes

Database Buffers     201326592 bytes

Redo Buffers             5152768 bytes

Database mounted.

四、恢复到指定SCN

1.查看最近一次备份片的scn

查看最近一次备份片的scn&#xff0c;指定恢复到scn

RMAN>list backup of database;

2c4e0b4426ad6e3c6262f64013cf64d845481470

 

恢复到最近一次数据库备份的SCN---1290386

即可恢复level0表

2.数据库启动至MOUNT状态

将数据库关闭&#xff0c;确认数据库启动到MOUNT状态

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  836976640 bytes

Fixed Size                  1348160 bytes

Variable Size           629149120 bytes

Database Buffers     201326592 bytes

Redo Buffers             5152768 bytes

Database mounted.

 

 

3.RESTORE DATABASE

[oracle&#64;oracle backup]$ rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Oct 18 13:22:34 2017

 

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

 

connected to target database: ORCL (DBID&#61;1484770744, not open)

 

RMAN> restore database;

 

Starting restore at 18-OCT-17

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID&#61;1147 device type&#61;DISK

 

skipping datafile 9; already restored to file /u01/app/oracle/oradata/orcl/ts13-01.dbf

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf

channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/orcl/ts3.dbf

channel ORA_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/orcl/ts14-01.dbf

channel ORA_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/orcl/test01.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/level0_ORCL_1_1_01shapil.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/level0_ORCL_1_1_01shapil.bak tag&#61;TAG20171018T124925

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:05

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf

channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/ts201.dbf

channel ORA_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/ts1.dbf

channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/orcl/ts2.dbf

channel ORA_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/orcl/test1.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/level0_ORCL_2_1_02shapil.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/level0_ORCL_2_1_02shapil.bak tag&#61;TAG20171018T124925

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:06

Finished restore at 18-OCT-17

 

RMAN>

 

 

4.RECOVER DATABASE

 RMAN> recover database until scn&#61;1290386;

RMAN>  recover database until scn&#61;1290386;

 

Starting recover at 18-OCT-17

using channel ORA_DISK_1

datafile 9 not processed because file is read-only

channel ORA_DISK_1: starting incremental datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

destination for restore of datafile 00002: /u01/app/oracle/oradata/orcl/sysaux01.dbf

destination for restore of datafile 00004: /u01/app/oracle/oradata/orcl/users01.dbf

destination for restore of datafile 00005: /u01/app/oracle/oradata/orcl/ts201.dbf

destination for restore of datafile 00006: /u01/app/oracle/oradata/orcl/ts1.dbf

destination for restore of datafile 00007: /u01/app/oracle/oradata/orcl/ts2.dbf

destination for restore of datafile 00011: /u01/app/oracle/oradata/orcl/test1.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/level1_ORCL_9_1_09shaq3k.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/level1_ORCL_9_1_09shaq3k.bak tag&#61;TAG20171018T125827

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting incremental datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

destination for restore of datafile 00001: /u01/app/oracle/oradata/orcl/system01.dbf

destination for restore of datafile 00003: /u01/app/oracle/oradata/orcl/undotbs01.dbf

destination for restore of datafile 00008: /u01/app/oracle/oradata/orcl/ts3.dbf

destination for restore of datafile 00010: /u01/app/oracle/oradata/orcl/ts14-01.dbf

destination for restore of datafile 00012: /u01/app/oracle/oradata/orcl/test01.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/level1_ORCL_8_1_08shaq3k.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/level1_ORCL_8_1_08shaq3k.bak tag&#61;TAG20171018T125827

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting incremental datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

destination for restore of datafile 00001: /u01/app/oracle/oradata/orcl/system01.dbf

destination for restore of datafile 00003: /u01/app/oracle/oradata/orcl/undotbs01.dbf

destination for restore of datafile 00008: /u01/app/oracle/oradata/orcl/ts3.dbf

destination for restore of datafile 00010: /u01/app/oracle/oradata/orcl/ts14-01.dbf

destination for restore of datafile 00012: /u01/app/oracle/oradata/orcl/test01.dbf

channel ORA_DISK_1: reading from backup piece /u01/backup/level2_ORCL_14_1_0eshaqbs.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/level2_ORCL_14_1_0eshaqbs.bak tag&#61;TAG20171018T130252

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

 

starting media recovery

 

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread&#61;1 sequence&#61;27

channel ORA_DISK_1: reading from backup piece /u01/backup/archivelog_ORCL_12_1_0cshaq5t.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/archivelog_ORCL_12_1_0cshaq5t.bak tag&#61;TAG20171018T125941

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name&#61;/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_27_956990010.dbf thread&#61;1 sequence&#61;27

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread&#61;1 sequence&#61;28

channel ORA_DISK_1: reading from backup piece /u01/backup/archivelog_ORCL_13_1_0dshaq5t.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/archivelog_ORCL_13_1_0dshaq5t.bak tag&#61;TAG20171018T125941

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name&#61;/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_28_956990010.dbf thread&#61;1 sequence&#61;28

media recovery complete, elapsed time: 00:00:03

channel ORA_DISK_1: starting archived log restore to default destination

channel ORA_DISK_1: restoring archived log

archived log thread&#61;1 sequence&#61;29

channel ORA_DISK_1: reading from backup piece /u01/backup/archivelog_ORCL_18_1_0ishaqe8.bak

channel ORA_DISK_1: piece handle&#61;/u01/backup/archivelog_ORCL_18_1_0ishaqe8.bak tag&#61;TAG20171018T130408

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

Finished recover at 18-OCT-17

 

RMAN>

 

由于不完全恢复需要resetlog&#xff0c;所以进行resetlogs 启库

0590c62d89e2e7d50a00bf89975d9eb34d6bc144

 

如果不使用resetlogs参数&#xff0c;会出现如下报错&#xff1a;

6e5b472af8c01c80cd1c9ad78bcd93cef1b1b804

5.查看表level0已经恢复

 c3d9762d46c9766baba2d9bcb62834da1e7f66ce

五、恢复到指定时间点

确认需要恢复的时间点存在数据库备份&#xff0c;且备份集可用。

由于进行过两次增量备份&#xff0c;在level0全备后&#xff0c;创建了level0表&#xff0c;12:56分&#xff1b;在level1增量备份后&#xff0c;创建了level1表&#xff0c;时间为13:01分&#xff0c;此时&#xff0c;如果需要将数据库恢复到没有创建表level1之前&#xff0c;我们可以指定恢复到特定的时间点。

此时&#xff1a;两张表都存在

7dc19ed4e64b1bbef7cd2f4608a05cc01b581d7a

1.DROP TABLE

此时将level0表DROP删除&#xff0c;剩余level1表

ad18c5cb86f9b440675e4df0224a4601846d80eb

将数据库恢复到12:58分后&#xff0c;如果恢复成功&#xff0c;我们将只能看到level0表&#xff0c;而level1表将不存在。此时可实验恢复到指定时间点

2.数据库启动至MOUNT状态

SQL> conn / as sysdba

Connected.

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  836976640 bytes

Fixed Size                  1348160 bytes

Variable Size           629149120 bytes

Database Buffers     201326592 bytes

Redo Buffers             5152768 bytes

Database mounted.

 

 

3. RESET DATABASE INCARNATION

由于此前我们使用不完全恢复了数据库&#xff0c;且以resetlogs方式OPEN了数据库&#xff0c;此时&#xff0c;归档日志已经不可用&#xff0c;需要重置数据库状态到2。

4dacb8194ceab24fe2024ab44421e9945b9da30f

 

RMAN> reset database to incarnation 2;

 

database reset to incarnation 2

 

RMAN>

9f40f96bdff71bb45c10540fa1bcece74eb2b901

如果不进行此操作&#xff0c;在RESTORE数据库时会报错如下&#xff1a;

ad44deb9691c6f361b5b4be4b76be74a17cd896f

 

4.恢复脚本

[oracle&#64;oracle scripts]$ cat recover_data_by_time.sql

run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

sql &#39;alter session set nls_date_format&#61;"yyyy-mm-dd hh24:mi:ss"&#39;;

set until time &#61; &#39;2017-10-18 12:58:00&#39;;

restore database;

recover database;

alter database open resetlogs;

}

 

恢复到12:55分的话&#xff0c;level0和level1两张表都将不存在。

5.执行脚本恢复至指定时间点

RMAN> &#64;/home/oracle/scripts/recover_data_by_time.sql

 

RMAN> run

2> {

3> allocate channel c1 type disk;

4> allocate channel c2 type disk;

5> sql &#39;alter session set nls_date_format&#61;"yyyy-mm-dd hh24:mi:ss"&#39;;

6> set until time &#61; &#39;2017-10-18 12:58:00&#39;;

7> restore database;

8> recover database;

9> alter database open resetlogs;

10> }

allocated channel: c1

channel c1: SID&#61;1137 device type&#61;DISK

 

allocated channel: c2

channel c2: SID&#61;10 device type&#61;DISK

 

sql statement: alter session set nls_date_format&#61;"yyyy-mm-dd hh24:mi:ss"

 

executing command: SET until clause

 

Starting restore at 18-OCT-17

 

skipping datafile 9; already restored to file /u01/app/oracle/oradata/orcl/ts13-01.dbf

channel c1: starting datafile backup set restore

channel c1: specifying datafile(s) to restore from backup set

channel c1: restoring datafile 00001 to /u01/app/oracle/oradata/orcl/system01.dbf

channel c1: restoring datafile 00003 to /u01/app/oracle/oradata/orcl/undotbs01.dbf

channel c1: restoring datafile 00008 to /u01/app/oracle/oradata/orcl/ts3.dbf

channel c1: restoring datafile 00010 to /u01/app/oracle/oradata/orcl/ts14-01.dbf

channel c1: restoring datafile 00012 to /u01/app/oracle/oradata/orcl/test01.dbf

channel c1: reading from backup piece /u01/backup/level0_ORCL_1_1_01shapil.bak

channel c2: starting datafile backup set restore

channel c2: specifying datafile(s) to restore from backup set

channel c2: restoring datafile 00002 to /u01/app/oracle/oradata/orcl/sysaux01.dbf

channel c2: restoring datafile 00004 to /u01/app/oracle/oradata/orcl/users01.dbf

channel c2: restoring datafile 00005 to /u01/app/oracle/oradata/orcl/ts201.dbf

channel c2: restoring datafile 00006 to /u01/app/oracle/oradata/orcl/ts1.dbf

channel c2: restoring datafile 00007 to /u01/app/oracle/oradata/orcl/ts2.dbf

channel c2: restoring datafile 00011 to /u01/app/oracle/oradata/orcl/test1.dbf

channel c2: reading from backup piece /u01/backup/level0_ORCL_2_1_02shapil.bak

channel c1: piece handle&#61;/u01/backup/level0_ORCL_1_1_01shapil.bak tag&#61;TAG20171018T124925

channel c1: restored backup piece 1

channel c1: restore complete, elapsed time: 00:01:26

channel c2: piece handle&#61;/u01/backup/level0_ORCL_2_1_02shapil.bak tag&#61;TAG20171018T124925

channel c2: restored backup piece 1

channel c2: restore complete, elapsed time: 00:01:38

Finished restore at 18-OCT-17

 

Starting recover at 18-OCT-17

datafile 9 not processed because file is read-only

 

starting media recovery

 

archived log for thread 1 with sequence 25 is already on disk as file /u01/app/oracle/product/11.2.0/db_1/dbs/arch1_25_956990010.dbf

archived log for thread 1 with sequence 26 is already on disk as file /u01/app/oracle/product/11.2.0/db_1/dbs/arch1_26_956990010.dbf

archived log for thread 1 with sequence 27 is already on disk as file /u01/app/oracle/product/11.2.0/db_1/dbs/arch1_27_956990010.dbf

archived log file name&#61;/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_25_956990010.dbf thread&#61;1 sequence&#61;25

archived log file name&#61;/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_26_956990010.dbf thread&#61;1 sequence&#61;26

archived log file name&#61;/u01/app/oracle/product/11.2.0/db_1/dbs/arch1_27_956990010.dbf thread&#61;1 sequence&#61;27

media recovery complete, elapsed time: 00:00:04

Finished recover at 18-OCT-17

 

database opened

released channel: c1

released channel: c2

 

RMAN> **end-of-file**

 

RMAN>

6.验证数据恢复

此时查询数据库数据&#xff0c;可以看到level0表已经恢复&#xff0c;而level1数据表是不存在的&#xff0c;至此&#xff0c;数据库指定时间点恢复完成。

baf4b3e240c9de51b88b8f7400b5f6bc3f0c2f43

 

相关知识点

完全恢复

 -- 利用重做日志或增量备份将数据块恢复到最接近当前时间的时间点。之所以叫做完整恢复是由于Oracle应用了归档日志和联机重做日志中所有的修改。如果只是数据文件损坏&#xff0c;且存在备份及备份以来的所有归档日志文件&#xff0c;那么就能把数据库完全恢复到发生介质损坏的那个时间点。完全恢复分为数据库级别&#xff0c;数据文件级别以及表空间级别。

不完全恢复

-- 需要将数据库恢复到历史上某个时间点&#xff0c;或由于丢失了联机日志件或某个归档日志文件&#xff0c;或者使用了以前备份的控制文件进行恢复&#xff0c;进行的恢复叫做不完全恢复。 换句话说&#xff0c;恢复过程中不会应用备份产生后生成的所有的重

做日志(可能应用部分或不应用)。

 

通常出现下面的情况需要进行不完全恢复&#xff1a;

a. 几个或全部的联机重做日志文件损坏&#xff1b;

b.由于个别归档日志文件的丢失无法进行完整的恢复&#xff1b;

c. 用户操作造成的数据丢失&#xff0c;比如&#xff0c;用户误删除了一张表, 这时可进行不完全恢复将数据库恢复到误操作之前的时间点&#xff1b;

d. 丢失了当前的控制文件&#xff0c;必须使用备份的控制文件打开数据库。不过只要所有的归档日志文件和联机日志文件都在&#xff0c;仍然能够恢复所有的数据。

为了执行不完整介质恢复&#xff0c;必须使用恢复时间点以前的备份来还原数据文件&#xff0c;并在恢复完成后使用RESETLOG选项打开数据库。resetlogs会重置日志序列号(变为1)强制清空或重建REDO&#xff0c; noresetlogs则不会 。

------ 关系&#xff1a;

1. 不完全恢复必须使用resetlogs &#xff1b;

2. 使用resetlogs大多数情况下是做不完全恢复&#xff0c;但也可以做完全恢复(视丢失文件类型不同)&#xff1b;

3.noresetlogs 必须做完全恢复时使用&#xff0c;但完全恢复不一定都是noresetlogs;&#96;

4. 使用备份的控制文件需要使用using backup controlfile,使用using backup controlfile就需要使用resetlogs开启数据库&#xff1b;

5.使用resetlogs方式重建控制文件需要使用using backup controlfile,同上,需要使用resetlogs开启数据库&#xff1b;

6. 如果是以noresetlogs方式重建控制文件&#xff0c;不必要使用using backup controlfile&#xff0c;详细可以参考通过backup controlfile to trace 导出的脚本&#xff1b;(因为resetlogs重建控制文件是针对Use this only if online logs are damaged&#xff0c;而noresetlogs方式重建控制文件是针对the current versions of all online logs are available )

7. create controlfile resetlogs/noresetlogs 用noresetlogs重建控制文件时&#xff0c;控制文件中datafile Checkpoint SCN来自online logs中的current log头部&#xff0c;选择noresetlogs重建使得控制文件最新。如记录了最新的联机日志和日志序号。这个命令后介质恢复不是必需的。

- 用resetlogs重建控制文件时(一般是在线日志损坏时)&#xff0c;控制文件中datafile checkpoint SCN来自各数据文件头。

8. 使用备份的控制文件(using backup controlfile)则需要使用resetlogs方式打开数据库(当然不一定是不完全恢复,备份的控制文件不能自动进行完全恢复, 可c 手工apply日志进行完全恢复; 重新创建控制文件则可以自动进行完全恢复)&#xff1b;

9. 使用当前控制文件或noresetlogs方式重建控制文件来恢复&#xff0c;可以不需要resetlogs打开数据库&#xff1b;

备注&#xff1a; 备份的控制文件之所以不能自动进行完全恢复&#xff0c;是因为备份的控制文件的检查点SCN是比较旧的SCN, Oracle需要知道从哪个归档日志文件开始恢复&#xff0c;以及从这个归档日志文件的哪个位置开始恢复。存储在备份的控制文件中的日志序列号以及对应于控制文件检查点SCN的RBA (Redo Bytes Address)指出了从哪个归档文件开始以及从文件的哪个位置&#xff08;重做记录&#xff09;开始恢复。

 

incarnation

incarnation是Oracle10G新加入的新特性&#xff0c;用于跨越resetlogs的恢复。

当在做Media Recover的不完全恢复时&#xff0c;通过resetlogs打开库&#xff0c;则Incarnation表示这个数据库的特定的逻辑生存期。当作为DBA可能面临这样的还原&#xff1a;需要使用上次执行resetlogs命令打开数据库前生成的一个备份来进行还原数据库&#xff0c;或者可能需要还原到执行上一个resetlogs命令之前的时间点

 

f03916983d731457e4ace4dc207546b998d81255

 

借用askmaclean的理解&#xff1a;

如何理解Oracle中的incarnation概念&#xff1f;

 

小明 活到了90岁 这是incarnation A &#xff0c; 这个matrix 矩阵世界里的 root (or oracle)管理员 将 小明世界的时间节点回退到了小明20岁时(同时resetlogs)&#xff0c;由于神的能力还不足以让这个宇宙里的一切量子变化都保证和之前的那一次完全一样&#xff0c;所以这次回退节点里的小明 是incarnation B&#xff0c;最后incarnation B的小明也会活到90岁。

虽然最后2个小明都90岁了&#xff0c;但这2个小明并不是一样的 &#xff0c;他们都叫小明&#xff0c;但需要区别他们 所以一个叫incarnation A 另一个叫incarnation B。 在其他平行世界里可能还有其他 incarnation的小明&#xff0c;这取决于 root (or oracle)管理员的需求。

 

incarnation英文的翻印的“化身”&#xff0c;那在oracle里如何理解它呢&#xff1f;我理解为“数据库实体”&#xff08;一个数据库场景&#xff09;

数据库自从创建起就连续的发展&#xff0c;但经过不完全恢复后&#xff0c;数据库要重新设置起点&#xff0c;然后继续来连续的发展&#xff0c;而数据库

的连续性是通过SCN来保证的&#xff0c;在不完全恢复后&#xff0c;数据库的控制文件&#xff0c;保证重做日志文件和数据文件的scn是不一致的&#xff0c;所以

数据库要求通过resetlogs打开来他们的scn的同步一致。



推荐阅读
  • XNA 3.0 游戏编程:从 XML 文件加载数据
    本文介绍如何在 XNA 3.0 游戏项目中从 XML 文件加载数据。我们将探讨如何将 XML 数据序列化为二进制文件,并通过内容管道加载到游戏中。此外,还会涉及自定义类型读取器和写入器的实现。 ... [详细]
  • Hadoop入门与核心组件详解
    本文详细介绍了Hadoop的基础知识及其核心组件,包括HDFS、MapReduce和YARN。通过本文,读者可以全面了解Hadoop的生态系统及应用场景。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文探讨了Hive中内部表和外部表的区别及其在HDFS上的路径映射,详细解释了两者的创建、加载及删除操作,并提供了查看表详细信息的方法。通过对比这两种表类型,帮助读者理解如何更好地管理和保护数据。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 数据库内核开发入门 | 搭建研发环境的初步指南
    本课程将带你从零开始,逐步掌握数据库内核开发的基础知识和实践技能,重点介绍如何搭建OceanBase的开发环境。 ... [详细]
  • 本文详细介绍了如何使用 Yii2 的 GridView 组件在列表页面实现数据的直接编辑功能。通过具体的代码示例和步骤,帮助开发者快速掌握这一实用技巧。 ... [详细]
  • 本文深入探讨 MyBatis 中动态 SQL 的使用方法,包括 if/where、trim 自定义字符串截取规则、choose 分支选择、封装查询和修改条件的 where/set 标签、批量处理的 foreach 标签以及内置参数和 bind 的用法。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • 本文详细分析了Hive在启动过程中遇到的权限拒绝错误,并提供了多种解决方案,包括调整文件权限、用户组设置以及环境变量配置等。 ... [详细]
  • 深入探讨CPU虚拟化与KVM内存管理
    本文详细介绍了现代服务器架构中的CPU虚拟化技术,包括SMP、NUMA和MPP三种多处理器结构,并深入探讨了KVM的内存虚拟化机制。通过对比不同架构的特点和应用场景,帮助读者理解如何选择最适合的架构以优化性能。 ... [详细]
  • 解决JAX-WS动态客户端工厂弃用问题并迁移到XFire
    在处理Java项目中的JAR包冲突时,我们遇到了JaxWsDynamicClientFactory被弃用的问题,并成功将其迁移到org.codehaus.xfire.client。本文详细介绍了这一过程及解决方案。 ... [详细]
  • 本题通过将每个矩形视为一个节点,根据其相对位置构建拓扑图,并利用深度优先搜索(DFS)或状态压缩动态规划(DP)求解最小涂色次数。本文详细解析了该问题的建模思路与算法实现。 ... [详细]
author-avatar
漆黑中的萤火虫
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有