資料庫恢復到備份之前測試_RMAN-06556

YallonKing發表於2012-04-02
今天,我在群裡提問如下:
問:  2012/2/20  rman下進行了 0級增量備份且已成功結束;能否將資料庫回退到 2012/2/19日某刻?
--測試過程如下:
--資料庫版本
SQL> select * from v$version where rownum<5;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
--資料庫執行模式
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     152
Next log sequence to archive   154
Current log sequence           154

--檢視當前scn
SQL> select CURRENT_SCN from v$database;
CURRENT_SCN
-----------
2912652800
--插入測試資料並切換日誌
SQL> insert into test values(1,'yallonking');
1 row created.
SQL> commit;
Commit complete.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> select * from test;
        ID NAME
---------- ----------
         1 yallonking
--進行0級增量備份全庫
[oracle@test ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 2 03:09:09 2012
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: TEST (DBID=2055832488)
RMAN> backup incremental level 0 database;
Starting backup at 02-APR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=52 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=54 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=56 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=31 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=51 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=55 device type=DISK
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u01/app/oracle/oradata/test/test101.dbf
channel ORA_DISK_1: starting piece 1 at 02-APR-12
channel ORA_DISK_2: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/test/test01.dbf
input datafile file number=00009 name=/u01/app/oracle/oradata/test/test_2010_d1
channel ORA_DISK_2: starting piece 1 at 02-APR-12
channel ORA_DISK_3: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/test/system01.dbf
input datafile file number=00008 name=/u01/app/oracle/oradata/test/test_2011_d1
channel ORA_DISK_3: starting piece 1 at 02-APR-12
channel ORA_DISK_4: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_4: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/test/sysaux01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/test/users01.dbf
channel ORA_DISK_4: starting piece 1 at 02-APR-12
channel ORA_DISK_5: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_5: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/test/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/test/example01.dbf
channel ORA_DISK_5: starting piece 1 at 02-APR-12
channel ORA_DISK_6: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_6: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_6: starting piece 1 at 02-APR-12
channel ORA_DISK_1: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_nnnd0_TAG20120402T030959_7qkb082g_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:10
channel ORA_DISK_1: starting compressed incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 02-APR-12
channel ORA_DISK_2: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_nnnd0_TAG20120402T030959_7qkb084d_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:11
channel ORA_DISK_1: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_nnsn0_TAG20120402T030959_7qkb0l5k_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:08
channel ORA_DISK_6: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_ncnn0_TAG20120402T030959_7qkb0jlb_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_6: backup set complete, elapsed time: 00:00:10
channel ORA_DISK_5: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_nnnd0_TAG20120402T030959_7qkb0gqj_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_5: backup set complete, elapsed time: 00:01:07
channel ORA_DISK_4: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_nnnd0_TAG20120402T030959_7qkb088s_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:01:58
channel ORA_DISK_3: finished piece 1 at 02-APR-12
piece handle=/tmp/TEST/backupset/2012_04_02/o1_mf_nnnd0_TAG20120402T030959_7qkb0864_.bkp tag=TAG20120402T030959
comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:02:18
Finished backup at 02-APR-12
--檢視當前scn
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
2912653190
--嘗試恢復到之前的scn(2912652800)
SQL> select * from test;
        ID NAME
---------- ----------
         1 yallonking
RMAN> recover database until scn 2912652800;
Starting recover at 02-APR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=31 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=52 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=38 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=41 device type=DISK
allocated channel: ORA_DISK_5
channel ORA_DISK_5: SID=44 device type=DISK
allocated channel: ORA_DISK_6
channel ORA_DISK_6: SID=34 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 04/02/2012 03:31:07
RMAN-06556: datafile 1 must be restored from backup older than SCN 2912652800
可見,問題答案顯而易見。
這個測試說明,當要將資料庫回退到完整備份之前的狀態時,需要的備份要在指定恢復資料庫時間之前結束。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26143577/viewspace-720223/,如需轉載,請註明出處,否則將追究法律責任。

相關文章