[20180627]测试bbed是否支持管道命令.txt
--//测试bbed是否支持管道命令.txt
1.环境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
SCOTT@test01p> select rowid,dept.* from dept;
ROWID DEPTNO DNAME LOC
------------------ ---------- -------------------- -------------
AAAWh9AAJAAAACFAAA 10 ACCOUNTING NEW YORK
AAAWh9AAJAAAACFAAB 20 RESEARCH DALLAS
AAAWh9AAJAAAACFAAC 30 SALES CHICAGO
AAAWh9AAJAAAACFAAD 40 OPERATIONS DALLAS
SCOTT@test01p> @ rowid AAAWh9AAJAAAACFAAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
92285 9 133 0 0x2400085 9,133 alter system dump datafile 9 block 133 ;
2.测试:
$ cat a.cmd
set dba 9,134
x /rncc *kdbr[0]
quit
--//说明一下,我使用windows下bbed,由于无法识别文件头.存在1个数据块的偏移. 访问的数据块要在原来基础上+1.
d:\tools\bbed>cat a.cmd | bbed parfile=bbed.par cmdfile=cmd.par
BBED: Release 2.0.0.0.0 - Limited Production on Wed Jun 27 20:52:13 2018
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set count 8192
COUNT 8192
BBED> set width 160
WIDTH 160
BBED> DBA 0x02400086 (37748870 9,134)
BBED> rowdata[518] @8140
------------
flag@8140: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8141: 0x00
cols@8142: 3
col 0[2] @8143: 20
col 1[8] @8146: RESEARCH
col 2[6] @8155: DALLAS
--//可以发现支持管道.上班再测试终止符EOF.
3.补充测试linux环境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
SCOTT@book> select rowid,dept.* from dept where rownum=1;
ROWID DEPTNO DNAME LOC
------------------ ---------- -------------- -------------
AAAVRCAAEAAAACHAAA 10 ACCOUNTING NEW YORK
SCOTT@book> @ rowid AAAVRCAAEAAAACHAAA
OBJECT FILE BLOCK ROW ROWID_DBA DBA TEXT
---------- ---------- ---------- ---------- -------------------- -------------------- ----------------------------------------
87106 4 135 0 0x1000087 4,135 alter system dump datafile 4 block 135 ;
--//测试管道:
$ echo x /rncc dba 4,135 *kdbr[0] | rlbbed
BBED: Release 2.0.0.0.0 - Limited Production on Thu Jun 28 08:37:22 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set count 64
COUNT 64
BBED> set width 160
WIDTH 160
BBED> rowdata[66] @8162
-----------
flag@8162: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8163: 0x01
cols@8164: 3
col 0[2] @8165: 10
col 1[10] @8168: ACCOUNTING
col 2[8] @8179: NEW YORK
--//说明:rlbbed 我定义函数,如下:
export RLWRAP=$(which rlwrap)
[ ! -z $RLWRAP ] || { echo 'not exist execution file rlwrap' ; return 7 ; }
rlbbed()
{
cd /home/oracle/bbed
$RLWRAP -s 9999 -c -r -i -f /usr/local/share/rlwrap/bbed $ORACLE_HOME/bin/bbed parfile=bbed.par cmdfile=cmd.par
}
--//测试EOF
$ rlbbed <<EOF
> set dba 4,135
> x /rncc *kdbr[0]
> quit
> EOF
BBED: Release 2.0.0.0.0 - Limited Production on Thu Jun 28 08:39:07 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set count 64
COUNT 64
BBED> set width 160
WIDTH 160
BBED> DBA 0x01000087 (16777351 4,135)
BBED> rowdata[66] @8162
-----------
flag@8162: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8163: 0x01
cols@8164: 3
col 0[2] @8165: 10
col 1[10] @8168: ACCOUNTING
col 2[8] @8179: NEW YORK
BBED>
--//这样可以更好操作bbed,加快恢复工作.例子:
$ rlbbed <<EOF
> set dba 4,135
> $(seq 0 3 | xargs -I{} echo x /rncc *kdbr[{}] )
> quit
> EOF
--//注意$(seq 0 3 | xargs -I{} echo x /rncc *kdbr[{}] ),$与()之间不能有空格.
BBED: Release 2.0.0.0.0 - Limited Production on Thu Jun 28 08:40:04 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> set count 64
COUNT 64
BBED> set width 160
WIDTH 160
BBED> DBA 0x01000087 (16777351 4,135)
BBED> rowdata[66] @8162
-----------
flag@8162: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8163: 0x01
cols@8164: 3
col 0[2] @8165: 10
col 1[10] @8168: ACCOUNTING
col 2[8] @8179: NEW YORK
BBED> rowdata[44] @8140
-----------
flag@8140: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8141: 0x01
cols@8142: 3
col 0[2] @8143: 20
col 1[8] @8146: RESEARCH
col 2[6] @8155: DALLAS
BBED> rowdata[24] @8120
-----------
flag@8120: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8121: 0x01
cols@8122: 3
col 0[2] @8123: 30
col 1[5] @8126: SALES
col 2[7] @8132: CHICAGO
BBED> rowdata[0] @8096
----------
flag@8096: 0x2c (KDRHFL, KDRHFF, KDRHFH)
lock@8097: 0x01
cols@8098: 3
col 0[2] @8099: 40
col 1[10] @8102: OPERATIONS
col 2[6] @8113: BOSTON
--//比如前面做删除sys.bootstrap$的测试,为了获得flag标识状态,可以写成如下:
--//参考链接:http://blog.itpub.net/267265/viewspace-2156149/=>[20180614]删除bootstrap$记录无法启动2
rlbbed <<EOF | grep flag
set dba 1,521
$(seq 0 23 | xargs -I{} echo x /rnnc *kdbr[{}] )
quit
EOF
--//执行如下:
flag@8167: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@8030: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@7641: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@7441: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@7058: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@6846: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@6641: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@6029: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@5823: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@5623: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@5402: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@5198: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@4915: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@4681: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@4434: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@3964: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@3756: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@3541: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@3261: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@2477: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@2272: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@1698: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@1489: 0x2c (KDRHFL, KDRHFF, KDRHFH)
flag@1290: 0x2c (KDRHFL, KDRHFF, KDRHFH)
--//如果写成如下,直接获得修改命令:
rlbbed <<EOF | grep flag | cut -c6-9 | xargs -I{} echo assign dba 1,521 offset {} = 0x2c
set dba 1,521
$(seq 0 23 | xargs -I{} echo x /rnnc *kdbr[{}] )
quit
EOF
$ rlbbed <<EOF | grep flag | cut -c6-9 | xargs -I{} echo assign dba 1,521 offset {} = 0x2c
> set dba 1,521
> $(seq 0 23 | xargs -I{} echo x /rnnc *kdbr[{}] )
> quit
> EOF
assign dba 1,521 offset 8167 = 0x2c
assign dba 1,521 offset 8030 = 0x2c
assign dba 1,521 offset 7641 = 0x2c
assign dba 1,521 offset 7441 = 0x2c
assign dba 1,521 offset 7058 = 0x2c
assign dba 1,521 offset 6846 = 0x2c
assign dba 1,521 offset 6641 = 0x2c
assign dba 1,521 offset 6029 = 0x2c
assign dba 1,521 offset 5823 = 0x2c
assign dba 1,521 offset 5623 = 0x2c
assign dba 1,521 offset 5402 = 0x2c
assign dba 1,521 offset 5198 = 0x2c
assign dba 1,521 offset 4915 = 0x2c
assign dba 1,521 offset 4681 = 0x2c
assign dba 1,521 offset 4434 = 0x2c
assign dba 1,521 offset 3964 = 0x2c
assign dba 1,521 offset 3756 = 0x2c
assign dba 1,521 offset 3541 = 0x2c
assign dba 1,521 offset 3261 = 0x2c
assign dba 1,521 offset 2477 = 0x2c
assign dba 1,521 offset 2272 = 0x2c
assign dba 1,521 offset 1698 = 0x2c
assign dba 1,521 offset 1489 = 0x2c
assign dba 1,521 offset 1290 = 0x2c
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2156932/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/267265/viewspace-2156932/