OCP考题解析_043:rman系列之 BBED破坏,BlockRecover恢复的案例演示

环境:

sys@EMREP> select * from v$version where rownum=1;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

sys@EMREP> !uname -a
Linux localhost.localdomain 2.6.18-308.el5xen #1 SMP Fri Jan 27 17:59:00 EST 2012 i686 i686 i386 GNU/Linux


        之前有个坏块63,所以dbv校验时有2个坏块,所以rman备份时要设坏块容忍哈,比较懒的,所以....
     
        ① 实验准备

RMAN> run {
2> set maxcorrupt for datafile 4 to 1;
3> backup tablespace users;
4> }

executing command: SET MAX CORRUPT

Starting backup at 17-DEC-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00004 name=/u01/app/oracle/oradata/emrep/users01.dbf
channel ORA_DISK_1: starting piece 1 at 17-DEC-12
channel ORA_DISK_1: finished piece 1 at 17-DEC-12
piece handle=/u01/app/oracle/flash_recovery_area/EMREP/backupset/2012_12_17/o1_mf_nnndf_TAG20121217T205237_8dy5dor3_.bkp tag=TAG20121217T205237 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 17-DEC-12


u1@EMREP> select t2.*,dbms_rowid.rowid_block_number(rowid) from t2;

         B DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
---------- ------------------------------------
         1                                   71
         3                                   71


 

        ② BBED模拟坏块

BBED> set file 4
        FILE#           4

BBED> modify 1000 file 4 block 71
 File: /u01/app/oracle/oradata/emrep/users01.dbf (4)
 Block: 71               Offsets:    0 to  511           Dba:0x01000047
------------------------------------------------------------------------
 03e80000 47000001 a63e0400 00000406 454c0000 01000000 3d290000 993e0400 
 00000000 02003200 41000001 09001400 7e000000 ba008000 48001a00 02200000 
 a63e0400 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00010200 ffff1600 8c1f701f 701f0000 0200921f 8c1f0000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

 <32 bytes per line>

BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle/oradata/emrep/users01.dbf
BLOCK = 71

Block 71 is corrupt
Corrupt block relative dba: 0x01000047 (file 0, block 71)
Bad header found during verification
Data in bad block:
 type: 3 format: 0 rdba: 0x01000047
 last change scn: 0x0000.00043ea6 seq: 0x4 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x3ea60604
 check value in block header: 0x4c45
 computed block checksum: 0x4a05


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 1
Total Blocks Influx           : 0


 

        ③ SQLPLUS 检查

u1@EMREP> conn / as sysdba
Connected.
sys@EMREP> startup force;    
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size                  1220384 bytes
Variable Size             247464160 bytes
Database Buffers          272629760 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.
sys@EMREP> conn u1/u1
Connected.
u1@EMREP> select * from t2;
select * from t2
              *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 71)
ORA-01110: data file 4: '/u01/app/oracle/oradata/emrep/users01.dbf'


 

        ④ DBV再次确认

[oracle@localhost ~]$ dbv file=/u01/app/oracle/oradata/emrep/users01.dbf

DBVERIFY: Release 10.2.0.1.0 - Production on Mon Dec 17 21:00:48 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/emrep/users01.dbf
Page 63 is marked corrupt
Corrupt block relative dba: 0x0100003f (file 4, block 63)
Bad header found during dbv: 
Data in bad block:
 type: 3 format: 0 rdba: 0x0100003f
 last change scn: 0x0000.00050c11 seq: 0x1 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x0c110601
 check value in block header: 0xd375
 computed block checksum: 0x4a05

Page 71 is marked corrupt
Corrupt block relative dba: 0x01000047 (file 4, block 71)
Bad header found during dbv: 
Data in bad block:
 type: 3 format: 0 rdba: 0x01000047
 last change scn: 0x0000.00043ea6 seq: 0x4 flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x3ea60604
 check value in block header: 0x4c45
 computed block checksum: 0x4a05



DBVERIFY - Verification complete

Total Pages Examined         : 640
Total Pages Processed (Data) : 39
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 6
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 45
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 548
Total Pages Marked Corrupt   : 2
Total Pages Influx           : 0
Highest block SCN            : 330790 (0.330790)


 

        ⑤ RMAN修复

RMAN> blockrecover datafile 4 block 71;

Starting blockrecover at 17-DEC-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=538 devtype=DISK

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00004
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/EMREP/backupset/2012_12_17/o1_mf_nnndf_TAG20121217T205237_8dy5dor3_.bkp
channel ORA_DISK_1: restored block(s) from backup piece 1
piece handle=/u01/app/oracle/flash_recovery_area/EMREP/backupset/2012_12_17/o1_mf_nnndf_TAG20121217T205237_8dy5dor3_.bkp tag=TAG20121217T205237
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:02

starting media recovery
media recovery complete, elapsed time: 00:00:07

Finished blockrecover at 17-DEC-12


 

        ⑥ 数据验证

sys@EMREP> conn u1/u1
Connected.
u1@EMREP> select * from t2;

         B
----------
         1
         3


 

        ⑦ 注意事项
       
        BLOCKRECOVER DATAFILE 9 BLOCK 13 DATAFILE 2 BLOCK 19 RESTORE UNTIL SCN 100;
        BLOCKRECOVER语句中的UNTIL关键字不是表示不完全恢复
        UNTIL的意思是指从特定的日期或SCN之前生成的备份中还原数据块(restore)
        还原完成后还会应用与数据块相关的重做日志(recover)


      
        ⑧ 附上OCP-043考题

             

 

             

 

           

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值