[20210901]cygwin下使用bbed.txt
[20210901]cygwin下使用bbed.txt
--//工作需要,測試在cygwin下使用bbed,主要是這樣的方式可以使用bash shell程式設計,編寫指令碼比windows批處理方面不少.
--//首先我的bbed安裝在D:\tools\bbed目錄下,windows下的bbed一般來自oracle 9i for windows的安裝包,許多文章都有介紹如何移植.
--//我的cygwin64安裝在D:\tools\cygwin64目錄.
$ mount | grep /cygdrive/d
D: on /cygdrive/d type ntfs (binary,posix=0,user,noumount,auto)
$ cd /cygdrive/d/tools/bbed
$ cat bbed1.bat
@echo off
bbed parfile=bbed.par cmdfile=cmd.par
$ cat cmd.par
set count 8192
set width 160
$ cat bbed.par
blocksize=8192
listfile=d:\tools\bbed\filelist.txt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mode=edit
PASSWORD=blockedit
--//我最擔心的是無法訪問listfile的檔案列表.
$ ./bbed1.bat
BBED: Release 2.0.0.0.0 - Limited Production on Tue Aug 31 19:54:16 2021
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> info
File# Name Size(blks)
----- ---- ----------
1 D:\APP\ORACLE\ORADATA\TEST\SYSTEM01.DBF 0
2 D:\APP\ORACLE\ORADATA\TEST\PDBSEED\SYSTEM01.DBF 0
3 D:\APP\ORACLE\ORADATA\TEST\SYSAUX01.DBF 0
4 D:\APP\ORACLE\ORADATA\TEST\PDBSEED\SYSAUX01.DBF 0
5 D:\APP\ORACLE\ORADATA\TEST\UNDOTBS01.DBF 0
6 D:\APP\ORACLE\ORADATA\TEST\PDBSEED\UNDOTBS01.DBF 0
7 D:\APP\ORACLE\ORADATA\TEST\USERS01.DBF 0
8 D:\APP\ORACLE\ORADATA\TEST\TEST01P\SYSTEM01.DBF 0
9 D:\APP\ORACLE\ORADATA\TEST\TEST01P\SYSAUX01.DBF 0
10 D:\APP\ORACLE\ORADATA\TEST\TEST01P\UNDOTBS01.DBF 0
11 D:\APP\ORACLE\ORADATA\TEST\TEST01P\USERS01.DBF 0
28 D:\APP\ORACLE\ORADATA\TEST\TEST02P\SYSTEM01.DBF 0
29 D:\APP\ORACLE\ORADATA\TEST\TEST02P\SYSAUX01.DBF 0
30 D:\APP\ORACLE\ORADATA\TEST\TEST02P\UNDOTBS01.DBF 0
31 D:\APP\ORACLE\ORADATA\TEST\TEST02P\USERS01.DBF 0
36 D:\APP\ORACLE\ORADATA\TEST\TEST01P\LFREE05X.DBF 0
--//OK,顯示檔案列表沒有問題.看看是否可以訪問對應資料塊.
BBED> x /rncc dba 11,133 *kdbr[0]
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
--//注意:訪問的塊要+1.因為bbed for windows的版本無法識別10g以上的資料檔案的OS頭也就是第0塊.
--//OK.
--//在/usr/local/bin目錄下建立rlbbed檔案.
$ cd /usr/local/bin
$ cat rlbbed
cd /cygdrive/d/tools/bbed/
./bbed1.bat
--//注意:一定要執行cd /cygdrive/d/tools/bbed/ ,不然一些檔案如bbed.par無法訪問.
$ chmod 750 rlbbed
$ echo "x /rncc dba 11,133 *kdbr[0]" | rlbbed
BBED: Release 2.0.0.0.0 - Limited Production on Tue Aug 31 20:08:41 2021
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> 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
--//OK,使用基本沒有問題了.
--//不過windows 的bbed好麻煩,它的輸出是dos的文字格式多了1個\r字元.另外注意幾點塊要+1,訪問檔案頭不對.
--//測試一下我寫的bash shell讀取資料塊的指令碼:
$ . fff.sh 11 133 133 22487 ncc
10|ACCOUNTING|NEW YORK
20|RESEARCH|DALLAS
30|SALES|CHICAGO
40|OPERATIONS|BOSTON
$ . fff.sh 1 522 524 59 nnc | grep -i undo > aaa.txt
--//好慢.
$ cat aaa.txt
16|16|CREATE TABLE TS$("TS#" NUMBER NOT NULL,"NAME" VARCHAR2(30) NOT NULL,"OWNER#" NUMBER NOT NULL,"ONLINE$" NUMBER NOT NULL,"CONTENTS$" NUMBER NOT NULL,"UNDOFILE#" NUMBER,"UNDOBLOCK#" NUMBER,"BLOCKSIZE" NUMBER NOT NULL,"INC#" NUMBER NOT NULL,"SCNWRP" NUMBER,"SCNBAS" NUMBER,"DFLMINEXT" NUMBER NOT NULL,"DFLMAXEXT" NUMBER NOT NULL,"DFLINIT" NUMBER NOT NULL,"DFLINCR" NUMBER NOT NULL,"DFLMINLEN" NUMBER NOT NULL,"DFLEXTPCT" NUMBER NOT NULL,"DFLOGGING" NUMBER NOT NULL,"AFFSTRENGTH" NUMBER NOT NULL,"BITMAPPED" NUMBER NOT NULL,"PLUGGED" NUMBER NOT NULL,"DIRECTALLOWED" NUMBER NOT NULL,"FLAGS" NUMBER NOT NULL,"PITRSCNWRP" NUMBER,"PITRSCNBAS" NUMBER,"OWNERINSTANCE" VARCHAR2(30),"BACKUPOWNER" VARCHAR2(30),"GROUPNAME" VARCHAR2(30),"SPARE1" NUMBER,"SPARE2" NUMBER,"SPARE3" VARCHAR2(1000),"SPARE4" DATE) STORAGE ( OBJNO 16 TABNO 2) CLUSTER C_TS#(TS#)
15|15|CREATE TABLE UNDO$("US#" NUMBER NOT NULL,"NAME" VARCHAR2(30) NOT NULL,"USER#" NUMBER NOT NULL,"FILE#" NUMBER NOT NULL,"BLOCK#" NUMBER NOT NULL,"SCNBAS" NUMBER,"SCNWRP" NUMBER,"XACTSQN" NUMBER,"UNDOSQN" NUMBER,"INST#" NUMBER,"STATUS$" NUMBER NOT NULL,"TS#" NUMBER,"UGRP#" NUMBER,"KEEP" NUMBER,"OPTIMAL" NUMBER,"FLAGS" NUMBER,"SPARE1" NUMBER,"SPARE2" NUMBER,"SPARE3" NUMBER,"SPARE4" VARCHAR2(1000),"SPARE5" VARCHAR2(1000),"SPARE6" DATE) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K NEXT 1024K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJNO 15 EXTENTS (FILE 1 BLOCK 224))
34|34|CREATE UNIQUE INDEX I_UNDO1 ON UNDO$(US#) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 64K NEXT 1024K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJNO 34 EXTENTS (FILE 1 BLOCK 320))
35|35|CREATE INDEX I_UNDO2 ON UNDO$(NAME) PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE ( INITIAL 64K NEXT 1024K MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 OBJNO 35 EXTENTS (FILE 1 BLOCK 328))
--//fff.sh指令碼如下,如果沒有後面的tr -d "\r",輸出的v_object_id="59\r",執行會報錯.
--//注意指令碼里面的在windows下透過ctrl+q,ctrl+g生成,linux下透過ctrl+v,ctrl+g生成.
#! /bin/bash -x
# argv1=file_number argv2=begin_block argvs3=end_block argv4=data_object_id argv5=bbed /x format
file_number=$1
begin_block=$2
end_block=$3
data_object_id=$4
ff="/r"${5}
# create sed script.
a=$5
len=$( echo ${#a})
seq $len | xargs -IQ expr substr $a Q 1 | grep -n '[nt]' | sed 's+:.$+s/ $//+' >| ff.sed
echo 's+^\*NULL\*$++g' >> ff.sed
# scan1 begin_block to end_block,define Scope.
/bin/rm scan1.txt 2>/dev/null
#declare -i v_object_id
while [ $begin_block -le $end_block ]
do
v_object_id=$(echo "p /d dba $file_number,$begin_block ktbbh.ktbbhsid.ktbbhod1" | rlbbed | grep ktbbhod1 |awk '{print $NF}'| tr -d "\r")
if [ -z "$v_object_id" ]
then
v_object_id=0
fi
#echo $v_object_id
if (( $v_object_id == $data_object_id ))
then
echo $file_number,$begin_block >> scan1.txt
fi
begin_block=$[ begin_block + 1 ]
done
# scan2 kdbr and display record.
cat scan1.txt |while read dba
do
#echo set dba $dba
kdbr_size=$(echo map dba $dba | rlbbed | tr -d "\r" | grep "sb2 kdbr" | sed -e "s/^.*\[//;s/].*$//")
#echo $kdbr_size
begin=0
end=$[ kdbr_size -1 ]
#echo $begin $end
while [ $begin -le $end ]
do
kdbr_off=$(echo p dba $dba offset 0 kdbr | rlbbed | tr -d "\r" |grep "sb2 kdbr\[$begin\]" | awk '{print $NF'})
#echo $kdbr_off
#if [ $kdbr_off -gt $kdbr_size ]
if (( $kdbr_off > $kdbr_size ))
then
#echo -n "x $ff dba $dba *kdbr[$begin]" | rlbbed | tr -d "\r" | grep "^col " | cut -c20- | sed -f ff.sed | paste -sd'|'
#echo -n "x $ff dba $dba *kdbr[$begin]" | rlbbed | tr -d "\r" | sed -n '/^col /,${s/^col .\{13\}: /^G/;p;}' | sed '/^BBED/,$d' |tr -d "\n\r" | sed "1s/^G//" |tr "^G" "\n"| sed -f ff.sed| paste -sd"|"
echo -n "x $ff dba $dba *kdbr[$begin]" | rlbbed | tr -d "\r" | sed -n '/^col /,${s/^col .\{13\}: //;p;}' | sed '/^BBED/,$d' |tr -d "\n\r" | sed "1s///" |tr "" "\n"| sed -f ff.sed| paste -sd"|"
fi
begin=$[ begin + 1 ]
done
done
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2789795/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Cygwin,在windows中使用linux命令WindowsLinux
- Cygwin配置總結
- 使用映象安裝cygwin、gcc並配置CLion IDE -2020.09.12GCIDE
- [openssh]windows 10使用cygwin安裝openssh服務端Windows服務端
- [20231029]使用cygwin調式bash shell引出的問題.txt
- [20201119]安裝cygwin.txt
- [20201120]cygwin與ssh.txt
- Mingw、Cygwin和msys2
- win10怎麼解除安裝cygwin_win10如何完全解除安裝cygwinWin10
- Cygwin 安裝最新的 man pages
- MSYS2、MinGW、Cygwin 關係梳理
- cygwin安裝配置apt-cyg工具APT
- [20210802]cygwin文字回車換行問題.txt
- Win10安裝Cygwin-含淚推薦Win10
- 【Dr.Chen的計算機作業系統】Cygwin的安裝計算機作業系統
- Windows下Github使用WindowsGithub
- Laravel 下 Elasticsearch 使用LaravelElasticsearch
- Sublime 下使用 PHPcsPHP
- Linux下Certbot使用教程Linux
- 使用treq庫下載
- Avalona下AvaloniaEdit的使用
- Audio Slicer下載使用
- 使用 Spring Data Repositories(下)Spring
- windows 下使用 phpunit 命令WindowsPHP
- windows下的gcc使用WindowsGC
- docker下的spark使用DockerSpark
- Windows下QtCreator使用QWebEngineViewWindowsQTWebView
- socket在python下的使用Python
- Linux下絲滑使用dockerLinuxDocker
- axios下載安裝/使用iOS
- ubuntu下使用spdk-rsUbuntu
- 下載工具使用總結
- Windows下更改並使用NTPWindows
- Vagrant 在 Windows 下的使用Windows
- Linux下安裝使用MySQLLinuxMySql
- Carbon中文使用手冊(下)
- zookeeper下載安裝使用
- Ubuntu下Git的使用2UbuntuGit