归档模式下,使用RMAN的同一备份两次用于不完全恢复

实验理论基础:

SCN的序列的递增性不随数据库的任何操作而改变,即使是RESETLOGS也如此。
RESETLOGS清除所有联机日志文件中未应用的重做记录,RESETLOGS只重置日志文件的序列号为1,但对SCN无影响,SCN仍按原序列递增。

在控制文件中保存resetlogs SCN和计数器,以便唯一地标识用RESETLOGS选项执行的每一次打开数据库的操作。
这个值被写进每个数据文件头以及重做日志文件。
如果重做日志文件的日志序列号与Oracle的要求值不相符,则在恢复中不能应用重做日志文件。
执行不完全恢复后,数据库要求日志序列号为1的日志文件,所以原来的日志序列中剩余的日志文件将不可用。
RESETLOGS操作创建数据库的新形体,即一个拥有从1开始的新的日志序列号流的数据库。

根据以上理论:SCN为顺序数据流,在数据库存在期间始终递增,而日志文件序列流也是递增序列,只不过会因RESETLOGS而重置为1,但日志文件序列流中的SCN序列流却保持递增不变
因此可以用RESETLOGS之前的归档日志流和RESETLOGS之后的归档日志流来连接和延续SCN序列流,这样就实现了用RESETLOGS之前的备份恢复RESETLOGS之后的数据。
前提是:

保证两股日志流(RESETLOGS之前的归档日志流和RESETLOGS之后的归档日志流)完整,并且有相应两股日志流的控制文件。

建议:在RESETLOGS前保证数据库以前备份的数据安全,在创建RESETLOGS之后的第一个一致性备份之前,一定不可删掉在RESETLOGS前创建的一致数据库备份

如空间足够,建议永久保留RESETLOGS前创建的一致数据库备份。

实验思路、步骤:

1.关库做备份--RMAN,记下SCN与时间,记录序号及REDO。
2.打开库,记下时间/SCN,删除一个用户,做基于时间点的不完全恢复。记录不完全恢复后的SCN,归档序号
3.在恢复后的库,记下时间/SCN,再删除一个用户,使用步骤1中备份可以对RESETLOS后的库再次做不完全恢复。
##########################################################################################################

第一步:关库做备份--RMAN,记录归档日志序号。

1.查询当前归档日志序号

SYS@bys1>col name for a50
SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log  order by recid desc) where rownum<5;
NAME                                                    RECID  SEQUENCE# S APPLIED
-------------------------------------------------- ---------- ---------- - ---------
/u01/archbys1/arc_1_31_829941492.arc                      120         31 A NO
/u01/archbys1/arc_1_30_829941492.arc                      119         30 A NO
/u01/archbys1/arc_1_29_829941492.arc                      118         29 A NO

/u01/archbys1/arc_1_28_829941492.arc                      117         28 A NO
BYS@bys1>select incarnation#,resetlogs_change#,resetlogs_time,prior_resetlogs_time,status,resetlogs_id from v$database_incarnation;后来补充-可以从此视图查出历次RESETLOGS情况
INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME      PRIOR_RESETLOGS_TIM STATUS  RESETLOGS_ID
------------ ----------------- ------------------- ------------------- ------- ------------
           1                 1 2009/08/13 23:00:48                     PARENT     694825248
           2            754488 2013/08/01 08:58:04 2009/08/13 23:00:48 PARENT     822301084
           3           2541692 2013/10/27 19:18:12 2013/08/01 08:58:04 PARENT     829941492
           4           3228984 2013/11/06 00:14:08 2013/10/27 19:18:12 PARENT     830736848
           5           3229505 2013/11/06 00:27:42 2013/11/06 00:14:08 CURRENT    830737662

2.关库并启动到 MOUNT,做全备备份

SYS@bys1>startup mount;
ORACLE instance started.
Total System Global Area  631914496 bytes
Fixed Size                  1338364 bytes
Variable Size             385876996 bytes
Database Buffers          239075328 bytes
Redo Buffers                5623808 bytes
SYS@bys1>exit

3.使用写好的备份脚本做全备备份--注意先用df -h确定备份的目录有足够空间。

[oracle@bys001 ~]$ cat fullback.sh
rman   log /home/oracle/backfull-`date +%Y%m%d-%H%M`.log <<EOF
connect target /;
run {
backup full tag 'bys001-full' database
format "/home/oracle/bys001full_%d_%t_%s"
plus archivelog
format "/home/oracle/bys001arch_%d_%t_%s"
delete all input;
}
exit

[oracle@bys001 ~]$ sh fullback.sh
RMAN> RMAN> 2> 3> 4> 5> 6> 7> RMAN>
[oracle@bys001 ~]$ sqlplus / as sysdba
SYS@bys1>alter database open;
Database altered.
###############
4.记录当前系统的SCN,并删除一个用户
SYS@bys1>select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SYS@bys1>select dbid,checkpoint_change# from v$database;
      DBID CHECKPOINT_CHANGE#
---------- ------------------
3957527513            3228508
SYS@bys1>col name for a40
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
     FILE# NAME                                     CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
         1 /u01/oradata/bys1/system01.dbf                      3228508 2013-11-05 23:51:15
         2 /u01/oradata/bys1/sysaux01.dbf                      3228508 2013-11-05 23:51:15
         3 /u01/oradata/bys1/undotbs01.dbf                     3228508 2013-11-05 23:51:15
         4 /u01/oradata/bys1/users01.dbf                       3228508 2013-11-05 23:51:15
         5 /u01/oradata/bys1/example01.dbf                     3228508 2013-11-05 23:51:15
         6 /u01/oradata/bys1/test1.dbf                         3228508 2013-11-05 23:51:15
SYS@bys1> select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
    GROUP#  SEQUENCE# STATUS           FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
         1         31 INACTIVE               3222825 2013/11/05:22:08:56          
          2         32 CURRENT                3228378 2013/11/05:23:38:08       可以看到当前REDO日志的序号是32
         3         30 INACTIVE               3218774 2013/11/05:22:00:30
SYS@bys1>set time on
23:55:34 SYS@bys1> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
                 3228983
23:55:35 SYS@bys1>conn test/test
Connected.
23:55:53 TEST@bys1>select * from cat;
TABLE_NAME                     TABLE_TYPE
------------------------------ -----------
TEST1                          SYNONYM
23:56:06 TEST@bys1>conn / as sysdba
Connected.
23:56:18 SYS@bys1>drop user test cascade;
User dropped.
删除用户完成
######################################################################

第二步:执行第一次不完全恢复

1.首先将库启动到MOUNT,然后基于SCN进行不完全恢复

23:57:19 @bys1>conn / as sysdba
Connected.
23:57:25 SYS@bys1>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
23:57:42 SYS@bys1> startup mount;
ORACLE instance started.

Total System Global Area  631914496 bytes
Fixed Size                  1338364 bytes
Variable Size             385876996 bytes
Database Buffers          239075328 bytes
Redo Buffers                5623808 bytes
Database mounted.

##############################

在RMAN中使用的恢复语句如下

restore database;
recover database until scn 3228983;
alter database open resetlogs;
################
RMAN> restore database;

Starting restore at 2013/11/06 00:08:56
using channel ORA_DISK_1

skipping datafile 3; already restored to file /u01/oradata/bys1/undotbs01.dbf
skipping datafile 4; already restored to file /u01/oradata/bys1/users01.dbf
skipping datafile 5; already restored to file /u01/oradata/bys1/example01.dbf
skipping datafile 6; already restored to file /u01/oradata/bys1/test1.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/oradata/bys1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/bys1/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/bys001full_BYS1_830735101_8
channel ORA_DISK_1: piece handle=/home/oracle/bys001full_BYS1_830735101_8 tag=BYS001-FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:13
Finished restore at 2013/11/06 00:13:09

RMAN> recover database until scn 3228983;

Starting recover at 2013/11/06 00:13:48
using channel ORA_DISK_1

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

Finished recover at 2013/11/06 00:13:51

RMAN> alter database open;     使用了不完整恢复,所以打开库时要用RESETLOGS,不然报错。

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/06/2013 00:14:02
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


RMAN> alter database open resetlogs;
database opened
RMAN>
##########################################################

第三步:登陆系统查看数据是否恢复,并再次删除用户

[oracle@bys001 ~]$ sqlplus / as sysdba
SYS@bys1>select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE

SYS@bys1>col name for a40

BYS@bys1>show parameter archive_form
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_format                   string      arc_%t_%s_%r.arc

初始化参数LOG_ARCHIVE_FORMAT用于指定归档日志的文件名格式,设置该初始化参数时,可以指定以下匹配符:
%s: 日志序列号   %S: 日志序列号(带有前导0)    %t: 重做线程编号.%T: 重做线程编号(带有前导0)   %a: 活动ID   %d: 数据库ID号   %r RESETLOGS的值.

SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log  order by recid desc) where rownum<5;
NAME                                          RECID  SEQUENCE# S APPLIED
---------------------------------------- ---------- ---------- - ---------
/u01/archbys1/arc_1_32_829941492.arc            121         32 A NO         这里忘了手动做一次归档,所以看不出归档日志名中日志序列号被重置为1
                                                120         31 D NO
                                                119         30 D NO
                                                118         29 D NO
SYS@bys1>select dbid,checkpoint_change# from v$database;
      DBID CHECKPOINT_CHANGE#
---------- ------------------
3957527513            3228987
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
     FILE# NAME                                     CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
         1 /u01/oradata/bys1/system01.dbf                       32289872013-11-06 00:14:27
         2 /u01/oradata/bys1/sysaux01.dbf                      3228987 2013-11-06 00:14:27
         3 /u01/oradata/bys1/undotbs01.dbf                     3228987 2013-11-06 00:14:27
         4 /u01/oradata/bys1/users01.dbf                       3228987 2013-11-06 00:14:27
         5 /u01/oradata/bys1/example01.dbf                     3228987 2013-11-06 00:14:27
         6 /u01/oradata/bys1/test1.dbf                         3228987 2013-11-06 00:14:27
SYS@bys1>select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
    GROUP#  SEQUENCE# STATUS           FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
         1          1 CURRENT                3228984 2013/11/06:00:14:08      可以看到RESETLOGS后的REDO日志的序号是1
         2          0 UNUSED                       0
         3          0 UNUSED                       0
SYS@bys1>conn test/test
Connected.
TEST@bys1>set time on
00:16:34 TEST@bys1>select * from cat;
TABLE_NAME                     TABLE_TYPE
------------------------------ -----------
TEST1                          SYNONYM
00:16:39 TEST@bys1>conn / as sysdba
Connected.
00:16:45 SYS@bys1> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
                 3229504
00:16:57 SYS@bys1> drop user test cascade;
User dropped.
00:17:12 SYS@bys1>conn test/test
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
00:17:17 @bys1>conn / as sysdba
Connected.
00:17:21 SYS@bys1>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
00:17:40 SYS@bys1>startup mount;
ORACLE instance started.

Total System Global Area  631914496 bytes
Fixed Size                  1338364 bytes
Variable Size             385876996 bytes
Database Buffers          239075328 bytes
Redo Buffers                5623808 bytes
Database mounted.
############################################################

第四步;使用第一步中的RMA备份,进行恢复到第二次不完全恢复

restore database;
recover database until scn 3229504;
alter database open resetlogs;
#####
[oracle@bys001 ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Wed Nov 6 00:20:06 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: BYS1 (DBID=3957527513, not open)

RMAN> restore database;

Starting restore at 2013/11/06 00:21:06
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

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/oradata/bys1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/bys1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/bys1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/bys1/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oradata/bys1/example01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /u01/oradata/bys1/test1.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/bys001full_BYS1_830735101_8
channel ORA_DISK_1: piece handle=/home/oracle/bys001full_BYS1_830735101_8 tag=BYS001-FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:26
Finished restore at 2013/11/06 00:25:34

RMAN> recover database until scn 3229504;

Starting recover at 2013/11/06 00:27:05
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 32 is already on disk as file /u01/archbys1/arc_1_32_829941492.arc
archived log file name=/u01/archbys1/arc_1_32_829941492.arc thread=1 sequence=32
media recovery complete, elapsed time: 00:00:01
Finished recover at 2013/11/06 00:27:08

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 11/06/2013 00:27:34
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open resetlogs;
database opened
#####################################################################

第五步:登陆系统并查看数据已经恢复

[oracle@bys001 ~]$ sqlplus / as sysdba
SYS@bys1>col name for a40
SYS@bys1>select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log  order by recid desc) where rownum<5;
NAME                                          RECID  SEQUENCE# S APPLIED
---------------------------------------- ---------- ---------- - ---------
/u01/archbys1/arc_1_1_830736848.arc             122          1 A NO                可以看到归档日志文件名中的序号像REDO一样被重置为1,在本文最后的日志中也有显现。
/u01/archbys1/arc_1_32_829941492.arc            121         32 A NO

                                                120         31 D NO
                                                119         30 D NO
SYS@bys1>select dbid,checkpoint_change# from v$database;
      DBID CHECKPOINT_CHANGE#
---------- ------------------
3957527513            3229508
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
     FILE# NAME                                     CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
         1 /u01/oradata/bys1/system01.dbf                      3229508 2013-11-06 00:27:58
         2 /u01/oradata/bys1/sysaux01.dbf                      3229508 2013-11-06 00:27:58
         3 /u01/oradata/bys1/undotbs01.dbf                     3229508 2013-11-06 00:27:58
         4 /u01/oradata/bys1/users01.dbf                       3229508 2013-11-06 00:27:58
         5 /u01/oradata/bys1/example01.dbf                     3229508 2013-11-06 00:27:58
         6 /u01/oradata/bys1/test1.dbf                         3229508 2013-11-06 00:27:58
SYS@bys1>select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
    GROUP#  SEQUENCE# STATUS           FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
         1          1 CURRENT                3229505 2013/11/06:00:27:42
         2          0 UNUSED                       0
         3          0 UNUSED                       0
SYS@bys1>conn test/test
Connected.
TEST@bys1>select * from cat;
TABLE_NAME                     TABLE_TYPE
------------------------------ -----------
TEST1                          SYNONYM

TEST@bys1>conn / as sysdba
Connected.
SYS@bys1>select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------
                 3230066
SYS@bys1>alter system switch logfile;
System altered.
SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log  order by recid desc) where rownum<5;

NAME                                          RECID  SEQUENCE# S APPLIED
---------------------------------------- ---------- ---------- - ---------
/u01/archbys1/arc_1_1_830737662.arc             123          1 A NO
/u01/archbys1/arc_1_1_830736848.arc             122          1 A NO
/u01/archbys1/arc_1_32_829941492.arc            121         32 A NO
                                                120         31 D NO
SYS@bys1>select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
    GROUP#  SEQUENCE# STATUS           FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
         1          1 ACTIVE                 3229505 2013/11/06:00:27:42
         2          2 CURRENT                3230073 2013/11/06:00:32:49
         3          0 UNUSED                       0
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
     FILE# NAME                                     CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
         1 /u01/oradata/bys1/system01.dbf                      3229508 2013-11-06 00:27:58
         2 /u01/oradata/bys1/sysaux01.dbf                      3229508 2013-11-06 00:27:58
         3 /u01/oradata/bys1/undotbs01.dbf                     3229508 2013-11-06 00:27:58
         4 /u01/oradata/bys1/users01.dbf                       3229508 2013-11-06 00:27:58
         5 /u01/oradata/bys1/example01.dbf                     3229508 2013-11-06 00:27:58

         6 /u01/oradata/bys1/test1.dbf                         3229508 2013-11-06 00:27:58

附日志:

为节约篇幅,日志中不重要的信息已经删除

Tue Nov 05 23:39:53 2013
ALTER DATABASE   MOUNT
Successful mount of redo thread 1, with mount id 3965984777
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: ALTER DATABASE   MOUNT
###############################################
MOUNT后,使用RMAN进行备份
################################################
Tue Nov 05 23:51:25 2013
Completed: alter database open
###########################################################################################
备份后重新打开数据库
##################################################################
Tue Nov 05 23:57:37 2013
ARCH shutting down
ARC0: Archival stopped
Thread 1 closed at log sequence 32
Successful close of redo thread 1
Completed: ALTER DATABASE CLOSE NORMAL
ALTER DATABASE DISMOUNT
Completed: ALTER DATABASE DISMOUNT

Tue Nov 05 23:57:42 2013
Instance shutdown complete
######################################################
第一次删除用户,并关库。关库时:Thread 1 closed at log sequence 32
#######################################################
Lost write protection disabled
Completed: ALTER DATABASE   MOUNT
##########################################################
打开库到MOUNT状态,准备进行RMAN下的不完全恢复。

######################################################
Wed Nov 06 00:04:34 2013
Full restore complete of datafile 6 /u01/oradata/bys1/test1.dbf.  Elapsed time: 0:00:01
  checkpoint is 3228505     第一步关库进行备份时的检查点是3228505
Full restore complete of datafile 4 /u01/oradata/bys1/users01.dbf.  Elapsed time: 0:00:04
  checkpoint is 3228505
  last deallocation scn is 3050819
Wed Nov 06 00:05:07 2013
Full restore complete of datafile 3 /u01/oradata/bys1/undotbs01.dbf.  Elapsed time: 0:00:28
  checkpoint is 3228505
  last deallocation scn is 3211783
  Undo Optimization current scn is 3225591
Wed Nov 06 00:05:25 2013
Full restore complete of datafile 5 /u01/oradata/bys1/example01.dbf.  Elapsed time: 0:00:51
  checkpoint is 3228505
  last deallocation scn is 2915000

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥

下面可以看到对SYSTEM及SYSAUX的RESTORE过程:

Wed Nov 06 00:08:56 2013
Hex dump of (file 1, block 1) in trace file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc
Corrupt block relative dba: 0x00400001 (file 1, block 1)
Bad header found during kcvxfh v8
Data in bad block:
 type: 0 format: 2 rdba: 0x00400001
 last change scn: 0x0000.00000000 seq: 0x1 flg: 0x05
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x00000001
 check value in block header: 0xa741
 computed block checksum: 0x0
Reading datafile '/u01/oradata/bys1/system01.dbf' for corruption at rdba: 0x00400001 (file 1, block 1)
Reread (file 1, block 1) found same corrupt data
Hex dump of (file 2, block 1) in trace file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc
Corrupt block relative dba: 0x00800001 (file 2, block 1)
Bad header found during kcvxfh v8
Data in bad block:
 type: 0 format: 2 rdba: 0x00800001
 last change scn: 0x0000.00000000 seq: 0x1 flg: 0x05
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x00000001
 check value in block header: 0xa781
 computed block checksum: 0x0
Reading datafile '/u01/oradata/bys1/sysaux01.dbf' for corruption at rdba: 0x00800001 (file 2, block 1)
Reread (file 2, block 1) found same corrupt data
Hex dump of (file 1, block 1) in trace file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc
Corrupt block relative dba: 0x00400001 (file 1, block 1)
Bad header found during kcvxfh v8
Data in bad block:
 type: 0 format: 2 rdba: 0x00400001
 last change scn: 0x0000.00000000 seq: 0x1 flg: 0x05
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x00000001
 check value in block header: 0xa741
 computed block checksum: 0x0
Reading datafile '/u01/oradata/bys1/system01.dbf' for corruption at rdba: 0x00400001 (file 1, block 1)
Reread (file 1, block 1) found same corrupt data
Hex dump of (file 2, block 1) in trace file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc
Corrupt block relative dba: 0x00800001 (file 2, block 1)
Bad header found during kcvxfh v8
Data in bad block:
 type: 0 format: 2 rdba: 0x00800001
 last change scn: 0x0000.00000000 seq: 0x1 flg: 0x05
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x00000001
 check value in block header: 0xa781
 computed block checksum: 0x0
Reading datafile '/u01/oradata/bys1/sysaux01.dbf' for corruption at rdba: 0x00800001 (file 2, block 1)
Reread (file 2, block 1) found same corrupt data
Wed Nov 06 00:12:58 2013
Full restore complete of datafile 2 /u01/oradata/bys1/sysaux01.dbf.  Elapsed time: 0:03:56
  checkpoint is 3228505
  last deallocation scn is 3222373
Full restore complete of datafile 1 /u01/oradata/bys1/system01.dbf.  Elapsed time: 0:04:01
  checkpoint is 3228505
  last deallocation scn is 825711
  Undo Optimization current scn is 3225591

Wed Nov 06 00:13:48 2013
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6       完成恢复的文件号列表1 , 2 , 3 , 4 , 5 , 6 
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6
 ######################################################
 以上即是restore database;语句执行时的ALERT日志。下面看RECOVER时的日志
 ######################################################

alter database recover if needed
 start until change 3228983

Media Recovery Start
Serial Media Recovery started
Recovery of Online Redo Log: Thread 1 Group 2 Seq 32Reading mem 0
  Mem# 0: /u01/oradata/bys1/redo02.log
Incomplete Recovery applied until change 3228983 time 11/05/2013 23:55:37       从这一句也可以看到,不完整恢复到的SCN及时间。
Media Recovery Complete (bys1)
Completed: alter database recover if needed
 start until change 3228983
 ####################################################
recover database until scn 3228983;语句执行时的ALERT日志

  ####################################################
Wed Nov 06 00:14:02 2013
alter database open
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
ORA-1589 signalled during: alter database open...
 ####################################################
以上是alter database open;语句打开库时的报错
  ####################################################

alter database open resetlogs
Archived Log entry 121 added for thread 1 sequence 32ID 0xec572000 dest 1:
RESETLOGS after incomplete recovery UNTIL CHANGE 3228983
Resetting resetlogs activation ID 3965132800 (0xec572000)
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 1 of thread 1 is not current copy
ORA-00312: online log 1 thread 1: '/u01/oradata/bys1/redo01.log'
Wed Nov 06 00:14:10 2013
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_m000_24513.trc:
ORA-00316: log 1 of thread 1, type 0 in header is not log file    日志 (用于线程 )头部中的类型不是日志文件
ORA-00312: online log 1 thread 1: '/u01/oradata/bys1/redo01.log'
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_m000_24513.trc:
ORA-00322: log 2 of thread 1 is not current copy
ORA-00312: online log 2 thread 1: '/u01/oradata/bys1/redo02.log'
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_m000_24513.trc:
ORA-00322: log 3 of thread 1 is not current copy
ORA-00312: online log 3 thread 1: '/u01/oradata/bys1/redo03.log'
Checker run found 12 new persistent data failures
Wed Nov 06 00:14:16 2013
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 2 of thread 1 is not current copy
ORA-00312: online log 2 thread 1: '/u01/oradata/bys1/redo02.log'
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24483.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 3 of thread 1 is not current copy
ORA-00312: online log 3 thread 1: '/u01/oradata/bys1/redo03.log'
……
Thread 1 opened at log sequence 1             可以看到,当前REDO的序号在RESETLOS后被重置为了1.
  Current log# 1 seq# 1 mem# 0: /u01/oradata/bys1/redo01.log
Successful open of redo thread 1

ARC1: Becoming the 'no FAL' ARCH
ARC1: Becoming the 'no SRL' ARCH
ARC2: Becoming the heartbeat ARCH

LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete

Completed: alter database open resetlogs
 ####################################################
以上是alter database open resetlogs语句执行时的ALERT日志
####################################################

Wed Nov 06 00:17:40 2013
Instance shutdown complete
Wed Nov 06 00:17:40 2013
Instance shutdown complete
Wed Nov 06 00:18:16 2013
ALTER DATABASE   MOUNT
Successful mount of redo thread 1, with mount id 3965999368
Database mounted in Exclusive Mode
Lost write protection disabled
Completed: ALTER DATABASE   MOUNT
##########################################################
在打开的库中又删除了已经恢复的用户,并关库;再打开库到MOUNT状态,准备进行RMAN下的不完全恢复
######################################################
Wed Nov 06 00:21:11 2013
Full restore complete of datafile 6 /u01/oradata/bys1/test1.dbf.  Elapsed time: 0:00:01
  checkpoint is 3228505
Full restore complete of datafile 4 /u01/oradata/bys1/users01.dbf.  Elapsed time: 0:00:03
  checkpoint is 3228505
  last deallocation scn is 3050819
Wed Nov 06 00:21:55 2013
Full restore complete of datafile 3 /u01/oradata/bys1/undotbs01.dbf.  Elapsed time: 0:00:46
  checkpoint is 3228505
  last deallocation scn is 3211783
  Undo Optimization current scn is 3225591
Wed Nov 06 00:22:07 2013
Full restore complete of datafile 5 /u01/oradata/bys1/example01.dbf.  Elapsed time: 0:00:57
  checkpoint is 3228505
  last deallocation scn is 2915000
Wed Nov 06 00:25:29 2013
Full restore complete of datafile 2 /u01/oradata/bys1/sysaux01.dbf.  Elapsed time: 0:04:16
  checkpoint is 3228505
  last deallocation scn is 3222373
Full restore complete of datafile 1 /u01/oradata/bys1/system01.dbf.  Elapsed time: 0:04:21
  checkpoint is 3228505
  last deallocation scn is 825711
  Undo Optimization current scn is 3225591
Wed Nov 06 00:27:06 2013
alter database recover datafile list clear
Completed: alter database recover datafile list clear
alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6
Completed: alter database recover datafile list
 1 , 2 , 3 , 4 , 5 , 6

 ######################################################
 以上即是第二次restore database;语句执行时的ALERT日志。下面看RECOVER时的日志
 ######################################################
alter database recover if needed
 start until change 3229504
Media Recovery Start
Serial Media Recovery started
Media Recovery start incarnation depth : 1, target inc# : 4, irscn : 3228983
ORA-279 signalled during: alter database recover if needed
 start until change 3229504
...
alter database recover logfile '/u01/archbys1/arc_1_32_829941492.arc'
Media Recovery Log /u01/archbys1/arc_1_32_829941492.arc
Recovery of Online Redo Log: Thread 1 Group 1 Seq 1 Reading mem 0
  Mem# 0: /u01/oradata/bys1/redo01.log
Incomplete Recovery applied until change 3229504 time 11/06/2013 00:17:09
Media Recovery Complete (bys1)
Completed: alter database recover logfile '/u01/archbys1/arc_1_32_829941492.arc'

 ####################################################
recover database until scn 3229504语句执行时的ALERT日志

  ####################################################

alter database open resetlogs
Archived Log entry 122 added for thread 1 sequence 1 ID 0xec64a53c dest 1:
RESETLOGS after incomplete recovery UNTIL CHANGE 3229504
Resetting resetlogs activation ID 3966018876 (0xec64a53c)
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24755.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 1 of thread 1 is not current copy
ORA-00312: online log 1 thread 1: '/u01/oradata/bys1/redo01.log'
Wed Nov 06 00:27:44 2013
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_m000_24780.trc:
ORA-00316: log 1 of thread 1, type 0 in header is not log file
ORA-00312: online log 1 thread 1: '/u01/oradata/bys1/redo01.log'
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_m000_24780.trc:
ORA-00322: log 2 of thread 1 is not current copy
ORA-00312: online log 2 thread 1: '/u01/oradata/bys1/redo02.log'
Wed Nov 06 00:27:47 2013
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24755.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 2 of thread 1 is not current copy
ORA-00312: online log 2 thread 1: '/u01/oradata/bys1/redo02.log'
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_m000_24780.trc:
ORA-00322: log 3 of thread 1 is not current copy
ORA-00312: online log 3 thread 1: '/u01/oradata/bys1/redo03.log'
Errors in file /u01/diag/rdbms/bys1/bys1/trace/bys1_ora_24755.trc:
ORA-00367: checksum error in log file header
ORA-00322: log 3 of thread 1 is not current copy
ORA-00312: online log 3 thread 1: '/u01/oradata/bys1/redo03.log'


Wed Nov 06 00:27:57 2013
Setting recovery target incarnation to 5
Wed Nov 06 00:27:57 2013
Assigning activation ID 3965999368 (0xec645908)
LGWR: STARTING ARCH PROCESSES


Wed Nov 06 00:27:57 2013
ARC0 started with pid=22, OS id=24788
ARC0: Archival started
LGWR: STARTING ARCH PROCESSES COMPLETE
ARC0: STARTING ARCH PROCESSES


Wed Nov 06 00:27:58 2013
ARC1 started with pid=23, OS id=24793
Thread 1 opened at log sequence 1      可以看到,当前REDO的序号在RESETLOS后被重置为了1.
  Current log# 1 seq# 1 mem# 0: /u01/oradata/bys1/redo01.log
Successful open of redo thread 1

……
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
ARC3: Archival started
ARC0: STARTING ARCH PROCESSES COMPLETE
Completed: alter database open resetlogs

###########################################################

下面是第二次RESETLOGS后打开库后的日志:

###########################################################
Wed Nov 06 00:32:49 2013
Thread 1 advanced to log sequence 2 (LGWR switch)   
  Current log# 2 seq# 2 mem# 0: /u01/oradata/bys1/redo02.log
Wed Nov 06 00:32:49 2013
Archived Log entry 123 added for thread 1 sequence 1 ID 0xec645908 dest 1:    可以看到归档的entry 没有被重置为1,这里对应的是查询v$archived_log 中的sequence#号,是连续的,未因RESETLOGS而改变。

你可能感兴趣的:(rman,不完全恢复,resetlogs)