問題解決:
先要弄清楚alter database open resetlogs是什麼意思,為什麼要用resetlogs打開資料庫,這個指令發出後oracle都做了什麼?
alter database open resetlogs是要打開資料時,重置重做日志,即将重做日志的sequence置零,為什麼要重置重做日志呢?
不完全恢複後,原來的online redo log裡面包含的是未做恢複前的資料,而這些資料對于恢複後的資料庫不再有效,是以資料庫會要求在Open之前先對online redo log的sequence置零。
Resetlogs指令表示一個資料庫邏輯生存期的結束和另一個資料庫邏輯生存期的開始,每次使用Resetlogs指令的時候,SCN不會被重置,不過oracle會重置日志序列号,而且會重置聯機重做日志内容。
Oracle把這個資料庫邏輯生存期稱為incarnation
每次使用resetlogs打開資料庫,就會使incarnation + 1,也就是産生一個新的incarnation;
如果想要恢複到之前incarnation的scn/time,就需要先恢複到之前的incarnation;
對于上面的案例,具體就是先要
Reset database to incarnation 2;
再做不完全恢複試試
--------------------------我執行一次rman之後,再次執行這個腳本--------------
- RMAN> @/home/oracle/testrman.rman
- RMAN> run{
- 2> allocate channel c1 type disk;
- 3> allocate channel c2 type disk;
- 4> sql 'alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"';
- 5> set until time='2012-08-16 17:30:00';
- 6> restore database;
- 7> recover database;
- 8> sql 'alter database open resetlogs';}
- allocated channel: c1
- channel c1: sid=145 devtype=DISK
- allocated channel: c2
- channel c2: sid=146 devtype=DISK
- sql statement: alter session set nls_date_format="yyyy-mm-dd hh24:mi:ss"
- executing command: SET until clause
- released channel: c1
- released channel: c2
- RMAN-00571: ===========================================================
- RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
- RMAN-00571: ===========================================================
- RMAN-03002: failure of set command at 08/16/2012 21:01:11
- RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time
- RMAN> **end-of-file**
http://hi.baidu.com/heuet032606/item/4553f3c1d8f8b22c47d5c07c
http://blog.csdn.net/leishifei/article/details/6430057
關于alter database open resetlogs及incarnation的一點了解
不完全恢複隻能做一次嗎?
采用rman的預設設定,對資料庫進行了backup database備份,進行了一些操作後,然後直接關閉啟動到mount狀态
RMAN> run{
2> set until time "to_date('2010-10-16 23:14:42','yyyy-mm-dd hh24:mi:ss')";
3> restore database;
4> recover database;
5> }
executing command: SET until clause
Starting restore at 17-OCT-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/oradata/denver/system01.dbf
restoring datafile 00002 to /oracle/oradata/denver/undotbs01.dbf
restoring datafile 00003 to /oracle/oradata/denver/sysaux01.dbf
restoring datafile 00004 to /oracle/oradata/denver/users01.dbf
restoring datafile 00005 to /oracle/oradata/denver/example01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/flash_recovery_area/DENVER/backupset/2010_10_16/o1_mf_nnndf_TAG20101016T230845_6cmhzz8t_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/flash_recovery_area/DENVER/backupset/2010_10_16/o1_mf_nnndf_TAG20101016T230845_6cmhzz8t_.bkp tag=TAG20101016T230845
channel ORA_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 17-OCT-10
Starting recover at 17-OCT-10
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 10 is already on disk as file /oracle/archivelog/1_10_732510268.dbf
archive log filename=/oracle/archivelog/1_10_732510268.dbf thread=1 sequence=10
media recovery complete, elapsed time: 00:00:01
Finished recover at 17-OCT-10
RMAN> alter database open resetlogs;
database opened
發現剛才恢複的時間23:14:42有點早,于是想改為恢複時間點為23:17:26,于是再次關閉資料庫,mount狀态下,但是出錯了
RMAN> run {
2> set until time "to_date('2010-10-16 23:17:26','yyyy-mm-dd hh24:mi:ss')";
3> restore database;
4> recover database;
5> }
executing command: SET until clause
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of set command at 10/17/2010 00:45:40
RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time
時間再前點恢複也不行:
RMAN> run {
2> set until time "to_date('2010-10-16 23:14:40','yyyy-mm-dd hh24:mi:ss')";
3> restore database;
4> recover database;
5> }
executing command: SET until clause
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of set command at 10/17/2010 01:17:03
RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time
這是為什麼?那些歸檔都還在,難道我的rman做過一次不完全恢複後,就不能再不完全恢複了,跟有沒有換備份控制檔案有關系嗎?裡面做了什麼呢?
RMAN> list incarnation;
using target database control file instead of recovery catalog
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1 1 DENVER 4021391415 PARENT 1 22-OCT-05
2 2 DENVER 4021391415 PARENT 525876 16-OCT-10
3 3 DENVER 4021391415 CURRENT 620239 17-OCT-10
問題解決:
先要弄清楚alter database open resetlogs是什麼意思,為什麼要用resetlogs打開資料庫,這個指令發出後oracle都做了什麼?
alter database open resetlogs是要打開資料時,重置重做日志,即将重做日志的sequence置零,為什麼要重置重做日志呢?
不完全恢複後,原來的online redo log裡面包含的是未做恢複前的資料,而這些資料對于恢複後的資料庫不再有效,是以資料庫會要求在Open之前先對online redo log的sequence置零。
Resetlogs指令表示一個資料庫邏輯生存期的結束和另一個資料庫邏輯生存期的開始,每次使用Resetlogs指令的時候,SCN不會被重置,不過oracle會重置日志序列号,而且會重置聯機重做日志内容。
Oracle把這個資料庫邏輯生存期稱為incarnation
每次使用resetlogs打開資料庫,就會使incarnation + 1,也就是産生一個新的incarnation;
如果想要恢複到之前incarnation的scn/time,就需要先恢複到之前的incarnation;
對于上面的案例,具體就是先要
Reset database to incarnation 2;
再做不完全恢複試試