資料庫恢復到備份之前測試_RMAN-06556
今天,我在群裡提問如下:
問: 2012/2/20 rman下進行了 0級增量備份且已成功結束;能否將資料庫回退到 2012/2/19日某刻?
問: 2012/2/20 rman下進行了 0級增量備份且已成功結束;能否將資料庫回退到 2012/2/19日某刻?
--測試過程如下:
--資料庫版本
SQL> select * from v$version where rownum<5;
--資料庫版本
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
--------------------------------------------------------------------------------
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
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
-----------
2912652800
--插入測試資料並切換日誌
SQL> insert into test values(1,'yallonking');
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
---------- ----------
1 yallonking
--進行0級增量備份全庫
[oracle@test ~]$ rman target /
[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
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
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
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
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
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
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
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
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;
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
2912653190
-----------
2912653190
--嘗試恢復到之前的scn(2912652800)
SQL> select * from test;
SQL> select * from test;
ID NAME
---------- ----------
1 yallonking
---------- ----------
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
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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【備份恢復】從備份恢復資料庫資料庫
- rman備份恢復-rman恢復資料檔案測試
- 資料庫備份恢復資料庫
- Oracle資料庫的熱備份與完整恢復測試 (2)Oracle資料庫
- Oracle資料庫的熱備份與完整恢復測試 (1)Oracle資料庫
- DB2資料庫的備份測試--開始恢復DB2資料庫
- 備份與恢復:polardb資料庫備份與恢復資料庫
- mysql備份恢復測試MySql
- 【備份恢復】noarchive模式下使用增量備份恢復資料庫Hive模式資料庫
- Oracle DG從庫 Rman備份恢復測試Oracle
- 通過binlog恢復mysql備份之前的資料MySql
- 達夢資料庫備份恢復資料庫
- postgresql備份與恢復資料庫SQL資料庫
- mongo資料庫備份與恢復Go資料庫
- 資料庫的備份與恢復資料庫
- Informix資料庫備份與恢復ORM資料庫
- 備份和恢復postgreSQL資料庫SQL資料庫
- Mysql資料庫備份及恢復MySql資料庫
- 資料庫資料的恢復和備份資料庫
- RMAN備份恢復——備份到帶庫的效能
- PDM測試資料庫恢復資料庫
- rman資料庫全庫備份與恢復資料庫
- DB2備份恢復測試DB2
- oracle備份與恢復測試(五)Oracle
- 【Mysql】xtrabackup 備份和恢復測試MySql
- RMAN備份恢復測試指令碼指令碼
- 【管理篇備份恢復】rman恢復測試(一) 表空間資料檔案
- PostgreSql資料庫的備份和恢復SQL資料庫
- Mongo 資料庫備份和恢復命令Go資料庫
- 直接透過備份恢復資料庫資料庫
- mysql的資料庫備份與恢復MySql資料庫
- oracle資料庫的備份與恢復Oracle資料庫
- 備份和恢復SQL Server資料庫SQLServer資料庫
- 資料庫備份與恢復技術資料庫
- pg_dump 備份,恢復資料庫資料庫
- 【備份恢復】RMAN catalog 恢復目錄資料庫資料庫
- SqlServer資料庫恢復備份資料的方法SQLServer資料庫
- 資料庫備份與異機恢復——熱備份方式資料庫