联系:手机/微信(+86 17813235971) QQ(107644445)
作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]
bbed的功能很强大,可以通过bbed_wrap来获得数据块记录,相当用途:抢救坏块中的数据
环境准备
[oracle@xifenfei ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 12 18:29:50 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> conn chf/xifenfei Connected. SQL> create table t_xifenfei 2 as 3 select object_id,object_name from dba_objects where rownum<20; Table created. SQL> select file_id,block_id,block_id+blocks-1 2 from dba_extents 3 where segment_name ='T_XIFENFEI' AND owner='CHF'; FILE_ID BLOCK_ID BLOCK_ID+BLOCKS-1 ---------- ---------- ----------------- 4 680 687 SQL> alter system checkpoint; System altered. --查询记录 SQL> col object_name for a20 SQL> select object_id,object_name, 2 dbms_rowid.rowid_relative_fno(rowid)rel_fno, 3 dbms_rowid.rowid_block_number(rowid)blockno, 4 dbms_rowid.rowid_row_number(rowid) rowno 5 from chf.t_xifenfei; OBJECT_ID OBJECT_NAME REL_FNO BLOCKNO ROWNO ---------- -------------------- ---------- ---------- ---------- 20 ICOL$ 4 683 0 46 I_USER1 4 683 1 28 CON$ 4 683 2 15 UNDO$ 4 683 3 29 C_COBJ# 4 683 4 3 I_OBJ# 4 683 5 25 PROXY_ROLE_DATA$ 4 683 6 41 I_IND1 4 683 7 54 I_CDEF2 4 683 8 40 I_OBJ5 4 683 9 26 I_PROXY_ROLE_DATA$_1 4 683 10 17 FILE$ 4 683 11 13 UET$ 4 683 12 9 I_FILE#_BLOCK# 4 683 13 43 I_FILE1 4 683 14 51 I_CON1 4 683 15 38 I_OBJ3 4 683 16 7 I_TS# 4 683 17 56 I_CDEF4 4 683 18 19 rows selected.
bbed参数配置
[oracle@xifenfei ~]$ more bbed_file 1 /u01/oracle/oradata/ora11g/system01.dbf 2 /u01/oracle/oradata/ora11g/sysaux01.dbf 3 /u01/oracle/oradata/ora11g/undotbs01.dbf 4 /u01/oracle/oradata/ora11g/users01.dbf 5 /u01/oracle/oradata/ora11g/dbfs01.dbf [oracle@xifenfei ~]$ more bbed.par blocksize=8192 listfile=/home/oracle/bbed_file mode=browse SILENT=yes PASSWORD=blockedit
bbed_wrap脚本执行
[oracle@xifenfei ~]$ ./bbed_wrap.sh 4 683 "/rn2cntn" There are 19 rows in block 683 on file 4 " 20 "," ICOL$" " 46 "," I_USER1" " 28 "," CON$" " 15 "," UNDO$" " 29 "," C_COBJ#" " 3 "," I_OBJ#" " 25 "," PROXY_ROLE_DATA$" " 41 "," I_IND1" " 54 "," I_CDEF2" " 40 "," I_OBJ5" " 26 "," I_PROXY_ROLE_DATA$_1" " 17 "," FILE$" " 13 "," UET$" " 9 "," I_FILE#_BLOCK#" " 43 "," I_FILE1" " 51 "," I_CON1" " 38 "," I_OBJ3" " 7 "," I_TS#" " 56 "," I_CDEF4" --和我们查询的结果完全一致
飞总,bbed_wrap.sh脚本能贴给我吗?
我自己写的如下部分,不知道bbed 怎么与shell结合交互,麻烦请教一下,谢谢。
#!/bin/bash
#/rn2cntn
bbed parfile=/home/oracle/bbed.par<<EOF
set file $1 block $2
a=p kdbr|wc -l
#p *kdbr[0]
x$3
EOF
echo "There are" a "rows in block" $2 "on file" $1
bbed_wrap是oracle internal的脚本,不太直接方便对外提供