[20180627]測試bbed是否支援管道命令.txt

lfree發表於2018-06-28

[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/,如需轉載,請註明出處,否則將追究法律責任。

相關文章