Oracle异常恢复BBED系列

0    525    1

Tags:

👉 本文共约65004个字,系统预计阅读时间或需245分钟。

使用BBED修复SYSTEM文件头损坏

前言部分

导读和注意事项

各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其它你所不知道的知识,~O(∩_∩)O~:

① BBED恢复SYSTEM文件头

② BBED查看文件头的信息

本文简介

本文的实验过程主要是为了学习BBED,大家学完做完这1篇还有之前的3篇blog,那么BBED基本算是入门了,恭喜。

相关知识点扫盲(摘自网络)

考虑到文件头基本上不会有数据,只有一些数据库、相应表空间以及本文件相关的描述信息

故此我们有能力考虑白行构诰一个 File Header来启动数据库。

实验环境介绍

项目db
db 类型单实例
db version11.2.0.4.0
db 存储FS
主机IP地址/hosts配置192.168.59.129
OS版本及kernel版本AIX 7.1 64位
归档模式Archive Mode
ORACLE_SIDoralhr

实验目标

破坏SYSTEM的文件头,然后利用SYSAUX文件的文件头来恢复SYSTEM文件头。

实验过程

冷备system文件

ZHLHRDB2:oracle:/oracle>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 14 16:10:07 2016

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

Connected to:

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

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options

SYS@oralhr> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SYS@oralhr> exit

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Real Application Clusters, OLAP, Data Mining

and Real Application Testing options

ZHLHRDB2:oracle:/oracle>cp /oracle/app/oracle/datafile/oralhr/system01.dbf /oracle/app/oracle/datafile/oralhr/system01.dbf_bk

ZHLHRDB2:oracle:/oracle>sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Apr 14 16:34:04 2016

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

Connected to an idle instance.

SYS@oralhr> startup

ORACLE instance started.

Total System Global Area 3089920000 bytes

Fixed Size 2250360 bytes

Variable Size 721422728 bytes

Database Buffers 2348810240 bytes

Redo Buffers 17436672 bytes

Database mounted.

Database opened.

SYS@oralhr>

SYS@oralhr> set line 9999 pagesize 9999

SYS@oralhr> col name format a80

SYS@oralhr> select file#||' '||name||' '||bytes name from v$datafile;

NAME

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

1 /oracle/app/oracle/datafile/oralhr/system01.dbf 786432000

2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 576716800

3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 78643200

4 /oracle/app/oracle/datafile/oralhr/users01.dbf 310640640

SYS@oralhr>

模拟故障

total 208

-rwxrwxrwx 1 oracle dba 57 Apr 05 17:01 bbed.par

-rwxrwxrwx 1 oracle dba 52224 Apr 14 15:55 bifile.bbd

-rwxrwxrwx 1 oracle asmadmin 5715 Apr 06 15:34 ctl.sql

-rwxrwxrwx 1 oracle dba 302 Apr 14 10:32 file.txt

drwxrwxrwx 8 oracle dba 4096 Apr 13 17:16 gdul

-rwxrwxrwx 1 oracle dba 21008 Apr 14 16:35 log.bbd

drwxrwxrwx 4 oracle dba 256 Apr 12 15:52 oracle_bk

drwxrwxrwx 4 oracle dba 256 Apr 05 16:54 rman_bak

-rwxrwxrwx 1 oracle dba 757 Apr 11 10:02 rman_bk_db_archive_lhr.sh

-rwxrwxrwx 1 oracle dba 1023 Apr 08 11:25 rman_bk_db_lhr.sh

ZHLHRDB2:oracle:/home/oracle>cat file.txt

1 /oracle/app/oracle/datafile/oralhr/system01.dbf 786432000

2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 566231040

3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 78643200

4 /oracle/app/oracle/datafile/oralhr/users01.dbf 310640640

5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 786432000

ZHLHRDB2:oracle:/home/oracle>bbed PASSWORD=blockedit mode=edit blocksize=8192 listfile=/home/oracle/file.txt

BBED: Release 2.0.0.0.0 - Limited Production on Thu Apr 14 16:36:00 2016

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

************* !!! For Oracle Internal Use only !!! ***************

BBED> info

File# Name Size(blks)

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

1 /oracle/app/oracle/datafile/oralhr/system01.dbf 96000

2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 69120

3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 9600

4 /oracle/app/oracle/datafile/oralhr/users01.dbf 37920

5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 96000

BBED> help copy

COPY [ DBA | FILE | FILENAME | BLOCK ] TO [ DBA | FILE | FILENAME | BLOCK ]

BBED> set count 128

COUNT 128

BBED> copy file 1 block 111 to file 1 block 1

Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) Y

File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)

Block: 377 Offsets: 0 to 127 Dba:0x00400179

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

1ea20000 0040006f 000000e2 00000104 fa4c0000 00000001 03450080 00000000

00000000 0000f800 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> sum apply

Check value for File 1, Block 380:

current = 0xfa4c, required = 0xfa4c

BBED>

BBED>

重启数据库:

SYS@oralhr> startup force

ORACLE instance started.

Total System Global Area 3089920000 bytes

Fixed Size 2250360 bytes

Variable Size 721422728 bytes

Database Buffers 2348810240 bytes

Redo Buffers 17436672 bytes

Database mounted.

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-01122: database file 1 failed verification check

ORA-01110: data file 1: '/oracle/app/oracle/datafile/oralhr/system01.dbf'

ORA-01210: data file header is media corrupt

SYS@oralhr>

告警日志:

Fri Apr 15 08:52:22 2016

ALTER DATABASE OPEN

Read of datafile '/oracle/app/oracle/datafile/oralhr/system01.dbf' (fno 1) header failed with ORA-01210

Hex dump of (file 1, block 1) in trace file /oracle/app/oracle/diag/rdbms/oralhr/oralhr/trace/oralhr_ora_7602280.trc

Corrupt block relative dba: 0x00400001 (file 1, block 1)

Bad header found during datafile header read

Data in bad block:

type: 30 format: 2 rdba: 0x0040006f

last change scn: 0x0000.000000e2 seq: 0x1 flg: 0x04

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

consistency value in tail: 0x00e21e01

check value in block header: 0xfa4c

computed block checksum: 0x0

Rereading datafile 1 header failed with ORA-01210

Errors in file /oracle/app/oracle/diag/rdbms/oralhr/oralhr/trace/oralhr_ora_7602280.trc:

ORA-01122: database file 1 failed verification check

ORA-01110: data file 1: '/oracle/app/oracle/datafile/oralhr/system01.dbf'

ORA-01210: data file header is media corrupt

ORA-1122 signalled during: ALTER DATABASE OPEN...

Fri Apr 15 08:52:23 2016

Checker run found 1 new persistent data failures

ORA-01210: data file header is media corrupt 文件头有介质损坏,下边用BBED来恢复。

故障恢复

ZHLHRDB2:oracle:/home/oracle>bbed PASSWORD=blockedit mode=edit blocksize=8192 listfile=/home/oracle/file.txt

BBED: Release 2.0.0.0.0 - Limited Production on Thu Apr 14 16:42:59 2016

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

************* !!! For Oracle Internal Use only !!! ***************

BBED> info

File# Name Size(blks)

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

1 /oracle/app/oracle/datafile/oralhr/system01.dbf 96000

2 /oracle/app/oracle/datafile/oralhr/sysaux01.dbf 69120

3 /oracle/app/oracle/datafile/oralhr/undotbs01.dbf 9600

4 /oracle/app/oracle/datafile/oralhr/users01.dbf 37920

5 /oracle/app/oracle/datafile/oralhr/system01.dbf_bk 96000

BBED> set count 128

COUNT 128

BBED>

BBED> set dba 1,1

DBA 0x00400001 (4194305 1,1)

BBED> map /v

File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)

Block: 1 Dba:0x00400001

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

BBED-00400: invalid blocktype (30)

BBED>

可以看到dba 1,1是一个非法的块类型,下边利用BBED将SYSAUX上的FILE HEADER拷贝到SYSTEM上,然后修改文件头相关的内容:

BBED> copy file 2 block 1 to file 1 block 1

File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)

Block: 1 Offsets: 0 to 511 Dba:0x00400001

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

0ba20000 00800001 00000000 00000104 ed220000 00000000 0b200400 1793c969

4f52414c 48520000 0000093b 00011300 00002000 00020003 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000716 00000000 3155becc 362e0deb 000e20dc 00007f18 00000000

00000000 00000000 00000004 000000a6 3630b88e 000000a5 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 00000001 00065359 53415558 00000000 00000000

00000000 00000000 00000000 00000000 00000002 00000000 00000000 00000000

00000000 0000b7e0 00000000 00000000 00000000 00000000 00000000 00000000

3155bebd 00000001 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 0013e5a8 0000c388 363142ec 00010000 0000002d 00000002 00100000

\<32 bytes per line>

BBED> sum apply

Check value for File 1, Block 1:

current = 0xed22, required = 0xed22

BBED> map /v

File: /oracle/app/oracle/datafile/oralhr/system01.dbf (1)

Block: 1 Dba:0x00400001

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

Data File Header

struct kcvfh, 860 bytes @0

struct kcvfhbfh, 20 bytes @0

struct kcvfhhdr, 76 bytes @20

ub4 kcvfhrdb @96

struct kcvfhcrs, 8 bytes @100

ub4 kcvfhcrt @108

ub4 kcvfhrlc @112

struct kcvfhrls, 8 bytes @116

ub4 kcvfhbti @124

struct kcvfhbsc, 8 bytes @128

ub2 kcvfhbth @136

ub2 kcvfhsta @138

struct kcvfhckp, 160 bytes @484

ub4 kcvfhcpc @140

ub4 kcvfhrts @144

ub4 kcvfhccc @148

struct kcvfhbcp, 160 bytes @152

ub4 kcvfhbhz @312

struct kcvfhxcd, 16 bytes @316

sword kcvfhtsn @332

ub2 kcvfhtln @336

text kcvfhtnm[30] @338

ub4 kcvfhrfn @368

struct kcvfhrfs, 8 bytes @372

ub4 kcvfhrft @380

struct kcvfhafs, 8 bytes @384

ub4 kcvfhbbc @392

ub4 kcvfhncb @396

ub4 kcvfhmcb @400

ub4 kcvfhlcb @404

ub4 kcvfhbcs @408

ub2 kcvfhofb @412

ub2 kcvfhnfb @414

ub4 kcvfhprc @416

struct kcvfhprs, 8 bytes @420

struct kcvfhprfs, 8 bytes @428

ub4 kcvfhtrt @444

ub4 tailchk @8188

BBED>

BBED> p kcvfh

struct kcvfh, 860 bytes @0

struct kcvfhbfh, 20 bytes @0

ub1 type_kcbh @0 0x0b

ub1 frmt_kcbh @1 0xa2

ub1 spare1_kcbh @2 0x00

ub1 spare2_kcbh @3 0x00

ub4 rdba_kcbh @4 0x00800001

ub4 bas_kcbh @8 0x00000000

ub2 wrp_kcbh @12 0x0000

ub1 seq_kcbh @14 0x01

ub1 flg_kcbh @15 0x04 (KCBHFCKV)

ub2 chkval_kcbh @16 0xed22

ub2 spare3_kcbh @18 0x0000

struct kcvfhhdr, 76 bytes @20

ub4 kccfhswv @20 0x00000000

ub4 kccfhcvn @24 0x0b200400

ub4 kccfhdbi @28 0x1793c969

text kccfhdbn[0] @32 O

text kccfhdbn[1] @33 R

text kccfhdbn[2] @34 A

text kccfhdbn[3] @35 L

text kccfhdbn[4] @36 H

text kccfhdbn[5] @37 R

text kccfhdbn[6] @38

text kccfhdbn[7] @39

ub4 kccfhcsq @40 0x0000093b

ub4 kccfhfsz @44 0x00011300

s_blkz kccfhbsz @48 0x00

ub2 kccfhfno @52 0x0002

ub2 kccfhtyp @54 0x0003

ub4 kccfhacid @56 0x00000000

ub4 kccfhcks @60 0x00000000

text kccfhtag[0] @64

text kccfhtag[1] @65

text kccfhtag[2] @66

text kccfhtag[3] @67

text kccfhtag[4] @68

text kccfhtag[5] @69

text kccfhtag[6] @70

text kccfhtag[7] @71

text kccfhtag[8] @72

text kccfhtag[9] @73

text kccfhtag[10] @74

text kccfhtag[11] @75

text kccfhtag[12] @76

text kccfhtag[13] @77

text kccfhtag[14] @78

text kccfhtag[15] @79

text kccfhtag[16] @80

text kccfhtag[17] @81

text kccfhtag[18] @82

text kccfhtag[19] @83

text kccfhtag[20] @84

text kccfhtag[21] @85

text kccfhtag[22] @86

text kccfhtag[23] @87

text kccfhtag[24] @88

text kccfhtag[25] @89

text kccfhtag[26] @90

text kccfhtag[27] @91

text kccfhtag[28] @92

text kccfhtag[29] @93

text kccfhtag[30] @94

text kccfhtag[31] @95

ub4 kcvfhrdb @96 0x00000000

struct kcvfhcrs, 8 bytes @100

ub4 kscnbas @100 0x00000716

ub2 kscnwrp @104 0x0000

ub4 kcvfhcrt @108 0x3155becc

ub4 kcvfhrlc @112 0x362e0deb

struct kcvfhrls, 8 bytes @116

ub4 kscnbas @116 0x000e20dc

ub2 kscnwrp @120 0x0000

ub4 kcvfhbti @124 0x00000000

struct kcvfhbsc, 8 bytes @128

ub4 kscnbas @128 0x00000000

ub2 kscnwrp @132 0x0000

ub2 kcvfhbth @136 0x0000

ub2 kcvfhsta @138 0x0004 (KCVFHOFZ)

struct kcvfhckp, 160 bytes @484

struct kcvcpscn, 8 bytes @484

ub4 kscnbas @484 0x0013e5a8

ub2 kscnwrp @488 0x0000

ub4 kcvcptim @492 0x363142ec

ub2 kcvcpthr @496 0x0001

union u, 12 bytes @500

struct kcvcprba, 12 bytes @500

本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信db_bao,谢谢!
Oracle异常恢复BBED系列后续精彩内容已被小麦苗无情隐藏,请输入验证码解锁本站所有文章!
验证码:
请先关注本站微信公众号,然后回复“验证码”,获取验证码。在微信里搜索“DB宝”或者“www_xmmup_com”或者微信扫描右侧二维码都可以关注本站微信公众号。

标签:

Avatar photo

小麦苗

学习或考证,均可联系麦老师,请加微信db_bao或QQ646634621

您可能还喜欢...

发表回复

嘿,我是小麦,需要帮助随时找我哦。
  • 18509239930
  • 个人微信

  • DB宝
  • 个人邮箱
  • 点击加入QQ群
  • 个人微店

  • 回到顶部