oracle bbed修改数据块的例子

比如我要修改SQL_TEXT=’8.0.0.0.0’为’9.0.0.0.0′

SQL> select     rowid,
  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  a.*
  6  from bootstrap$ a where rownum<2;

ROWID              REL_FNO  BLOCKNO    ROWNO  LINE#     OBJ#  SQL_TEXT
------------------ -------  ---------- ------ --------- ----- -----------
AAAAA4AABAAAAF6AAA   1        378       0       -1       -1    8.0.0.0.0

一般使用bbed,都是将一些配置信息写入到一个参数文本里,在调用bbed时,指定该参数文件。如:
$bbed parfile=bbed.par
先获取datafile 的信息
将datafile 的信息写入一个文件,格式为:文件编号 文件名字 文件大小。可以通过如下SQL 获取:

SQL>select file#||' '||name||' '||bytes from v$datafile ;

FILE#||''||NAME||''||BYTES
------------------------------------------------------------------------------
1 /u01/app/oracle/oradata/jytest/system01.dbf 524288000
2 /u01/app/oracle/oradata/jytest/undotbs01.dbf 193986560
3 /u01/app/oracle/oradata/jytest/sysaux01.dbf 2149580800
4 /u01/app/oracle/oradata/jytest/users01.dbf 5242880
5 /u01/app/oracle/oradata/jytest/hygeia.dbf 21474836480

注意这里的file id。 我们这里的file id 和 oracle 系统内部的file id 相同。 当然这个id 我们也可以自己指定。 当我们在bbed 里设置file id 时,就是根据这个参数文件中的的设置来的。 最好设置为相同,不然以后可能会混淆。

将上面查询出来的datafile信息保存到文本里。

[oracle@weblogic28 lib]$ cat /u01/filelist.txt
1 /u01/app/oracle/oradata/jytest/system01.dbf 524288000
2 /u01/app/oracle/oradata/jytest/undotbs01.dbf 193986560
3 /u01/app/oracle/oradata/jytest/sysaux01.dbf 2149580800
4 /u01/app/oracle/oradata/jytest/users01.dbf 5242880
5 /u01/app/oracle/oradata/jytest/hygeia.dbf 21474836480

创建parameter file:

[oracle@weblogic28 lib]$ cat /u01/bbed.par
blocksize=8192
listfile=/u01/filelist.txt
mode=edit

使用parameter file 连接bbed:

[oracle@weblogic28 lib]$ ./bbed parfile=/u01/bbed.par
Password:

BBED: Release 2.0.0.0.0 - Limited Production on Wed Oct 31 14:39:28 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> set dba 1,378 offset 0
        DBA             0x0040017a (4194682 1,378)
        OFFSET          0

find 在指定的block中查找指定的字符串,结果是显示出字符串,及其偏移量–offset,偏移量就是在block中的字节数
查找关键字8.0.0.0.0,确定其在block中的偏移量offset。

BBED> find /c 8.0.0.0.0
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378              Offsets: 8181 to 8191           Dba:0x0040017a
------------------------------------------------------------------------
 302e302e 302e3001 065d01

 <32 bytes per line>

dump 查看具体内容:

BBED> dump /v dba 1,378 offset 8181 count 11
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378     Offsets: 8181 to 8191  Dba:0x0040017a
-------------------------------------------------------
 302e302e 302e3001 065d01            l 0.0.0.0..].

 <16 bytes per line>

从上面看到’8.’这两个字节没显示出来所示8.0.0.0.0的偏移量是从8179开始
count是指查看多少个字节的内容

BBED> dump /v dba 1,378 offset 8179 count 11
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378     Offsets: 8179 to 8189  Dba:0x0040017a
-------------------------------------------------------
 382e302e 302e302e 300106            l 8.0.0.0.0..

 <16 bytes per line>

modify 修改指定block的指定偏移量的值,可以在线修改。
由上可知偏移量8179就是’8’现将8修改成9

BBED> modify /c '9' dba 1,378 offset 8179
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378              Offsets: 8179 to 8189           Dba:0x0040017a
------------------------------------------------------------------------
 392e302e 302e302e 300106

 <32 bytes per line>

BBED> dump /v dba 1,378 offset 8179 count 11
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378     Offsets: 8179 to 8189  Dba:0x0040017a
-------------------------------------------------------
 392e302e 302e302e 300106            l 9.0.0.0.0..

 <16 bytes per line>

应用变更

BBED> sum dba 1,378
Check value for File 1, Block 378:
current = 0x13d5, required = 0x12d5
此时 current checksum 是0x13d5,requiredchecksum 是0x12d5
BBED> sum dba 1,378 apply
Check value for File 1, Block 378:
current = 0x12d5, required = 0x12d5

加上apply参数,使checksum一致。即之前的修改生效。

这时关闭数据库后打开数据库报错

SQL> startup
ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  2030368 bytes
Variable Size            1090520288 bytes
Database Buffers         5335154688 bytes
Redo Buffers               14745600 bytes
Database mounted.
ORA-01092: ORACLE instance terminated. Disconnection forced

错误信息如下(alertsid.log)

Errors in file /u01/app/oracle/admin/jytest/udump/jytest_ora_6148.trc:
ORA-00704: bootstrap process failure
ORA-00702: bootstrap verison '9.0.0.0.0' inconsistent with version '8.0.0.0.0'
Wed Oct 31 14:46:52 2012
Error 704 happened during db open, shutting down database
USER: terminating instance due to error 704
Instance terminated by USER, pid = 6148
ORA-1092 signalled during: ALTER DATABASE OPEN...
 bootstrap verison '9.0.0.0.0' inconsistent with version '8.0.0.0.0'
 

说明原来的值是’8.0.0.0.0’现在却是’9.0.0.0.0’所以数据库打不开

现在又将8.0.0.0.0修改成9.0.0.0.0

BBED> modify /c '8' dba 1,378 offset 8179
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378              Offsets: 8179 to 8189           Dba:0x0040017a
------------------------------------------------------------------------
 382e302e 302e302e 300106

 <32 bytes per line>

BBED> dump /v dba 1,378 offset 8179 count 11
 File: /u01/app/oracle/oradata/jytest/system01.dbf (1)
 Block: 378     Offsets: 8179 to 8189  Dba:0x0040017a
-------------------------------------------------------
 382e302e 302e302e 300106            l 8.0.0.0.0..

 <16 bytes per line>

BBED> sum dba 1,378
Check value for File 1, Block 378:
current = 0x12d5, required = 0x13d5

BBED> sum dba 1,378 apply
Check value for File 1, Block 378:
current = 0x13d5, required = 0x13d5
SQL> startup
ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  2030368 bytes
Variable Size            1090520288 bytes
Database Buffers         5335154688 bytes
Redo Buffers               14745600 bytes
Database mounted.
Database opened.

当把9.0.0.0.0修改成8.0.0.0.0时数据库就能正常打开了

One thought on “oracle bbed修改数据块的例子

发表评论

电子邮件地址不会被公开。