BBED (Block Browser and Editor)

 

< BBED 를 이용한 Block Recovery >

- Block 을 탐색하고 수정하는 유틸리티

- 사용을 위해서는 Linking 작업이 추가로 필요

 

10g Version

[oracle@rac1 lib]$ pwd

/home/oracle/product/10g/db/rdbms/lib

[oracle@rac1 lib]$ make -f ins_rdbms.mk

/home/oracle/product/10g/db/rdbms/lib/bbed

[oracle@rac1 lib]$ pwd

/home/oracle/product/10g/db/rdbms/lib

[oracle@rac1 lib]$ ls -l bbed

-rwxr-xr-x 1 oracle dba 554330 10월 21 15:33 bbed

[oracle@rac1 lib]$ cp bbed $ORACLE_HOME/bin/

[oracle@rac1 lib]$

Next Step – 모든 Version 동일

[oracle@rac1 lib]$ bbed

Password: blockedit (기본 암호)

 

BBED: Release 2.0.0.0.0 - Limited Production on Fri Oct 21 15:39:55 2011

 

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

 

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

 

BBED>

 

BBED Option

 

옵션명

설명

BLOCKSIZE

편집할 데이터 파일의 블록 사이즈를 적어줍니다.

MODE 

BBED를 실행할 모드를 설정합니다.(browser or edit)

SILENT 

작업결과를 표준 출력으로 보여줄지를 제어(Y,N)

SPOOL

BBED 작업 log 를 bbed.log 파일에 저장할 것인지를 제어 (Y, N)

LISTFILE

작업할 파일의 목록을 적어줍니다.

CMDFILE 

실행할 파일들의 목록을 적어줍니다.

BIFILE

변경 전 파일의 이미지를 저장할 파일명을 적어줍니다.(기본값-Bifile.bbd)

LOGFILE

User log를 저장할 파일명을 지정합니다.(기본값- log.bbd)

PARFILE

BBED 를 실행할 때 사용할 파라미터 등을 적어주는 파일명을 지정합니다.

 

예제 (옵션사용)

 

SQL> select file#||' '||name||' '||bytes from v$datafile;

 

- 위 내용을 list file 을 만들어서 거기에 등록하고 listfile 옵션을 사용하여 bbed 를 실행

1 /dev/raw/raw6 628097024

2 /dev/raw/raw8 208666624

3 /dev/raw/raw7 313524224

4 /dev/raw/raw9 208666624

5 /dev/raw/raw10 9437184

6 /dev/raw/raw28 52428800

7 /dev/raw/raw30 20971520

8 /dev/raw/raw31 8388608

 

[oracle@rac1 lib]$ cd ~

[oracle@rac1 ~]$ vi filelist.log

[oracle@rac1 ~]$

 

[oracle@rac1 ~]$ vi bbed.par

blocksize=8192

listfile=/home/oracle/filelist.log

mode=edit

 

[oracle@rac1 ~]$ bbed parfile=bbed.par

 

BBED 명령어

 

1) help all

- BBED 관련 도움말을 보여 줍니다.

 

2) set dba

- 작업하고자 하는 데이터 파일과 블록을 지정.

- 여기에 지정될 데이터 파일은 listfile 에 등록되어 있어야 함

BBED> set dba 2,50

DBA 0x00800032 (8388658 2,50)

 

BBED>

- 위 명령은 2번 파일의 50번 블록에 작업을 하겠다고 설정하는 것입니다.

 

3) set filename

- 작업할 데이터 파일을 이름으로 지정합니다.

BBED> set filename '/dev/raw/raw30'

FILENAME /dev/raw/raw30

 

4) set file

- 작업할 데이터 파일을 번호로 지정합니다.

BBED> set file 8;

FILE# 8

 

5) set block

- 현재 설정되어 있는 파일에서 작업을 원하는 block 을 지정합니다.

BBED> set block 20

BLOCK# 20

 

6) set offset

- 현재 작업하기 원하는 offset 번호를 지정합니다.

 

7) set blocksize

- 현재 작업하는 파일의 blocksize 를 지정합니다.

BBED> set blocksize 8192

BLOCKSIZE 8192

 

8) set listfile

- 작업을 수행할 파일의 목록이 적혀있는 list file 을 지정합니다.

BBED> set listfile '/home/oracle/filelist.log'

LISTFILE /home/oracle/filelist.log

 

9) set width

- 현재 보이는 화면의 폭을 지정합니다.

BBED> set width 200

WIDTH 200

 

10) set count

- Dump 명령어 수행시 화면에 보여줄 data block 의 byte 수를 지정합니다.

BBED> set count 100

COUNT 100'

 

11) set ibase

- 내부적으로 사용되는 값들의 표현식을 지정합니다.

- 기본값은 10진수이며 16진수(Hexadecimal) 이나 8진수(Octal) 로 변경 가능합니다.

 

12) set obase

- 기능 모름

 

13) set mode

- BBED 수행 mode 를 설정 합니다.

 

14) set spool

- 기능 모름

 

15) show

- 현재 설정되어 있는 내용들을 보여줍니다.

BBED> show

FILE# 1

BLOCK# 1

OFFSET 0

DBA 0x00400001 (4194305 1,1)

FILENAME /dev/raw/raw6

BIFILE bifile.bbd

LISTFILE /home/oracle/filelist.log

BLOCKSIZE 8192

MODE Edit

EDIT Unrecoverable

IBASE Dec

OBASE Dec

WIDTH 200

COUNT 100

LOGFILE log.bbd

SPOOL No

 

16) info

- 현재 작업중인 파일 내용을 보여줍니다.

BBED> info

File# Name Size(blks)

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

1 /dev/raw/raw6 76672

2 /dev/raw/raw8 25472

3 /dev/raw/raw7 38272

4 /dev/raw/raw9 25472

5 /dev/raw/raw10 1152

6 /dev/raw/raw28 6400

7 /dev/raw/raw30 2560

8 /dev/raw/raw31 1024

 

17) map

- 현재 작업중인 블록에 대한 자세한 정보를 보여줍니다.

BBED> map /v dba 1,20

File: /dev/raw/raw6 (1)

Block: 20 Dba:0x00400014

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

Undo Data

 

struct kcbh, 20 bytes @0

ub1 type_kcbh @0

ub1 frmt_kcbh @1

ub1 spare1_kcbh @2

ub1 spare2_kcbh @3

ub4 rdba_kcbh @4

ub4 bas_kcbh @8

ub2 wrp_kcbh @12

ub1 seq_kcbh @14

ub1 flg_kcbh @15

ub2 chkval_kcbh @16

ub2 spare3_kcbh @18

 

struct ktubh, 82 bytes @20

struct ktubhxid, 8 bytes @20

ub2 ktubhseq @28

ub1 ktubhcnt @30

ub1 ktubhirb @31

ub1 ktubhicl @32

ub1 ktubhflg @33

ub2 ktubhidx[34] @34

 

ub1 freespace[346] @102

 

ub1 undodata[7740] @448

 

ub4 tailchk @8188

 

18) dump

- Block 의 내용을 실제 dump 해서 화면에 보여주는 명령어

- 자세한 내용을 알기 위해 /v 옵션을 함께 사용하는 경우가 많습니다.

- DBA, filename, file, block, offset 등 set 명령어로 설정된 값들을 다 조회 가능

 

- 다음은 1번 파일의 10번 블록을 offset 1-127 번까지 dump 를 수행한 내용입니다.

BBED> set width 100

WIDTH 100

 

BBED> dump /v dba 1,10 offset 0 count 128

File: /dev/raw/raw6 (1)

Block: 10 Offsets: 0 to 127 Dba:0x0040000a

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

02a20000 0a004000 4e870200 00000104 l ......@.N.......

284e0000 00004800 27000000 36001f1f l (N....H.'...6...

0000e81f ec1ef01d f41cf81b fc1a001a l ................

04190818 0c171016 14151814 1c132012 l .............. .

24112810 2c0f300e 340d380c 3c0b400a l $.(.,.0.4.8.<.@.

44094808 4c075006 54055804 5c036002 l D.H.L.P.T.X.\.`.

64010000 00000000 00000000 00000000 l d...............

00000000 00000000 00000000 00000000 l ................

 

<16 bytes per line>

 

19) (p)rint

- 현재 작업중인 정보를 보여줍니다.

BBED> p

kcbh.type_kcbh

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

ub1 type_kcbh @0 0x02

 

BBED> p kcbh

struct kcbh, 20 bytes @0

ub1 type_kcbh @0 0x02

ub1 frmt_kcbh @1 0xa2

ub1 spare1_kcbh @2 0x00

ub1 spare2_kcbh @3 0x00

ub4 rdba_kcbh @4 0x0040000a

ub4 bas_kcbh @8 0x0002874e

ub2 wrp_kcbh @12 0x0000

ub1 seq_kcbh @14 0x01

ub1 flg_kcbh @15 0x04 (KCBHFCKV)

ub2 chkval_kcbh @16 0x4e28

ub2 spare3_kcbh @18 0x0000

 

BBED>

 

20) e(x)amine

- 이 명령어는 DBA, filename, file, block, offset 등의 값을 정해진 포멧형식으로 보여줍니다.

BBED> x

kcbh.type_kcbh @0

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

0x02

 

BBED> x /2

kcbh.type_kcbh @0

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

0x02 0xa2

 

BBED> x /b

kcbh.type_kcbh @0

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

0x02

 

BBED> x /h

kcbh.type_kcbh @0

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

0xa202

 

BBED> x /w

kcbh.type_kcbh @0

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

0x0000a202

 

BBED> x /l

kcbh.type_kcbh @0

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

0x0000a202

 

BBED> x /r

kcbh.type_kcbh @0

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

BBED-00402: operation only allowed for data/index blocks

 

- 옵션

/b : bytes 단위로 보여줌

/h : half-word 단위로 보여줌

/w : word 단위로 보여줌

/l : long 단위로 보여줌

/r : table/index row 를 보여줌

 

21) (f)ind

- 원하는 데이터를 찾아내는 기능

 

BBED> set file 7

FILE# 7

 

BBED> show

FILE# 7

BLOCK# 10

OFFSET 0

DBA 0x01c0000a (29360138 7,10)

FILENAME /dev/raw/raw30

BIFILE bifile.bbd

LISTFILE /home/oracle/filelist.log

BLOCKSIZE 8192

MODE Edit

EDIT Unrecoverable

IBASE Dec

OBASE Dec

WIDTH 100

COUNT 128

LOGFILE log.bbd

SPOOL No

 

BBED> find /c EW

File: /dev/raw/raw28 (6)

Block: 1 Offsets: 342 to 391 Dba:0x01800001

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

45570000 00000000 00000000 00000000 00000000 00000000 00000600 00000000

00000000 00009671 982d0000 00000000 0000

 

<32 bytes per line>

 

BBED>

BBED> d /v dba 6,1 offset 342 count 50

File: /dev/raw/raw28 (6)

Block: 1 Offsets: 342 to 391 Dba:0x01800001

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

45570000 00000000 00000000 00000000 l EW..............

00000000 00000000 00000600 00000000 l ................

00000000 00009671 982d0000 00000000 l .......q.-......

0000 l ..

 

<16 bytes per line>

 

BBED>

 

- find 명령어와 쓸 수 있는 옵션

/x : 16진수 값을 찾습니다.

/d : 10진수 값을 찾습니다.

/u : 부호없는 10진수 값을 찾습니다.

/o : 8진수 값을 찾습니다.

/c : 문자값을 찾습니다.

à find 명령어는 날짜와 숫자 값 검색은 지원하지 않습니다.

 

22) copy

- 이 명령어는 블록을 복사하는 명령어

 

 

BBED> copy dba 6,1 to dba 7,1

File: /dev/raw/raw30 (7)

Block: 1 Offsets: 342 to 391 Dba:0x01c00001

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

45570000 00000000 00000000 00000000 00000000 00000000 00000600 00000000

00000000 00009671 982d0000 00000000 0000

 

<32 bytes per line>

 

BBED>

- 위 명령어는 6번 파일의 1번 블록을 7번 파일의 1번 블록으로 복사하라는 명령어

- 이 명령어는 백업 파일에서 특정 블록만을 운영 파일 등으로 복사해 올 때만 조심해서 사용해야 합니다.

 

+ Recent posts