热门标签 | 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的同步一致。



推荐阅读
  • 请看|间隔时间_Postgresql 主从复制 ... [详细]
  • 本文介绍如何使用MFC和ADO技术调用SQL Server中的存储过程,以查询指定小区在特定时间段内的通话统计数据。通过用户界面选择小区ID、开始时间和结束时间,系统将计算并展示小时级的通话量、拥塞率及半速率通话比例。 ... [详细]
  • 云函数与数据库API实现增删查改的对比
    本文将深入探讨使用云函数和数据库API实现数据操作(增删查改)的不同方法,通过详细的代码示例帮助读者更好地理解和掌握这些技术。文章不仅提供代码实现,还解释了每种方法的特点和适用场景。 ... [详细]
  • ElasticSearch 集群监控与优化
    本文详细介绍了如何有效地监控 ElasticSearch 集群,涵盖了关键性能指标、集群健康状况、统计信息以及内存和垃圾回收的监控方法。 ... [详细]
  • 探讨ChatGPT在法律和版权方面的潜在风险及影响,分析其作为内容创造工具的合法性和合规性。 ... [详细]
  • PHP 过滤器详解
    本文深入探讨了 PHP 中的过滤器机制,包括常见的 $_SERVER 变量、filter_has_var() 函数、filter_id() 函数、filter_input() 函数及其数组形式、filter_list() 函数以及 filter_var() 和其数组形式。同时,详细介绍了各种过滤器的用途和用法。 ... [详细]
  • 本文探讨了如何在 F# Interactive (FSI) 中通过 AddPrinter 和 AddPrintTransformer 方法自定义类型(尤其是集合类型)的输出格式,提供了详细的指南和示例代码。 ... [详细]
  • 本文将详细介绍如何在没有显示器的情况下,使用Raspberry Pi Imager为树莓派4B安装操作系统,并进行基本配置,包括设置SSH、WiFi连接以及更新软件源。 ... [详细]
  • 主调|大侠_重温C++ ... [详细]
  • 在尝试从数据库获取设置的过程中,遇到了一个致命错误:Fatal error: Call to a member function bind_param() on boolean。本文将详细分析该错误的原因,并提供解决方案。 ... [详细]
  • CentOS 7.6环境下Prometheus与Grafana的集成部署指南
    本文旨在提供一套详细的步骤,指导读者如何在CentOS 7.6操作系统上成功安装和配置Prometheus 2.17.1及Grafana 6.7.2-1,实现高效的数据监控与可视化。 ... [详细]
  • 序列化与反序列化是数据处理中的重要技术,特别是在网络通信和数据存储中。它们允许将复杂的数据结构转换为可传输或存储的格式,再从这些格式恢复原始数据。本文探讨了序列化与反序列化的基本概念,以及它们在不同协议模型中的角色。 ... [详细]
  • MongoDB的核心特性与架构解析
    本文深入探讨了MongoDB的核心特性,包括其强大的查询语言、灵活的文档模型以及高效的索引机制。此外,还详细介绍了MongoDB的体系结构,解释了其文档、集合和数据库的层次关系,并对比了MongoDB与传统关系型数据库(如MySQL)的逻辑结构。 ... [详细]
  • CentOS 6.8 上安装 Oracle 10.2.0.1 的常见问题及解决方案
    本文记录了在 CentOS 6.8 系统上安装 Oracle 10.2.0.1 数据库时遇到的问题及解决方法,包括依赖库缺失、操作系统版本不兼容、用户权限不足等问题。 ... [详细]
  • 本文详细介绍了 Kubernetes 集群管理工具 kubectl 的基本使用方法,涵盖了一系列常用的命令及其应用场景,旨在帮助初学者快速掌握 kubectl 的基本操作。 ... [详细]
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社区 版权所有