Oracle 基於 RMAN 的不完全恢復(incomplete recovery by RMAN)
引用自:https://blog.csdn.net/leshami/article/details/9253867
Oracle 資料庫可以實現資料庫不完全恢復與完全恢復。完全恢復是將資料庫恢復到最新時刻,也就是無損恢復,保證資料庫無丟失的恢復。而不完全恢復則是根據需要特意將資料庫恢復到某個過去的特定時間點或特定的SCN以及特定的Sequence。我們可以通過基於使用者管理的不完全恢復實現,也可以通過基於RMAN方式來實現。本文主要描述是基於RMAN的不完全恢復的幾種情形並給出示例。有關資料庫備份恢復,RMAN備份恢復的概念與實戰可以參考文章尾部給出的連結。
一、不完全恢復的步驟
a、關閉資料庫並備份資料庫(以防止恢復失敗)
b、啟動資料庫到mount 狀態
c、還原資料庫
d、將資料庫恢復至某個時間點、序列、或系統改變號
e、使用RESETLOGS關鍵字開啟資料庫
二、不完全恢復的幾種型別
Type of Recovery Function
------------------- ----------------------------
Time-based recovery Recovers the data up to a specified point in time.
Cancel-based recovery Recovers until you issue the CANCEL statement (not available when using Recovery Manager).
Change-based recovery Recovers until the specified SCN.
Log sequence recovery Recovers until the specified log sequence number (only available when using Recovery Manager).
三、RMAN不完全恢復的主要操作命令
a、基於TIME 引數不完全恢復
run {
shutdown immediate;
startup mount;
set until time "to_date('20130705 10:09:53','yyyymmdd hh24:mi:ss')";
restore database;
recover database;
alter database open resetlogs;
}
b、基於SCN 引數不完全恢復
run {
shutdown immediate;
startup mount;
set until scn 3400;
restore database;
recover database;
alter database open resetlogs;
}
c、基於SEQUENCE 引數不完全恢復:
run {
shutdown immediate;
startup mount;
set until sequence 12903;
restore database;
recover database;
alter database open resetlogs;
}
四、演示RMAN不完全恢復
1、準備環境
--->首先備份資料庫
[[email protected] ~]$ export ORACLE_SID=oradb
[[email protected] ~]$ more rman_full.rcv
run{
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
crosscheck archivelog all;
delete noprompt expired archivelog all;
backup database format '/u02/rman/full_%d_%U' tag=full_bak
plus archivelog format '/u02/rman/arch_%d_%U' tag=arch;
release channel ch1;
release channel ch2;
}
[[email protected] ~]$ rman target / cmdfile=/home/oracle/rman_full.rcv log=/home/oracle/rman_full.log
RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11>
--下面是產生的備份檔案
[[email protected] ~]$ ls -hltr /u02/rman
total 1.1G
-rw-r----- 1 oracle asmadmin 31M Jul 5 09:44 arch_ORADB_03odvgv2_1_1
-rw-r----- 1 oracle asmadmin 595M Jul 5 09:45 full_ORADB_04odvgv7_1_1
-rw-r----- 1 oracle asmadmin 490M Jul 5 09:45 full_ORADB_05odvgv7_1_1
-rw-r----- 1 oracle asmadmin 12K Jul 5 09:46 arch_ORADB_06odvh30_1_1
--演示環境
SQL> select * from v$version where rownum<2;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
SQL> conn scott/tiger;
Connected.
-->下面的查詢得到當前已產生的歸檔日誌
SQL> SELECT name,sequence# seq#,status,completion_time FROM v$archived_log;
NAME SEQ# S COMPLETION_TIME
---------------------------------------------------------- ---- - -----------------
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_26_8xd97058_.arc 26 A 20130705 09:44:01
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc 27 A 20130705 09:46:08
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc 28 A 20130705 10:03:36
-->建立測試用表並插入記錄
10:07:01 SQL> create table t2(id varchar2(10), dt varchar2(20));
10:07:57 SQL> insert into t2 select 'Robinson',to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
10:08:15 SQL> commit;
10:08:18 SQL> alter system archive log current; -->對當前日誌進行歸檔
-->下面的查詢可知產生新的歸檔日誌29
10:08:28 SQL> SELECT name,sequence# seq#,status,completion_time FROM v$archived_log where sequence#>=28;
NAME SEQ# S COMPLETION_TIME
------------------------------------------------------------ ---- - -----------------
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc 28 A 20130705 10:03:36
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc 29 A 20130705 10:08:23
-->應證歸檔日誌中包含記錄Robinson
10:09:53 SQL> ho strings /u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc | grep "Robinson"
Robinson
--->第二次插入記錄
10:10:48 SQL> insert into t2 select 'Jackson',to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
10:11:27 SQL> commit;
10:11:30 SQL> alter system archive log current;
10:11:47 SQL> SELECT name,sequence# seq#,status,completion_time FROM v$archived_log where sequence#>=28;
NAME SEQ# S COMPLETION_TIME
---------------------------------------------------------- ---- - -----------------
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc 28 A 20130705 10:03:36
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc 29 A 20130705 10:08:23
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc 30 A 20130705 10:11:47
10:12:17 SQL> ho strings /u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc | grep "Jackson"
Jackson
-->檢視當前資料庫的SCN
10:12:34 SQL> select name,current_scn from v$database;
NAME CURRENT_SCN
------------------------------ -----------
ORADB 1365679
--->第三次插入記錄
10:15:07 SQL> insert into t2 select 'Winson',to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
10:15:47 SQL> commit;
10:21:18 SQL> alter system switch logfile;
--->第四次插入記錄
10:22:53 SQL> insert into t2 select 'LastRecord',to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
10:23:44 SQL> commit;
10:23:47 SQL> select * from t2;
ID DT
---------- --------------------
Robinson 20130705 10:08:15
Jackson 20130705 10:11:27
Winson 20130705 10:15:47
LastRecord 20130705 10:23:44
10:23:52 SQL> alter system switch logfile;
-->下面是最終的歸檔日誌情況
10:24:00 SQL> SELECT name,sequence# seq#,status,completion_time FROM v$archived_log where sequence#>=28;
NAME SEQ# S COMPLETION_TIME
------------------------------------------------------------ ---- - -----------------
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc 28 A 20130705 10:03:36
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc 29 A 20130705 10:08:23
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc 30 A 20130705 10:11:47
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc 31 A 20130705 10:21:53
/u02/DB/oradb/arch/2013_07_05/o1_mf_1_32_8xdcl0rx_.arc 32 A 20130705 10:24:00
10:24:12 SQL> ho strings /u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc | grep "Winson"
Winson
--->最後一次插入記錄
10:25:16 SQL> insert into t2 select 'Completed',to_char(sysdate,'yyyymmdd hh24:mi:ss') from dual;
10:26:20 SQL> commit;
-->此時資料庫當前的redo log並沒有歸檔,因此插入的資料位於聯機日誌
10:27:40 SQL> ho strings /u02/DB/oradb/redo/redo03.log | grep "Completed"
Completed
--->下面列出完成的記錄與日誌對照關係
SQL> select * from t2;
ID DT 對應的歸檔日誌 對應的sequence
---------- -------------------- ------------------------ --------------
Robinson 20130705 10:08:15 o1_mf_1_29_8xdbnqx9_.arc 29
Jackson 20130705 10:11:27 o1_mf_1_30_8xdbv338_.arc 30
Winson 20130705 10:15:47 o1_mf_1_31_8xdcg1wc_.arc 31
LastRecord 20130705 10:23:44 o1_mf_1_32_8xdcl0rx_.arc 32
Completed 20130705 10:26:20 redo03.log
2、實施不完全恢復
a、基於時間點的不完全恢復
[[email protected] ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jul 5 10:28:53 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORADB (DBID=2557712192)
RMAN> run{
2> shutdown immediate;
3> startup mount;
4> set until time "to_date('20130705 10:09:53','yyyymmdd hh24:mi:ss')";
5> restore database;
6> recover database;
7> }
using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 263639040 bytes
executing command: SET until clause
Starting restore at 20130705 10:33:36
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 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 /u02/DB/oradb/oradata/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u02/DB/oradb/oradata/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /u02/rman/full_ORADB_04odvgv7_1_1
channel ORA_DISK_1: piece handle=/u02/rman/full_ORADB_04odvgv7_1_1 tag=FULL_BAK
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 /u02/DB/oradb/oradata/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u02/DB/oradb/oradata/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u02/DB/oradb/oradata/example01.dbf
channel ORA_DISK_1: reading from backup piece /u02/rman/full_ORADB_05odvgv7_1_1
channel ORA_DISK_1: piece handle=/u02/rman/full_ORADB_05odvgv7_1_1 tag=FULL_BAK
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45 --->完成資料檔案還原
Finished restore at 20130705 10:35:28
Starting recover at 20130705 10:35:29 --->啟動資料恢復
using channel ORA_DISK_1
starting media recovery
---->下面提示歸檔日誌已經存在,是由於我們備份歸檔日誌後並沒有對其清除
archived log for thread 1 with sequence 27 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc
archived log for thread 1 with sequence 28 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc
archived log for thread 1 with sequence 29 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc
archived log for thread 1 with sequence 30 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc thread=1 sequence=27 --->列出日誌對應的sequence
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc thread=1 sequence=28
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc thread=1 sequence=29
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc thread=1 sequence=30
media recovery complete, elapsed time: 00:00:09 --->介質恢復完成,可以看到介質恢復,日誌apply到了30(不包含sequence 30的內容)
Finished recover at 20130705 10:35:42 --->完成恢復
RMAN> alter database open resetlogs; --->手動open resetlogs
database opened
RMAN> host;
[[email protected] ~]$ more query_t2.sh
#!/bin/bash
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export ORACLE_SID=oradb
sqlplus -S /nolog <<EOF
connect scott/tiger
select * from scott.t2;
exit;
EOF
exit
-->驗證結果,記錄Robinson已經被恢復
[[email protected] ~]$ ./query_t2.sh
ID DT
---------- --------------------
Robinson 20130705 10:08:15
[[email protected] ~]$ exit
exit
host command complete
-->新的incarnation已經被產生,為3
RMAN> list incarnation;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 ORADB 2557712192 PARENT 1 20090813 23:00:48
2 2 ORADB 2557712192 PARENT 754488 20130111 17:37:07
3 3 ORADB 2557712192 CURRENT 1365530 20130705 10:37:15
b、基於SCN的不完全恢復
RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> reset database to incarnation 2; --->在此需要reset incarnation
database reset to incarnation 2
RMAN> run{
2> set until scn 1365679;
3> restore database;
4> recover database;
5> alter database open resetlogs;}
executing command: SET until clause
Starting restore at 20130705 11:01:14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
......................
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 20130705 11:03:05
Starting recover at 20130705 11:03:06
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 27 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc
.............................
archived log for thread 1 with sequence 31 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc thread=1 sequence=27
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc thread=1 sequence=28
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc thread=1 sequence=29
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc thread=1 sequence=30 --->該日誌包含記錄Jackson
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc thread=1 sequence=31
media recovery complete, elapsed time: 00:00:10 --->此時apply到了31(不包含sequence 31的內容)
Finished recover at 20130705 11:03:19
database opened
RMAN> host;
-->驗證結果,記錄Jackson已經被恢復
[[email protected] ~]$ ./query_t2.sh
ID DT
---------- --------------------
Robinson 20130705 10:08:15
Jackson 20130705 10:11:27
c、基於sequence的不完全恢復
RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> reset database to incarnation 2;
RMAN> run{
2> set until sequence 32;
3> restore database;
4> recover database;
5> alter database open resetlogs;}
-- Author : Robinson
-- Blog : http://blog.csdn.net/robinson_0612
executing command: SET until clause
Starting restore at 05-JUL-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
...................
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 05-JUL-13
Starting recover at 05-JUL-13
using channel ORA_DISK_1
starting media recovery
...................................
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc thread=1 sequence=30
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc thread=1 sequence=31 --->此時也是apply到了31
media recovery complete, elapsed time: 00:00:07 --->我們指定了sequence為32(但不包含sequence 32)
Finished recover at 05-JUL-13
database opened
RMAN> host;
Recovery Manager complete.
-->驗證結果,記錄Winson已經被恢復
[[email protected] ~]$ ./query_t2.sh
ID DT
---------- --------------------
Robinson 20130705 10:08:15
Jackson 20130705 10:11:27
Winson 20130705 10:15:47
d、恢復到最近時刻
-->此處的恢復到最近(新)時刻,也就是我們希望恢復最後的記錄"Completed"
-->通常情況下,我們恢復到故障點為完全恢復,此時也可以說是做完全恢復
-->但是由於我們對資料庫作了不完全恢復,因此此時即使是做完全恢復,仍然為不完全恢復,見下面的示例
RMAN> shutdown immediate;
RMAN> startup mount;
RMAN> reset database to incarnation 2;
RMAN> run{
2> restore database;
3> recover database;
4> alter database open;}
Starting restore at 05-JUL-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
...........................
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 05-JUL-13
Starting recover at 05-JUL-13
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 27 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc
......................
archived log for thread 1 with sequence 33 is already on disk as file /u02/DB/oradb/arch/2013_07_05/o1_mf_1_33_8xddbvsc_.arc
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_27_8xd9c0f0_.arc thread=1 sequence=27
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_28_8xdbcrht_.arc thread=1 sequence=28
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc thread=1 sequence=29
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc thread=1 sequence=30
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_31_8xdcg1wc_.arc thread=1 sequence=31
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_32_8xdcl0rx_.arc thread=1 sequence=32
archived log file name=/u02/DB/oradb/arch/2013_07_05/o1_mf_1_33_8xddbvsc_.arc thread=1 sequence=33
unable to find archived log
archived log thread=1 sequence=34
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 07/05/2013 11:27:48
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 34 and starting SCN of 1367222
--可以看到,資料庫被apply到了sequence為33的歸檔日誌,現在資料庫尋找sequence為34為SCN為1367222的歸檔日誌
--細心的朋友可能會發現,我們之前僅僅歸檔到32,那sequence為33的歸檔日誌從而而來呢,應該是系統自動產生了一次歸檔
--但這裡我的歸檔日誌大小為50MB,因此也不可能是由於redo log滿而產生歸檔
--檢視alert日誌
[[email protected] trace]$ tail -1280 alert_oradb.log | more
Media Recovery Log /u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc
Fri Jul 05 10:35:41 2013
ORA-279 signalled during: alter database recover logfile '/u02/DB/oradb/arch/2013_07_05/o1_mf_1_29_8xdbnqx9_.arc'...
alter database recover logfile '/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc'
Media Recovery Log /u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc
Incomplete Recovery applied until change 1365529 time 07/05/2013 10:09:59
Media Recovery Complete (oradb) --->提示介質恢復完成
Completed: alter database recover logfile '/u02/DB/oradb/arch/2013_07_05/o1_mf_1_30_8xdbv338_.arc'
Fri Jul 05 10:37:15 2013
alter database open resetlogs --->執行open resetlogs
Archived Log entry 8 added for thread 1 sequence 33 ID 0x98733640 dest 1: --->這個地方是關鍵
RESETLOGS after incomplete recovery UNTIL CHANGE 1365529
Resetting resetlogs activation ID 2557687360 (0x98733640)
Errors in file /u01/app/oracle/diag/rdbms/oradb/oradb/trace/oradb_ora_30772.trc:
ORA-00367: checksum error in log file header --->下面伴隨一堆重置日誌檔案前的ORA校驗錯誤
ORA-00322: log 1 of thread 1 is not current copy
ORA-00312: online log 1 thread 1: '/u02/DB/oradb/redo/redo01.log'
Fri Jul 05 10:37:18 2013
Errors in file /u01/app/oracle/diag/rdbms/oradb/oradb/trace/oradb_m000_30963.trc:
ORA-00316: log 1 of thread 1, type 0 in header is not log file
ORA-00312: online log 1 thread 1: '/u02/DB/oradb/redo/redo01.log'
Errors in file /u01/app/oracle/diag/rdbms/oradb/oradb/trace/oradb_ora_30772.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: '/u02/DB/oradb/redo/redo02.log'
Errors in file /u01/app/oracle/diag/rdbms/oradb/oradb/trace/oradb_m000_30963.trc:
ORA-00316: log 2 of thread 1, type 0 in header is not log file
ORA-00312: online log 2 thread 1: '/u02/DB/oradb/redo/redo02.log'
Errors in file /u01/app/oracle/diag/rdbms/oradb/oradb/trace/oradb_ora_30772.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: '/u02/DB/oradb/redo/redo03.log'
Errors in file /u01/app/oracle/diag/rdbms/oradb/oradb/trace/oradb_m000_30963.trc:
ORA-00316: log 3 of thread 1, type 0 in header is not log file
ORA-00312: online log 3 thread 1: '/u02/DB/oradb/redo/redo03.log'
Fri Jul 05 10:37:23 2013
Setting recovery target incarnation to 3 --->設定新的incarnation
-->下面的歸檔日誌的產生時間與alert日誌中的時間相吻合
[[email protected] 2013_07_05]$ ls -al --full-time o1_mf_1_33_8xddbvsc_.arc
-rw-r----- 1 oracle asmadmin 259584 2013-07-05 10:37:15.000000000 +0800 o1_mf_1_33_8xddbvsc_.arc
-->查詢檢視也可以得到在RESETLOGS時產生了歸檔日誌
SQL> col name format a60 wrap
SQL> SELECT name,sequence# seq#,status,completion_time,end_of_redo_type eof_type from v$archived_log where sequence#=33;
NAME SEQ# S COMPLETION_TIME EOF_TYPE
------------------------------------------------------------ ---------- - ----------------- ----------
/u02/database/oradb/flash_recovery_area/ORADB/archivelog/201 33 A 20130705 10:37:15 RESETLOGS
3_07_05/o1_mf_1_33_8xddbvsc_.arc
-->驗證結果
SQL> alter database open resetlogs;
Database altered.
SQL> select * from scott.t2;
ID DT
---------- --------------------
Robinson 20130705 10:08:15
Jackson 20130705 10:11:27
Winson 20130705 10:15:47
LastRecord 20130705 10:23:44
Completed 20130705 10:26:20
五、小結
a、RMAN支援基於TIME,SCN,SEQUENCE引數的不完全恢復,不支援基於CANCEL的不完全恢復
b、所有實施了不完全恢復的資料庫都需要以open resetlogs方式開啟資料庫,且同時伴隨一個新的incarnation產生
c、不完全恢復之後即使是恢復到故障點,或者說想做完全恢復,都只能是做不完全恢復到最近時刻
d、不完全恢復後再次恢復到最新時刻,新的incarnation變為CURRENT狀態,中間的incarnation為ORPHAN狀態
e、首次不完全恢復以open resetlogs方式開啟資料庫時,未歸檔的聯機日誌被歸檔
f、注意until子句的用法。until子句是到什麼什麼,不包括,是一個非半閉包的形式
g、生產環境建議不完全恢復前後備份資料庫
相關參考
Oracle 冷備份
Oracle 熱備份
Oracle 備份恢復概念
Oracle 例項恢復
Oracle 基於使用者管理恢復的處理
SYSTEM 表空間管理及備份恢復
SYSAUX表空間管理及恢復
Oracle 基於備份控制檔案的恢復(unsing backup controlfile)
RMAN 概述及其體系結構
RMAN 配置、監控與管理
RMAN 備份詳解
RMAN 還原與恢復
RMAN catalog 的建立和使用
基於catalog 建立RMAN儲存指令碼
基於catalog 的RMAN 備份與恢復
RMAN 備份路徑困惑
自定義 RMAN 顯示的日期時間格式
只讀表空間的備份與恢復
Oracle 基於使用者管理的不完全恢復
理解 using backup controlfile
使用RMAN實現異機備份恢復(WIN平臺)
使用RMAN遷移檔案系統資料庫到ASM
基於Linux下 Oracle 備份策略(RMAN)
Linux 下RMAN備份shell指令碼
使用RMAN遷移資料庫到異機
RMAN 提示符下執行SQL語句