RMAN深入解析之--BlockRecover恢复坏块


案例环境:

操作系统:RedHat EL5

Oracle:  Oracle 11gR2

案例描述:

通过块介质恢复(Block Media Recover:BMR)执行块级别的恢复操作来修复Oracle数据库上的逻辑或物理上损坏的数据块。

1、模拟数据块被破坏

10:26:48 SYS@ prod>conn scott/tiger

Connected.

10:26:51 SCOTT@ prod>select * from tab;

TNAME                          TABTYPE  CLUSTERID

------------------------------ ------- ----------

BONUS                          TABLE

DEPT                          TABLE

EMP                            TABLE

EMP1                          TABLE

SALGRADE                      TABLE

Elapsed: 00:00:00.10

10:26:55 SCOTT@ prod>

10:27:37 SYS@ prod>desc dba_segments

 Name                                                              Null?    Type 

 ----------------------------------------------------------------- -------- -------------

 OWNER                                                                      VARCHAR2(30)

 SEGMENT_NAME                                                              VARCHAR2(81)

 PARTITION_NAME                                                            VARCHAR2(30)

 SEGMENT_TYPE                                                              VARCHAR2(18)

 SEGMENT_SUBTYPE                                                            VARCHAR2(10)

 TABLESPACE_NAME                                                            VARCHAR2(30)

 HEADER_FILE                                                                NUMBER

 HEADER_BLOCK                                                              NUMBER

 BYTES                                                                      NUMBER

 BLOCKS                                                                    NUMBER

 EXTENTS                                                                    NUMBER

 INITIAL_EXTENT                                                            NUMBER

 NEXT_EXTENT                                                                NUMBER

 MIN_EXTENTS                                                                NUMBER

 MAX_EXTENTS                                                                NUMBER

 MAX_SIZE                                                                  NUMBER

 RETENTION                                                                  VARCHAR2(7)

 MINRETENTION                                                              NUMBER

 PCT_INCREASE                                                              NUMBER

 FREELISTS                                                                  NUMBER

 FREELIST_GROUPS                                                            NUMBER

 RELATIVE_FNO                                                              NUMBER

 BUFFER_POOL                                                                VARCHAR2(7)

 FLASH_CACHE                                                                VARCHAR2(7)

 CELL_FLASH_CACHE                                                          VARCHAR2(7)

10:27:41 SYS@ prod>col segment_name for a20     

10:27:59 SYS@ prod>select owner,segment_name,SEGMENT_TYPE,HEADER_BLOCK from dba_segments     

10:29:06  2  where owner='SCOTT' and segment_name='EMP1';

OWNER                          SEGMENT_NAME        SEGMENT_TYPE      HEADER_BLOCK

------------------------------ -------------------- ------------------ ------------

SCOTT                          EMP1                TABLE                      170


    通过以上查询,可以知道EMP1 table的segment header block为170;利用Uedit32,打开数据文件(users01.dbf)进行编辑破坏!

--------------------------------------------------------------------------------

RMAN 配置归档日志删除策略

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密

Linux-6-64下安装Oracle 12C笔记

在CentOS 6.4下安装Oracle 11gR2(x64)

Oracle 11gR2 在VMWare虚拟机中安装步骤

Debian 下 安装 Oracle 11g XE R2

--------------------------------------------------------------------------------

以下是计算block 170和block 171在Uedit32编辑中的offset:

10:29:24 SYS@ prod>select to_char(170*8*1024, 'xxxxxxxxxxxxxxxxxxxxx') from dual;

TO_CHAR(170*8*1024,'XX

----------------------

                154000

 


10:30:27 SYS@ prod>select to_char(171*8*1024, 'xxxxxxxxxxxxxxxxxxxxx') from dual;

TO_CHAR(171*8*1024,'XX

----------------------

                156000

以下是Uedit32编辑users01.dbf图片:

RMAN深入解析之--BlockRecover恢复坏块 

通过转储数据块验证:

10:30:37 SYS@ prod>alter system dump datafile 4 block 170;

System altered.

 


[oracle@rh6 ~]$ ls -lt /u01/app/oracle/diag/rdbms/prod/prod/trace/|more

total 14300


-rw-r----- 1 oracle oinstall    4492 Jul 15 11:34 prod_ora_2883.trc

-rw-r----- 1 oracle oinstall      69 Jul 15 11:34 prod_ora_2883.trm

-rw-r----- 1 oracle oinstall  557756 Jul 15 10:17 alert_prod.log

-rw-r----- 1 oracle oinstall    947 Jul 15 10:17 prod_ckpt_2541.trc

-rw-r----- 1 oracle oinstall      59 Jul 15 10:17 prod_ckpt_2541.trm

-rw-r----- 1 oracle oinstall    1783 Jul 15 10:12 prod_j000_2588.trc

-rw-r----- 1 oracle oinstall      80 Jul 15 10:12 prod_j000_2588.trm


查看转储文件:

[oracle@rh6 ~]$ cat  /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_2883.trc|more

Trace file /u01/app/oracle/diag/rdbms/prod/prod/trace/prod_ora_2883.trc

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1

System name:    Linux

Node name:      rh6

Release:        2.6.32-358.el6.x86_64

Version:        #1 SMP Tue Jan 29 11:47:41 EST 2013

Machine:        x86_64

Instance name: prod

Redo thread mounted by this instance: 1

Oracle process number: 26

Unix process pid: 2883, image: oracle@rh6 (TNS V1-V3)

*** 2014-07-15 11:34:50.092

*** SESSION ID:(37.32) 2014-07-15 11:34:50.092

*** CLIENT ID:() 2014-07-15 11:34:50.092

*** SERVICE NAME:(SYS$USERS) 2014-07-15 11:34:50.092

*** MODULE NAME:(sqlplus@rh6 (TNS V1-V3)) 2014-07-15 11:34:50.092

*** ACTION NAME:() 2014-07-15 11:34:50.092

 

Start dump data blocks tsn: 4 file#:4 minblk 170 maxblk 170

Block dump from cache:

Dump of buffer cache at level 4 for tsn=4, rdba=16777386

Block dump from disk:

buffer tsn: 4 rdba: 0x010000aa (4/170)

scn: 0x0000.001f891c seq: 0x02 flg: 0x04 tail: 0x891c2302

frmt: 0x02 chkval: 0x8eee type: 0x23=PAGETABLE SEGMENT HEADER

Hex dump of block: st=0, typ_found=1

Dump of memory from 0x00007F7DFC5C7A00 to 0x00007F7DFC5C9A00


7F7DFC5C7A00 0000A223 010000AA 001F891C 04020000  [#...............]

---此行内容与Uedit32打开内容一致

7F7DFC5C7A10 00008EEE 00000000 00000000 00000000  [................]

7F7DFC5C7A20 00000000 00000001 00000008 00000A9C  [................]

7F7DFC5C7A30 00000000 00000008 00000008 010000B0  [................]

7F7DFC5C7A40 00000000 00000000 00000000 00000008  [................]

7F7DFC5C7A50 00000000 00000000 00000000 00000000  [................]

7F7DFC5C7A60 00000008 00000008 010000B0 00000000  [................]

7F7DFC5C7A70 00000000 00000000 00000008 010000A8  [................]

7F7DFC5C7A80 010000A8 00000000 00000000 00000000  [................]

7F7DFC5C7A90 00000000 00000000 00000000 00000000  [................]

        Repeat 3 times

7F7DFC5C7AD0 00000001 00002000 00000000 00001434  [..... ......4...]

7F7DFC5C7AE0 00000000 010000A9 00000001 010000A8  [................]

7F7DFC5C7AF0 010000A9 00000000 00000000 00000000  [................]

7F7DFC5C7B00 00000000 00000000 00000001 00000000  [................]

7F7DFC5C7B10 0001257B 10000000 010000A8 00000008  [{%..............]

7F7DFC5C7B20 00000000 00000000 00000000 00000000  [................]

        Repeat 152 times

7F7DFC5C84B0 010000A8 010000AB 00000000 00000000  [................]

7F7DFC5C84C0 00000000 00000000 00000000 00000000  [................]

        Repeat 151 times

7F7DFC5C8E40 00000000 00000000 010000A9 00000000  [................]

7F7DFC5C8E50 00000000 00000000 00000000 00000000  [................]

        Repeat 185 times

7F7DFC5C99F0 00000000 00000000 00000000 891C2302  [.............#..]

  Extent Control Header

  -----------------------------------------------------------------

  Extent Header:: spare1: 0      spare2: 0      #extents: 1      #blocks: 8   

                  last map  0x00000000  #maps: 0      offset: 2716 

      Highwater::  0x010000b0  ext#: 0      blk#: 8      ext size: 8   

  #blocks in seg. hdr's freelists: 0   

  #blocks below: 8   

  mapblk  0x00000000  offset: 0   

                  Unlocked

  --------------------------------------------------------

  Low HighWater Mark :

      Highwater::  0x010000b0  ext#: 0      blk#: 8      ext size: 8   

  #blocks in seg. hdr's freelists: 0   

  #blocks below: 8   

  mapblk  0x00000000  offset: 0   

  Level 1 BMB for High HWM block: 0x010000a8

  Level 1 BMB for Low HWM block: 0x010000a8

  --------------------------------------------------------

  Segment Type: 1 nl2: 1      blksz: 8192  fbsz: 0     

  L2 Array start offset:  0x00001434

  First Level 3 BMB:  0x00000000

  L2 Hint for inserts:  0x010000a9

  Last Level 1 BMB:  0x010000a8

  Last Level II BMB:  0x010000a9

  Last Level III BMB:  0x00000000

    Map Header:: next  0x00000000  #extents: 1    obj#: 75131  flag: 0x10000000

  Inc # 0

  Extent Map

  -----------------------------------------------------------------

  0x010000a8  length: 8   

 

  Auxillary Map

  --------------------------------------------------------

  Extent 0    :  L1 dba:  0x010000a8 Data dba:  0x010000ab

  --------------------------------------------------------

 

  Second Level Bitmap block DBAs

  --------------------------------------------------------

  DBA 1:  0x010000a9

 

End dump data blocks tsn: 4 file#: 4 minblk 170 maxblk 170


2、将Uedit32(通过16进制编辑功能)编辑过的数据文件上传到数据库

13:59:58 SYS@ prod>alter system flush buffer_cache;

System altered.

读取数据出错:

14:00:05 SYS@ prod>select * from scott.emp1;

select * from scott.emp1

*

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 4, block # 170)

ORA-01110: data file 4: '/u01/app/oracle/oradata/prod/users01.dbf'


验证数据文件:

[oracle@rh6 ~]$ dbv file=/u01/app/oracle/oradata/prod/users01.dbf blocksize=8192


DBVERIFY: Release 11.2.0.1.0 - Production on Tue Jul 15 13:59:41 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/prod/users01.dbf

Page 170 is marked corrupt

Corrupt block relative dba: 0x010000aa (file 4, block 170)

Bad check value found during dbv:

Data in bad block:

 type: 35 format: 2 rdba: 0x010000aa

 last change scn: 0x0000.001f891c seq: 0x2 flg: 0x04

 spare1: 0x0 spare2: 0x0 spare3: 0x0

 consistency value in tail: 0x891c2302

 check value in block header: 0x8eee

 computed block checksum: 0x2020

Page 171 is marked corrupt

Corrupt block relative dba: 0x010000ab (file 4, block 171)

Bad header found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x012020ab

 last change scn: 0x2020.201f890b seq: 0x2 flg: 0x04

 spare1: 0x20 spare2: 0x20 spare3: 0x2020

 consistency value in tail: 0x890b0602

 check value in block header: 0xcf8b

 computed block checksum: 0x2e00

Page 172 is marked corrupt

Corrupt block relative dba: 0x010000ac (file 4, block 172)

Bad header found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x012020ac

 last change scn: 0x2020.201f891c seq: 0x3 flg: 0x06

 spare1: 0x20 spare2: 0x20 spare3: 0x2020

 consistency value in tail: 0x891c0603

 check value in block header: 0xa5b1

 computed block checksum: 0x0

Page 173 is marked corrupt

Corrupt block relative dba: 0x010000ad (file 4, block 173)

Bad header found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x012020ad

 last change scn: 0x2020.201f891c seq: 0x1 flg: 0x04

 spare1: 0x20 spare2: 0x20 spare3: 0x2020

 consistency value in tail: 0x891c0601

 check value in block header: 0xf6ab

 computed block checksum: 0x2020

Page 174 is marked corrupt

Corrupt block relative dba: 0x010000ae (file 4, block 174)

Bad header found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x012020ae

 last change scn: 0x2020.201f891c seq: 0x1 flg: 0x04

 spare1: 0x20 spare2: 0x20 spare3: 0x2020

 consistency value in tail: 0x891c0601

 check value in block header: 0xcef0

 computed block checksum: 0x20

Page 175 is marked corrupt

Corrupt block relative dba: 0x010000af (file 4, block 175)

Bad header found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x012020af

 last change scn: 0x2020.201f891c seq: 0x1 flg: 0x04

 spare1: 0x20 spare2: 0x20 spare3: 0x2020

 consistency value in tail: 0x891c0601

 check value in block header: 0x146a

 computed block checksum: 0x0

Page 176 is marked corrupt

Corrupt block relative dba: 0x010000b0 (file 4, block 176)

Bad header found during dbv:

Data in bad block:

 type: 6 format: 2 rdba: 0x012020b0

 last change scn: 0x2020.201e6219 seq: 0x1 flg: 0x04

 spare1: 0x20 spare2: 0x20 spare3: 0x2020

 consistency value in tail: 0x62190601

 check value in block header: 0x2185

 computed block checksum: 0x2020


DBVERIFY - Verification complete

Total Pages Examined        : 12800

Total Pages Processed (Data) : 757

Total Pages Failing  (Data) : 0

Total Pages Processed (Index): 2

Total Pages Failing  (Index): 0

Total Pages Processed (Other): 12024

Total Pages Processed (Seg)  : 0

Total Pages Failing  (Seg)  : 0

Total Pages Empty            : 10

Total Pages Marked Corrupt  : 7

Total Pages Influx          : 0

Total Pages Encrypted        : 0

Highest block SCN            : 2066716 (0.2066716)

从以上验证结果看:总共有7个数据块(170-176)被破坏!

更多详情见请继续阅读下一页的精彩内容:

  • 1
  • 2
  • 下一页

相关内容