Using bbed to repair Oracle Bad block recovery method

Source: Internet
Author: User
Tags dba ibase

Bbed is the abbreviation for Block Browser/editor and is an internal tool of Oracle that does not publish documentation and support. Bbed is released with the software, but we need a simple relink to use.

  

While there are many risks to the use of bbed tools, they can be used properly to solve many tricky problems and to practice techniques such as bad block repair.

For example, the Bbed tool in oracle10g also requires manual relink to be used, and this version of the tool can also be used in other versions of the database:

[Email protected] lib]$ make-f ins_rdbms.mk $ORACLE _home/rdbms/lib/bbed

Linking bbed utility (bbed)

Rm-f/opt/oracle/product/10.2.0/rdbms/lib/bbed

Gcc-o/opt/oracle/product/10.2.0/rdbms/lib/bbed ...

-l/opt/oracle/product/10.2.0/lib

[Email protected] lib]$ bbed

Password:

Bbed:release 2.0.0.0.0-limited Production on Sun Sep 3 12:42:59 2006

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

************* !!! For Oracle Internal with only!!! ***************

Bbed> Help All

SET DBA [DBA | file#, block#]

SET filename ' filename '

SET FILE file#

SET BLOCK [+/-]block#

SET OFFSET [[+/-]byte offset | symbol | *symbol]

SET BLOCKSIZE bytes

SET list[file] ' filename '

SET WIDTH Character_count

SET COUNT Bytes_to_display

SET IBASE [HEX | OCT | DEC]

SET OBASE [HEX | OCT | DEC]

SET MODE [BROWSE | EDIT]

SET SPOOL [Y | N

SHOW [| ALL]

POP [All]

REVERT [DBA | FILE | FILENAME | BLOCK]

UNDO

Help [| ALL]

VERIFY [DBA | FILE | FILENAME | BLOCK]

corrupt [DBA | FILE | FILENAME | BLOCK]

The default bbed library file is not available in Oracle database 11g, but can be compiled with 10g files, as follows:

1. Copying Oracle 10g files

Copy $ORA 10G_HOME/RDBMS/LIB/SSBBDED.O to $ORA 11g_home/rdbms/lib

Copy $ORA 10G_HOME/RDBMS/LIB/SBBDPT.O to $ORA 11g_home/rdbms/lib

Copy $ORA 10G_HOME/RDBMS/MESG/BBEDUS.MSB to $ORA 11G_HOME/RDBMS/MESG

Copy $ORA 10g_home/rdbms/mesg/bbedus.msg to $ORA 11G_HOME/RDBMS/MESG

Copy $ORA 10G_HOME/RDBMS/MESG/BBEDAR.MSB to $ORA 11G_HOME/RDBMS/MESG

2. Compiling

Make-f $ORA 11g_home/rdbms/lib/ins_rdbms.mk bbed= $ORACLE _home/bin/bbed $ORACLE _home/bin/bbed

Bbed's default password is Blockedit, please use it carefully, internal tools. Oracle does not do technical support.

As I mentioned earlier, this tool can be used to simulate bad blocks for learning and research related to bad chunks, and here is an example.

1. Backing up data files

In this test to recover the corrupted file, need to have a good file, this article simple cold backup file.

[email protected] conner]$ CP users01.dbf Users01.dbf.bak

2. Modify the bbed parameter file

Add backup Files

[Email protected] conner]$ VI filelist.txt

1/OPT/ORACLE/ORADATA/CONNER/SYSTEM01.DBF 440401920

2/OPT/ORACLE/ORADATA/CONNER/UNDOTBS01.DBF 104857600

3/OPT/ORACLE/ORADATA/CONNER/USERS01.DBF 27262976

4/opt/oracle/oradata/conner/users01.dbf.bak 27262976

~

~

~

"Filelist.txt" 4L, 259C written

[Email protected] conner]$ more PAR.BBD

blocksize=8192

Listfile=filelist.txt

Mode=edit

3. Destroying data blocks

[Email protected] conner]$ bbed PARFILE=PAR.BBD

Password:

Bbed:release 2.0.0.0.0-limited Production on Sun Sep 11 22:30:11 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

************* !!! For Oracle Internal with only!!! ***************

Bbed> Set File 3

file# 3

Bbed> Modify-File 3 Block 17

Warning:contents of previous bifile'll be lost. Proceed? (y/n) Y

File:/OPT/ORACLE/ORADATA/CONNER/USERS01.DBF (3)

Block:17 offsets:0 to 511 dba:0x00c00011

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

03e80000 1100c000 75b5a320 00000104 06300000 01000000 611e0000 72b5a320

00000000 03003201 0900c000 ffff0000 00000000 00000000 00000000 00800000

72b5a320 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00012600

ffff5e00 d5037703 77030000 2600c21e 101e581d a91cf61b 471b941a dd192819

6218b417 06175216 9715dd14 26146c13 b4120712 44118310 bc0ffa0e 380e790d

b60cf40b 350b790a c0090409 45088b07 cc060e06 57059804 d5030000 00000000

<32 bytes per line>

Bbed> Verify

Dbverify-verification starting

FILE =/opt/oracle/oradata/conner/users01.dbf

BLOCK = 17

Block is corrupt

***

Corrupt block relative dba:0x00c00011 (file 0, block 17)

Bad header found during verification

Data in bad block-

Type:3 format:0 rdba:0x00c00011

Last Change scn:0x0000.20a3b575 seq:0x1 flg:0x04

Consistency value in tail:0xb5750601

Check value in block header:0x3006, computed block checksum:0xea05

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

***

Bbed> quit

4. Recovering from a copy of a good data block from a backup file

[Email protected] conner]$ bbed PARFILE=PAR.BBD

Password:

Bbed:release 2.0.0.0.0-limited Production on Sun Sep 11 22:33:55 2005

Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.

************* !!! For Oracle Internal with only!!! ***************

Bbed> Set File 4

file# 4

Bbed> Show

file# 4

block# 1

OFFSET 0

DBA 0x01000001 (16777217 4,1)

Filename/opt/oracle/oradata/conner/users01.dbf.bak

Bifile BIFILE.BBD

ListFile Filelist.txt

BLOCKSIZE 8192

MODE Edit

EDIT Unrecoverable

IBASE Dec

OBASE Dec

WIDTH 80

COUNT 512

LOGFILE LOG.BBD

SPOOL No

Bbed> Copy file 4 block to file 3 block 17;

Warning:contents of previous bifile'll be lost. Proceed? (y/n) Y

File:/OPT/ORACLE/ORADATA/CONNER/USERS01.DBF (3)

Block:17 offsets:0 to 511 dba:0x00c00011

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

06020000 1100c000 75b5a320 00000104 06300000 01000000 611e0000 72b5a320

00000000 03003201 0900c000 ffff0000 00000000 00000000 00000000 00800000

72b5a320 00000000 00000000 00000000 00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00012600

ffff5e00 d5037703 77030000 2600c21e 101e581d a91cf61b 471b941a dd192819

6218b417 06175216 9715dd14 26146c13 b4120712 44118310 bc0ffa0e 380e790d

b60cf40b 350b790a c0090409 45088b07 cc060e06 57059804 d5030000 00000000

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

<32 bytes per line>

Bbed> Verify

Dbverify-verification starting

FILE =/opt/oracle/oradata/conner/users01.dbf

BLOCK = 17

Dbverify-verification Complete

Total Blocks examined:1

Total Blocks processed (Data): 1

Total Blocks Failing (Data): 0

Total Blocks processed (Index): 0

Total Blocks Failing (Index): 0

Total Blocks empty:0

Total Blocks Marked corrupt:0

Total Blocks influx:0

This completes a simple copy recovery with a good data block copy of the intact file.

5. Database Validation

The original link contains detailed table creation and other steps for reference.

Sql> Select COUNT (*) from bbed;

Select COUNT (*) from bbed

*

ERROR at line 1:

Ora-01578:oracle data Block corrupted (file # 3, Block # 17)

Ora-01110:data file 3: '/OPT/ORACLE/ORADATA/CONNER/USERS01.DBF '

Sql> alter tablespace users offline;

Tablespace altered.

sql> alter tablespace users online;

Tablespace altered.

Sql> Select COUNT (*) from bbed;

COUNT (*)

----------

523

The use of bbed can save our database from many tricky issues, as Oracle DBAs need to know about the existence of such a tool.

Using bbed to repair Oracle Bad block recovery method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.