oracle bbed修改資料塊的例子

eric0435發表於2012-10-31
比如我要修改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時資料庫就能正常開啟了


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26015009/viewspace-748005/,如需轉載,請註明出處,否則將追究法律責任。

相關文章