当前位置:数据库 > Oracle >>

Oracle RMAN Recover中使用BBED跳过缺失的归档继续Recover的测试

Oracle RMAN Recover中使用BBED跳过缺失的归档继续Recover的测试
 
一.背景说明
 
Oracle RMAN 备份的恢复分2个步骤:RESTRE 和 RECOVER。
 
在这个过程中,Recover 是依赖与归档文件的。
 
假设一种情况:周一对数据库做了全备,然后保留归档。周四发现数据库有异常,准备恢复,发现周二的时候少了一个归档。
 
按照正常的情况,我们只能将数据库恢复到周二缺失归档的之前的点。
 
那么我这里就是一个研究,如何跳过这个缺失的归档,让数据库继续进行Recover。
 
根据测试结果,Recover 是可以继续,但是测试的结果意义不是很大,因为还是有数据丢失。
 
所以这里更多的是对这种方法的抛砖引玉。
 
二.测试案例
 
2.1 使用RMAN 全备数据库
此步骤直接备份即可。
 
2.2 创建测试表dave1并切换归档
SQL> select sequence# from v$log wherethread#=1;
 
 SEQUENCE#
----------
      152
      151
 
SQL> create table dave1 as select * fromdba_users;
Table created.
 
SQL> alter system switch logfile;
System altered.
 
SQL> select sequence# from v$log wherethread#=1;
 SEQUENCE#
----------
      152
      153
 
2.3 创建测试表dave2并切换归档
 
SQL> create table dave2 as select * fromdba_users;
Table created.
 
SQL> alter system switch logfile;
System altered.
 
SQL> select sequence#,status from v$logwhere thread#=1;
 
 SEQUENCE# STATUS
---------- ----------------
      154 CURRENT
      153 ACTIVE
 
SQL> select sequence# fromv$archived_log where thread#=1;
 
 SEQUENCE#
----------
      148
      149
      150
      151
      152
      153
 
6 rows selected.
 
2.4 删除153的归档
 
[oracle@dave arch]$ ll
total 42200
-rw-r-----. 1 oracle oinstall 42715136Jul  5 22:56 1_125_816661296.dbf
-rw-r-----. 1 oracle oinstall   248320 Jul 6 23:14 1_152_816661296.dbf
-rw-r-----. 1 oracle oinstall   127488 Jul 6 23:15 1_153_816661296.dbf
-rw-r-----. 1 oracle oinstall   113664 Jul 6 23:19 1_154_816661296.dbf
[oracle@dave arch]$ rm-rf 1_153_816661296.dbf
[oracle@dave arch]$ ll
total 42072
-rw-r-----. 1 oracle oinstall 42715136Jul  5 22:56 1_125_816661296.dbf
-rw-r-----. 1 oracle oinstall   248320 Jul 6 23:14 1_152_816661296.dbf
-rw-r-----. 1 oracle oinstall   113664 Jul 6 23:19 1_154_816661296.dbf
[oracle@dave arch]$
 
 
2.5 然后进行restore 和recover
 
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
 
SQL> startup mount
 
RMAN> restore database;
 
Starting restore at 06-JUL-13
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK
 
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00001 to /u01/app/oracle/oradata/dave/system.256.816661027
channel ORA_DISK_1: restoring datafile00003 to /u01/app/oracle/oradata/dave/undotbs1.258.816661037
channel ORA_DISK_1: restoring datafile00005 to /u01/app/oracle/oradata/dave/undotbs2.265.816661787
channel ORA_DISK_1: reading from backuppiece /u01/backup/dave_lev0_06oe3kdv_1_1_20130706
channel ORA_DISK_1: piecehandle=/u01/backup/dave_lev0_06oe3kdv_1_1_20130706 tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:25
channel ORA_DISK_1: starting datafilebackup set restore
channel ORA_DISK_1: specifying datafile(s)to restore from backup set
channel ORA_DISK_1: restoring datafile00002 to /u01/app/oracle/oradata/dave/sysaux.257.816661033
channel ORA_DISK_1: restoring datafile00004 to /u01/app/oracle/oradata/dave/users.259.816661039
channel ORA_DISK_1: restoring datafile00006 to /u01/app/oracle/oradata/dave/dave01.dbf
channel ORA_DISK_1: restoring datafile00007 to /u01/app/oracle/oradata/dave/dave02.dbf
channel ORA_DISK_1: reading from backuppiece /u01/backup/dave_lev0_05oe3kdv_1_1_20130706
channel ORA_DISK_1: piece handle=/u01/backup/dave_lev0_05oe3kdv_1_1_20130706tag=DAVE_LEV0
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete,elapsed time: 00:00:25
Finished restore at 06-JUL-13
 
RMAN>
 
RMAN> recoverdatabase;
 
Starting recover at 06-JUL-13
using channel ORA_DISK_1
 
starting media recovery
 
archived log for thread 1 with sequence 152is already on disk as file /u01/arch/1_152_816661296.dbf
archived log for thread 1 with sequence 154is already on disk as file /u01/arch/1_154_816661296.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGESTACK FOLLOWS ===============
RMAN-00571:===========================================================
RMAN-03002: failure of recover command at07/06/2013 23:23:48
RMAN-06053: unable to perform mediarecovery because of missing log
RMAN-06025: no backup ofarchived log for thread 1 with sequence 153 and starting SCN of 3836001 foundto restore
 
RMAN>
 
这个153 是我们刚才手工删掉的归档。如果这个不搞定,后面没办法恢复。
 
 
2.6 BBED 推荐SCN
 
2.6.1 修改原理说明
 
 
-- System Checkpoint SCN:
SQL> select checkpoint_change# fromv$database;
 
CHECKPOINT_CHANGE#
------------------
          3836654
 
 
--- Datafile CheckpointSCN:
SQL> select name,checkpoint_change# fromv$datafile;
 
NAME                                                   CHECKPOINT_CHANGE#
-------------------------------------------------------------------------
/u01/app/oracle/oradata/dave/system.256.816661027                  3836654
/u01/app/oracle/oradata/dave/sysaux.257.816661033                  3836654
/u01/app/oracle/oradata/dave/undotbs1.258.816661037     &n
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,