歸檔模式下,使用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 a50SYS@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.shrman 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 sysdbaConnected.
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中使用的恢復語句如下
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 sysdbaSYS@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的值.
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 sysdbaSYS@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時的日誌
######################################################
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
###########################################################
###########################################################
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 非歸檔模式下停庫備份與恢復模式
- rman 非歸檔模式下open庫備份與mount恢復模式
- 備份&恢復之四:非歸檔模式下的備份與恢復模式
- RMAN備份、恢復實驗室 之 備份篇 【歸檔模式】模式
- 【備份恢復】歸檔模式下丟失系統關鍵資料檔案 利用RMAN備份恢復模式
- rman恢復--歸檔模式有備份,丟失資料檔案的恢復模式
- rman恢復--歸檔模式無備份,丟失資料檔案的恢復模式
- 無備份恢復(歸檔模式)模式
- dg丟失歸檔,使用rman增量備份恢復
- 備份與恢復:用rman方式基於日誌序列的不完全恢復
- Oracle RMAN 不完全恢復(只有資料檔案備份,丟失歸檔日誌備份)Oracle
- 備份與恢復:用user模式基於日誌序列的不完全恢復模式
- Rman Crosscheck刪除失效歸檔-備份恢復ROS
- 基於歸檔的冷備份恢復
- rman datafile恢復(歸檔模式)模式
- RMAN備份及恢復歸檔日誌的語法
- 【備份恢復】非歸檔模式下丟失任意資料檔案 恢復操作模式
- 基於非歸檔的冷備份恢復
- 基於歸檔的熱備份完全恢復
- RMAN資料庫恢復 之歸檔模式有(無)備份-丟失資料檔案的恢復資料庫模式
- 【備份與恢復】控制檔案的恢復(不完全恢復)
- 12 使用RMAN備份和恢復檔案
- 備份&恢復之八:RMAN備份歸檔模式下損壞(丟失)多個資料檔案,進行整個資料庫的恢復模式資料庫
- 用冷備份+歸檔日誌執行不完全恢復一例
- 歸檔模式,恢復沒有備份的資料檔案模式
- 使用logmnr,在RMAN備份檔案中恢復備份的歸檔日誌檔案進行分析
- 【備份恢復】noarchive模式下使用增量備份恢復資料庫Hive模式資料庫
- 歸檔模式下,offline表空間備份與恢復模式
- 【備份與恢復】使用Flashback Database(不完全恢復)Database
- rman備份恢復-rman恢復資料檔案測試
- RMAN備份恢復之歸檔日誌對BLOCKRECOVER的影響BloC
- 恢復之非歸檔模式下資料庫非正常關閉的備份與恢復模式資料庫
- 恢復之非歸檔模式下的恢復模式
- RMAN備份恢復之控制檔案的恢復(三)
- RMAN備份恢復之控制檔案的恢復(二)
- RMAN備份恢復之控制檔案的恢復(一)
- RMAN基於備份控制檔案恢復失敗
- RMAN恢復(rman只備份資料庫,但不備份歸檔,歸檔透過簡單的rsync或scp來傳送到異地備份)資料庫