小说明
bbed可以直接修改Oracle数据文件块
安装思路:
9i/10g中可以连接生成bbed,
11g/12c将所需文件从10g cp 到12c 环境,然后编译安装
10g 具体操作
oracle用户
cd $ORACLE_HOME/rdbms/lib
[oracle@ngkf1 lib]$ make -f ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbed
Linking BBED utility (bbed)
rm -f /oracle/product/10.2.0/db/bin/bbed
gcc -o /oracle/product/10.2.0/db/bin/bbed -L/oracle/product/10.2.0/db/rdbms/lib/ -L/oracle/product/10.2.0/db/lib/ -L/oracle/product/10.2.0/db/lib/stubs/ /oracle/product/10.2.0/db/lib/s0main.o /oracle/product/10.2.0/db/rdbms/lib/ssbbded.o /oracle/product/10.2.0/db/rdbms/lib/sbbdpt.o `cat /oracle/product/10.2.0/db/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 /oracle/product/10.2.0/db/rdbms/lib/defopt.o -ldbtools10 -lclntsh `cat /oracle/product/10.2.0/db/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /oracle/product/10.2.0/db/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lmm -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /oracle/product/10.2.0/db/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lnro10 `cat /oracle/product/10.2.0/db/lib/ldflags` -lnsslb10 -lncrypt10 -lnsgr10 -lnzjs10 -ln10 -lnnz10 -lnl10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 -lclient10 -lnnetd10 -lvsn10 -lcommon10 -lgeneric10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lcore10 -lsnls10 -lnls10 -lxml10 -lcore10 -lunls10 -lsnls10 -lnls10 -lcore10 -lnls10 `cat /oracle/product/10.2.0/db/lib/sysliblist` -Wl,-rpath,/oracle/product/10.2.0/db/lib -lm `cat /oracle/product/10.2.0/db/lib/sysliblist` -ldl -lm -L/oracle/product/10.2.0/db/lib
[oracle@ngkf1 bin]$ ls -al |grep bbed
-rwxr-xr-x 1 oracle oinstall 706999 Sep 5 06:29 bbed
12c
OracleDatabase 11g和12c 中缺省的未提供BBED库文件,但可以用10g的文件编译出来,需要先从10g中复制如下文件到相应目录,然后再执行上述连接命令,参考如下步骤:
(1)复制Oracle 10g文件
ORA10gHOME/rdbms/lib/ssbbded.oto O R A 10 g H O M E / r d b m s / l i b / s s b b d e d . o t o ORA11g_HOME/rdbms/lib
ORA10gHOME/rdbms/lib/sbbdpt.oto O R A 10 g H O M E / r d b m s / l i b / s b b d p t . o t o ORA11g_HOME/rdbms/lib
ORA10gHOME/rdbms/mesg/bbedus.msbto O R A 10 g H O M E / r d b m s / m e s g / b b e d u s . m s b t o ORA11g_HOME/rdbms/mesg
ORA10gHOME/rdbms/mesg/bbedus.msgto O R A 10 g H O M E / r d b m s / m e s g / b b e d u s . m s g t o ORA11g_HOME/rdbms/mesg
复制后 复查权限
-rw-r–r– 1 oracle oinstall 3976 Sep 5 06:53 sbbdpt.o
-rw-r–r– 1 oracle oinstall 3306 Sep 5 06:55 ssbbded.o
-rw-r–r– 1 oracle oinstall 8704 Sep 5 06:58 bbedus.msb
-rw-r–r– 1 oracle oinstall 10270 Sep 5 06:58 bbedus.msg
(2)编译
make -f ins_rdbms.mk BBED= ORACLEHOME/bin/bbed O R A C L E H O M E / b i n / b b e d ORACLE_HOME/bin/bbed
-bash-3.2$ make -f ins_rdbms.mk BBED=$ORACLE_HOME/bin/bbed $ORACLE_HOME/bin/bbed
Linking BBED utility (bbed)
rm -f /u01/app/oracle/product/12.1.0/dbhome_1/bin/bbed
/u01/app/oracle/product/12.1.0/dbhome_1/bin/orald -o /u01/app/oracle/product/12.1.0/dbhome_1/bin/bbed -m64 -z noexecstack -Wl,--disable-new-dtags -L/u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ -L/u01/app/oracle/product/12.1.0/dbhome_1/lib/ -L/u01/app/oracle/product/12.1.0/dbhome_1/lib/stubs/ /u01/app/oracle/product/12.1.0/dbhome_1/lib/s0main.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/ssbbded.o /u01/app/oracle/product/12.1.0/dbhome_1/rdbms/lib/sbbdpt.o `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags` -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -ldbtools12 -lclntsh -lclntshcore `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags` -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags` -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnnz12 -lzt12 -lztkg12 -lztkg12 -lclient12 -lnnetd12 -lvsn12 -lcommon12 -lgeneric12 -lmm -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags` -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lnro12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/ldflags` -lncrypt12 -lnsgr12 -lnzjs12 -ln12 -lnl12 -lclient12 -lnnetd12 -lvsn12 -lcommon12 -lgeneric12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 -lclient12 -lnnetd12 -lvsn12 -lcommon12 -lgeneric12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lcore12 -lsnls12 -lnls12 -lxml12 -lcore12 -lunls12 -lsnls12 -lnls12 -lcore12 -lnls12 `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/12.1.0/dbhome_1/lib -lm `cat /u01/app/oracle/product/12.1.0/dbhome_1/lib/sysliblist` -ldl -lm -L/u01/app/oracle/product/12.1.0/dbhome_1/lib
登陆
oracle用户 bbed BBED设置了口令保护,默认密码为blockedit。
-bash-3.2$ bbed
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Wed Sep 5 07:08:58 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
*** !!! For Oracle Internal Use only !!! *****
BBED>
另外,一般使用bbed都是在参数配置文件中写好配置参数,然后直接调用配置文件,比如:
–获取数据文件
select file#||’ ‘||name||’ ‘||bytes from v$datafile;
4 /u01/app/oracle/oradata/orcl/undotbs01.dbf 230686720
8 /u01/app/oracle/oradata/orcl/pdborcl/system01.dbf 262144000
9 /u01/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf 608174080
10 /u01/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf 5242880
–编辑/tmp/bbed.par参数配置文件
vi /tmp/bbed.par
blocksize=8192
listfile=/tmp/listfile.txt
mode=edit
password=blockedit
silent=y
spool=y
logfile=’/home/oracle/bbed.log’
–编辑/tmp/listfile.txt文件
vi /tmp/listfile.txt
4 /u01/app/oracle/oradata/orcl/undotbs01.dbf 230686720
8 /u01/app/oracle/oradata/orcl/pdborcl/system01.dbf 262144000
9 /u01/app/oracle/oradata/orcl/pdborcl/sysaux01.dbf 608174080
10 /u01/app/oracle/oradata/orcl/pdborcl/pdborcl_users01.dbf 5242880
–调用bbed
cd /tmp
bbed parfile=bbed.par
-bash-3.2$ bbed parfile=bbed.par
Password:
BBED: Release 2.0.0.0.0 - Limited Production on Wed Sep 5 07:25:13 2018
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
************* !!! For Oracle Internal Use only !!! ***************
BBED> show all
FILE# 4
BLOCK# 1
OFFSET 0
DBA 0x01000001 (16777217 4,1)
FILENAME /u01/app/oracle/oradata/orcl/undotbs01.dbf
BIFILE bifile.bbd
LISTFILE /tmp/listfile.txt
BLOCKSIZE 8192
MODE Edit
EDIT Unrecoverable
IBASE Dec
OBASE Dec
WIDTH 80
COUNT 512
LOGFILE log.bbd
SPOOL No
BBED>