Oracle异常恢复BBED系列

0    525    1

Tags:

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

BBED基本命令

先看帮助的说明:

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 [ \<SET parameter> | ALL ]

INFO

MAP[/v] [ DBA | FILENAME | FILE | BLOCK ]

DUMP[/v] [ DBA | FILENAME | FILE | BLOCK |OFFSET | COUNT ]

PRINT[/x|d|u|o|c] [ DBA | FILE | FILENAME |BLOCK | OFFSET | symbol | *symbol ]

EXAMINE[/Nuf] [ DBA | FILE | FILENAME |BLOCK | OFFSET | symbol | *symbol ]

\</Nuf>:

N - a number which specifies a repeatcount.

u - a letter which specifies a unit size:

b -b1, ub1 (byte)

h -b2, ub2 (half-word)

w -b4, ub4(word)

r -Oracle table/index row

f - a letter which specifies a displayformat:

x -hexadecimal

d -decimal

u -unsigned decimal

o -octal

c -character (native)

n -Oracle number

t -Oracle date

i -Oracle rowid

FIND[/x|d|u|o|c] numeric/character string [TOP | CURR ]

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

MODIFY[/x|d|u|o|c] numeric/character string

[ DBA | FILE | FILENAME | BLOCK | OFFSET | symbol | *symbol ]

ASSIGN[/x|d|u|o] \<targetspec>=\<source spec>

\<target spec> : [ DBA | FILE |FILENAME | BLOCK | OFFSET | symbol | *symbol ]

\<source spec> : [ value | \<targetspec options> ]

SUM [ DBA | FILE | FILENAME | BLOCK ] [APPLY ]

PUSH [ DBA | FILE | FILENAME | BLOCK |OFFSET ]

POP [ALL]

REVERT [ DBA | FILE | FILENAME | BLOCK ]

UNDO

HELP [ \<bbed command> | ALL ]

VERIFY [ DBA | FILE | FILENAME | BLOCK ]

CORRUPT [ DBA | FILE | FILENAME | BLOCK ]

下面是几个常用的:

set 设定当前的环境

show 查看当前的环境参数,跟sqlplus的同名命令类似。

dump 列出指定block的内容

find 在指定的block中查找指定的字符串,结果是显示出字符串,及其偏移量--offset,偏移量就是在block中的字节数

modify 修改指定block的指定偏移量的值,可以在线修改。

copy 把一个block的内容copy到另一个block中

verify 检查当前环境是否有坏块

sum 计算block的checksum,modify之后block就被标识为坏块,current checksum与reqired checksum不一致,sum命令可以计算出新的checksum并应用到当前块。

undo 回滚当前的修改操作,如果手误做错了,undo一下就ok了,回到原来的状态。

revert 回滚所有之前的修改操作,意思就是 undo all

SET 命令

set dba

Set the current data block using the standard Oracle DBA (Data Block Address)format. This is entered as file_id, block.

关于DBA 说明,参考:Oracle rdba和 dba 说明 http://blog.csdn.net/tianlesoftware/article/details/6529346

select rowid,

dbms_rowid.rowid_relative_fno(rowid)rel_fno,

dbms_rowid.rowid_block_number(rowid)blockno,

dbms_rowid.rowid_row_number(rowid) rowno

from scott.emp;

Oracle异常恢复BBED系列

set dba 4,145

Oracle异常恢复BBED系列

如果设置成功,会返回该block的RDBA (Relative Data Block Address),rdba就是rowid中的rfile#+block#。括号里面的是DBA值和block 和 file id。 我们验证一下:

sqlplus执行:

variable dba varchar2(30);

exec :dba :=dbms_utility.make_data_block_address(4,145);

print dba

Oracle异常恢复BBED系列

set filename

Sets the current file to the one specified. It must be a valid Oracle data file andit must be enclosed in single quotes. If the file is not in the current path itmust also be fully qualified. If successful, bbed will respond showing the filenow being accessed.

BBED> set filename '/u01/app/oracle/oradata/dave2/users01.dbf'

FILENAME /u01/app/oracle/oradata/dave2/users01.dbf

--必须是一个有效的datafile,并且用单引号括起来

set file

Sets the current file to the number specified. The number specified must be one ofthe file ids supplied in the filelist referenced at startup. If successful,bbed will respond showing the file id now being accessed.

BBED> set file 4

FILE# 4

--注意这里的number,是我们之前配置的filelist里的number。它可以和我们db 里的file id 不一样。 不过最好是配置一样的。

set block

Sets the current block. The block is relative to the filename or file already set.The absolute block can be specified, or an offset to the current block can bespecified using the plus (+) or (-) symbols. If successful, bbed will respondshowing the current block.

--注意这里的block 是一个相对的位置,我们需要先指定一个file,然后在指定block。 即对应file里的block。可以对当前block的位置进行+和-操作。

BBED> set file 4

FILE# 4

BBED> set block 60882

BBED-00309: out of range block number(60882)

BBED> set file 1

FILE# 1

BBED> set block 60882

BLOCK# 60882

BBED> set bock +10

BBED-00202: invalid parameter (bock)

BBED> set block +10

BLOCK# 60892

BBED> set block -10

BLOCK# 60882

BBED> set file 4 block 520

FILE# 4

BLOCK# 520

BBED> set dba 4,520

DBA 0x01000208 (16777736 4,520)

set offset

Sets the current offset. The offset is relative to the block already set. Theabsolute offset can be specified, or an offset to the current offset can bespecified using the plus (+) or minus (-) symbols. If successful, bbed willrespond showing the current offset.

--偏移量是相对某个block里的偏移量,可以用+和-进行操作

BBED> set offset 20

OFFSET 20

BBED> set offset +2

OFFSET 22

BBED> set offset -2

OFFSET 20

set blocksize

Sets the blocksize of the current file. The blocksize must match the file selectedor an error will be reported. If successful, bbed will respond showing thecurrent blocksize.

设置当前datafile 的blocksize 大小,该大小必须和datafile 的实际block 匹配,否则会报错。

BBED> set blocksize 8192

BLOCKSIZE 8192

set listfile

Sets the listfile to the specified file. This option can be used if the listfile wasnot specified on the command line. The listfile must be enclosed in singlequotes. If successful, bbed will respond showing the current listfile.

--在前面讲过,可以通过parameter file 来指定bbed的属性,当然也可以通过set 来指定这些信息。对于listfile的文件,必须用单引号括起来。

BBED> set listfile '/u01/filelist.txt'

LISTFILE /u01/filelist.txt

set width

Sets the current screen width. If not specified bbed will assume an 80-characterdisplay.

设定当前屏幕的宽度,默认是80.

BBED> set width 200

WIDTH 200

set count

Sets the number of bytes of the data block to display from the dump command. Thedefault is 512.

Tosee an entire 8Kb block therefore you would need to dump the block eight timesat offsets 0, 512, 1024, 1536, 2048, 2560, 3092 and 3604.

By setting the count higher bbed will dump more of the block each time. Byreducing it a smaller dump can be achieved.

设置dump 命令显示bytes的数量。默认是512 bytes。

BBED> set count 512

COUNT 512

set ibase

Sets the internal number base. The default is decimal. However it can also be set tohexadecimal or octal. This allows the set file, set block and set offsetcommands to use an alternate base to decimal. If successful, bbed will respondshowing the current base:

--设置内部的数字格式,默认是十进制。 也可以设置为十六进制或者八进制。设置完数字格式之后,可是使用该格式来设置blcok,offset等。

BBED> set ibase hex

IBASE Hex

BBED> set block +D

BLOCK# 14

BBED> set ibase decimal

IBASE Dec

set mode

Sets the bbed mode. The options are browse or edit. In browse mode no changes can bemade. This is the suggested mode for first-time users, or if you are intendingto use the tool only to inspect data blocks.

--设置bbed 的模式,该默认有2种:browse 和 edit。 browse 模式不允许进行修改。 如果要修改,就选择edit模式。 这个在我们的之前的配置文件里,我们选择了edit。

BBED> set mode browse

MODE Browse

BBED> set mode edit

MODE Edit

show 命令

显示当前的配置选项。

show

Oracle异常恢复BBED系列

BBED> show

FILE# 1

BLOCK# 14

OFFSET 0

DBA 0x0040000e(4194318 1,14)

--注意这里的block 变成了14. 是我们刚才设置的。

FILENAME /u01/app/oracle/oradata/dave2/system01.dbf

BIFILE bifile.bbd

LISTFILE /u01/filelist.txt

BLOCKSIZE 8192

MODE Edit

EDIT Unrecoverable

IBASE Dec

OBASE Dec

WIDTH 200

COUNT 512

LOGFILE log.bbd

SPOOL No

info

显示当前可以进行browse 或者edit 的file。即我们filelist 里指定的datafile信息

Info

Oracle异常恢复BBED系列

map

The map command shows a map of the current block. It can be combined with the /voption to produce a more verbose output. The map shows the offsets throughout the block where certain information can be found such as the block header, the data block header or the row directory.

If the set commands have not been used to set a current block, or it the user simply wishes to examine another block while keeping the current block their focus,the file name, file id, block or DBA can be specified with the command.

Map会通过偏移量来显示block里的详细信息,如block header,data block header 和row directory。 使用/v 选项,可以查看更详细的信息

在不指定block的情况下,会显示当前block的信息,如果想显示其他block的信息,可以使用file name,file id,block 和DBA 来指定要显示的block。

--通过dba 来指定某个block

map /v dba 4,145

Oracle异常恢复BBED系列

本人提供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群
  • 个人微店

  • 回到顶部