ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 数据库恢复到备份之前测试_RMAN-06556

数据库恢复到备份之前测试_RMAN-06556

原创 Linux操作系统 作者:YallonKing 时间:2012-04-02 18:33:51 0 删除 编辑
今天,我在群里提问如下:
问:  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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-08-07

  • 博文量
    72
  • 访问量
    248599