没有合适的资源?快使用搜索试试~ 我知道了~
ORACLE_bbed_五个试用教程,使用BBED特殊手段恢复误删除的数据,块损坏导致数据库无法启动,数据文件头损坏导致库无法启动的问题都可以使用BBED解决
资源推荐
资源详情
资源评论
在之前的 blog 里介绍了 BBED 工具的语法部分。 参考:
Oracle BBED 工具 说明
http://blog.csdn.net/tianlesoftware/article/details/5006580
在这篇主要看一下 BBED 工具的几个使用示例。
Althoughbbed can modify data in the data files of an open Oracle database, it
isadvisable to shut down the database before making any changes. This avoids
thecheckpoint process overwriting the changes made with bbed from the Oracle
blockcache. It also avoids Oracle reading the block before the modifications arecomplete
and declaring the block corrupt.
虽然 bbed 可以在 db open 状态来进行修改,但是建议在做任何修改操作之前先
shutdown db。 这样避免 checkpoint 进程重写 bbed 对 block 的修改。 也避免 oracle 在
bbed 修改完成之前读 block 或者申明 block 为 corrupt。
Important:Using bbed to modify the contents of an Oracle data block renders the
dataun-supported by Oracle. These examples should be used for educational
purposesonly. If they are used on real production databases they should only be used
asa last resort and once the immediate problem has been resolved, all retrievabledata
should be exported and a new database created.
bbed 工具不受 Oracle 的技术支持。
Although bbed can be used to open a database that would otherwise be beyond
salvaging,the DBA must bear in mind that the internal tables such as OBJ$, UET$ and
FET$may no longer match the contents of the data blocks. The behavior of thedatabase
will therefore be unpredictable and ORA-600 errors are likely.
一. 示例: 修改 Data 内容
1.1 连接 bbed
[oracle@db2 ~]$ bbed parfile=/u01/bbed.par
Password:
BBED: Release 2.0.0.0.0 - LimitedProduction on Fri Aug 12 18:26:46 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
************* !!! For Oracle Internal Useonly !!! ***************
BBED>
1.2 查看要修改的内容
SYS@dave2(db2)> select * from dvd;
JOB
--------------------------------------------------------------------------------
Dave is DBA!
Dave like Oracle!
注意: bbed 的修改仅仅是对原有位置内容的一个替换。
对应 block 的信息如下:
SYS@dave2(db2)> 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 t1;
ROWID REL_FNO BLOCKNO ROWNO
------------------ ---------- --------------------
AAAN9VAABAAAcKiAAA 1 115362 0
AAAN9VAABAAAcKiAAB 1 115362 1
SYS@dave2(db2)>
1.3 查找关键字 Dave,确定其在 block 中的偏移量 offset。
BBED> set dba 1,115362 offset 0
DBA 0x0041c2a2(4309666 1,115362)
OFFSET 0
BBED> find /c Dave
File:/u01/app/oracle/oradata/dave2/system01.dbf (1)
Block: 115362 Offsets: 8176 to 8191 Dba:0x0041c2a2
------------------------------------------------------------------------
44617665 20697320 44424121 020616b3
<32 bytes per line>
dump 查看具体内容:
BBED> dump /v dba 1,115362 offset 8176count 128
File: /u01/app/oracle/oradata/dave2/system01.dbf(1)
Block: 115362 Offsets: 8176 to 8191 Dba:0x0041c2a2
-------------------------------------------------------
44617665 20697320 44424121 020616b3 l Dave isDBA!...³
<16 bytes per line>
注意这里面的 Offsets:8176 to 8191, 它指的是这一行的一个地址。其中
D 的 offset 是 8176
a 的 offset 是 8177
v 的 offset 是 8178
e 的 offset 是 8179
空格也算 offset。
1.4 修改 block,将 Dave 换成 DMM
BBED> modify /c 'DMM ' dba 1,115362offset 8176
File:/u01/app/oracle/oradata/dave2/system01.dbf (1)
Block: 115362 Offsets: 8176 to 8191 Dba:0x0041c2a2
------------------------------------------------------------------------
444d4d20 20697320 44424121 020616b3
<32 bytes per line>
--注意这里 DMM 我用单引号括起来,并且最后还有一个空格,这样就是 4 个 bytes,不用
单引号括起来,无法表示空格,验证一下
BBED> dump /v dba 1,115362 offset 8176count 128
File:/u01/app/oracle/oradata/dave2/system01.dbf (1)
Block: 115362 Offsets: 8176 to 8191 Dba:0x0041c2a2
-------------------------------------------------------
444d4d20 20697320 44424121 020616b3 l DMM is DBA!...³
<16 bytes per line>
1.5 应用变更
BBED> sum dba 1,115362
Check value for File 1, Block 115362:
current = 0xdef7, required = 0x8cc0
此时 current checksum 是 0xdef7,requiredchecksum 是 0x8cc0
BBED> sum dba 1,115362 apply
Check value for File 1, Block 115362:
current = 0x8cc0, required = 0x8cc0
加上 apply 参数,使 checksum 一致。即之前的修改生效。
SYS@dave2(db2)> alter system flush buffer_cache;
System altered.
SYS@dave2(db2)> select * from dvd;
JOB
--------------------------------------------------------------------------------
DMM is DBA!
Dave like Oracle!
二. 示例:恢复 delete 的 rows
Whenrows are deleted in Oracle the data is not actually removed. The row is
simplymarked as deleted and the free space counters and pointers adjustedaccordingly.
The status of a row is stored in the Row Header which occupies thefirst few bytes of each
row.
当 row 被 delete 的时候,实际上 data 并没有被 remove,只是将该 row 标记为
delete,然后其对应的空间被统计为 free space。 row 的 status 存在每个 row 的 row
header 里。
TheRow Header consists of the Row Flag, Lock Byte (ITL entry) and Column
Count.The first of these - the Row Flag - is a single byte that holds a bitmask thatshows
the status of the row. The bitmask is decoded as follows:
RowHeader 包含 Row Flag,Lock Byte(ITL)和 column Count。其中 Row Flag 占
用 1 个 byte,并且以 bitmask 来保存。bitmask 的解释如下:
Cluster Key
Cluster Table Member Head of row piece Deleted First data piece Last data piece 1st Column continues from previous piece
128 64 32 16 8 4 2
我们 dump 一个 block,看一个 row Flag,来帮助理解这个 bitmask。
SYS@dave2(db2)> alter system dump datafile1 block 115362;
System altered.
SYS@dave2(db2)> oradebug setmypid
Statement processed.
SYS@dave2(db2)> oradebug tracefile_name
/u01/app/oracle/admin/dave2/udump/dave2_ora_9396.trc
trace file 有关 row 的信息如下:
block_row_dump:
tab 0, row 0, @0x1f90
tl: 16 fb: --H-FL--lb: 0x1 cc: 1
col 0: [12] 44 4d 4d 20 20 69 73 2044 42 41 21
tab 0, row 1, @0x1f7b
tl: 21 fb: --H-FL-- lb: 0x2 cc: 1
col 0: [17] 64 6d 6d 65 20 6c 69 6b65 20 4f 72 61 63 6c 65 21
end_of_block_dump
我们的表 dvd 里只有 2 行记录,所以这里显示的 row 为 2.
注意这里的 fb: --H-FL--。 其有 8 个选项,每个值分别与 bitmask 对应。
Therefore,columns that fit within a single block, are not chained, migrated or part of
aclustered table and are not deleted will have the following attributes:
(1)Head of Row Piece
(2)First Data Piece
(3)Last Data Piece
如果一个 row 没有被删除,那么它就具有上面的 3 个属性,即 Flag 表示为:--H-FL--.
这里的字母分别代表属性的首字母。其对应的值:32 + 8 + 4 =44 or 0x2c.
如果一个 row 被 delete 了,那么 row flag 就会更新,bitmask 里的 deleted 被设置为
16. 此时 row flag 为: 32 + 16 + 8 + 4 = 60 or 0x3c.
验证一下:
SYS@dave2(db2)> delete from dvd whererownum=1;
1 row deleted.
SYS@dave2(db2)> commit;
Commit complete.
查看 dump 的标记:
block_row_dump:
tab 0, row 0, @0x1f90
tl: 2 fb: --HDFL--lb: 0x1
tab 0, row 1, @0x1f7b
tl: 21 fb: --H-FL-- lb: 0x0 cc: 1
col 0: [17] 64 6d 6d 65 20 6c 69 6b65 20 4f 72 61 63 6c 65 21
end_of_block_dump
这里的 row 1flag 变成了--HDFL--。
现在我们用 bbed 将删除的 row 1 内容找回来。
BBED> set dba1,115362 offset 0
DBA 0x0041c2a2(4309666 1,115362)
OFFSET 0
BBED> find /c DMM
File: /u01/app/oracle/oradata/dave2/system01.dbf(1)
Block: 115362 Offsets: 8176 to 8191 Dba:0x0041c2a2
剩余26页未读,继续阅读
资源评论
oracle_liuchao
- 粉丝: 0
- 资源: 67
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功