熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

Oracle的一個內部工具blockcorruption

2022-06-13   來源: Oracle 

  有人在Google新聞組上提出了一個問題:How can I get the BBED password?繼而引發了一場很有意思的討論

   

  後來Pete Finnigan也在他的Blog寫了一篇文章An interesting thread on Oraclel about BBED描述這次有意思的探討

   

  在討論中有一個有趣的觀點提到如果這個工具被廣泛傳播那麼可能有些人不是用BBED來修復數據意外的破壞可能更為多見最終的後果可能是Oracle徹底把這個工具移除

   

  BBED是Block Browser/Editor的縮寫是Oracle的一個內部工具不對外發布文檔及支持

   

  BBED隨軟件發布但是我們需要進行簡單的relink才能使用relink請參考:How to compile Oracleg BBED tools

   

  雖然BBED工具的使用存在很多風險但是如果利用得當可以以之解決很多棘手的問題

   

  本文簡單介紹一下如何用BBED模擬壞塊以練習壞塊修復等技術此前我曾經介紹過另外一種方法請參考:Oracle中模擬及修復數據塊損壞

   

  創建測試表

   

  [oracle@jumper conner]$ sqlplus / as sysdba

   

  SQL*Plus: Release Production on Sun Sep ::

   

  Copyright (c) Oracle Corporation  All rights reserved

   

  Connected to:

  Oraclei Enterprise Edition Release Production

  With the Partitioning option

  JServer Release Production

   

  SQL> create table bbed tablespace users as select * from dba_tables;

   

  Table created

   

  SQL> select count(*) from bbed;

   

  COUNT(*)

  

  

   

  SQL> col segment_name for a

  SQL> select segment_namefile_idblock_id from dba_extents where segment_name=BBED;

   

  SEGMENT_NA    FILE_ID   BLOCK_ID

  

  BBED                         

  BBED                        

  BBED                        

   

  SQL> select count(*) from bbed;

   

  COUNT(*)

  

  

   

  創建BBED參數文件等

   

  [oracle@jumper conner]$ more filelisttxt

   /opt/oracle/oradata/conner/systemdbf  

   /opt/oracle/oradata/conner/undotbsdbf 

   /opt/oracle/oradata/conner/usersdbf    

  [oracle@jumper conner]$ more parbbd

  blocksize=

  listfile=filelisttxt

  mode=edit

   

  使用BBED

   

  [oracle@jumper conner]$ bbed parfile=parbbd

  Password:

   

  BBED: Release Limited Production on Sun Sep ::

   

  Copyright (c) Oracle Corporation  All rights reserved

   

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

   

  BBED> set file

  FILE#          

   

  BBED> show

  FILE#          

  BLOCK#         

  OFFSET         

  DBA             xc ( )

  FILENAME        /opt/oracle/oradata/conner/usersdbf

  BIFILE          bifilebbd

  LISTFILE        filelisttxt

  BLOCKSIZE      

  MODE            Edit

  EDIT            Unrecoverable

  IBASE           Dec

  OBASE           Dec

  WIDTH          

  COUNT          

  LOGFILE         logbbd

  SPOOL           No

   

  回滾誤操作

   

  如果操作中發生誤操作可以使用revert命令回滾

   

  BBED> modify /x xc

  File: /opt/oracle/oradata/conner/usersdbf ()

  Block:                 Offsets: to            Dba:xc

  

  c

  

  

  

  

  

  

  

  

  

  

  

  

  

  

  

   

  < bytes per line>

   

  BBED> revert

  All changes made in this session will be rolled back Proceed? (Y/N) Y

  Reverted file /opt/oracle/oradata/conner/usersdbf block

  Warning: contents of previous BIFILE will be lost Proceed? (Y/N) Y

   

  改寫數據塊

   

  模擬壞塊

   

  BBED> modify file block

  File: /opt/oracle/oradata/conner/usersdbf ()

  Block:                Offsets: to            Dba:xc

  

  e

  

  

   cf cf fe fc

  ff cde d ffffc bc c c

  c ffc c eff c c e ffffffff

  ffffffff a a e

  e c ffffe fffe ee f c

  c e fef ff c e fff

  c c cf c f f

  fe c dff ffcb c cc c

  ff c c eff cc eff ffffffff

  ffffffa a e

  e cff ffef ffe eef c

  c ef efff c ef ff c

   cc f c c f f

   

  < bytes per line>

   

  檢查數據塊損壞

   

  使用verify命令可以發現剛才修改的file block 已經被標記為損壞

   

  BBED> verify

  DBVERIFY Verification starting

  FILE = /opt/oracle/oradata/conner/usersdbf

  BLOCK =

   

  Block is corrupt

  ***

  Corrupt block relative dba: xc (file block )

  Bad check value found during verification

  Data in bad block

  type: format: rdba: xc

  last change scn: xab seq: x flg: x

  consistency value in tail: xb

  check value in block header: x computed block checksum: xe

  spare: x spare: x spare: x

  ***

   

  DBVERIFY Verification complete

   

  Total Blocks Examined         :

  Total Blocks Processed (Data) :

  Total Blocks Failing   (Data) :

  Total Blocks Processed (Index):

  Total Blocks Failing   (Index):

  Total Blocks Empty            :

  Total Blocks Marked Corrupt   :

  Total Blocks Influx           :

   

  BBED> quit

   

  使用DBV檢查

   

  [oracle@jumper conner]$ dbv file=usersdbf blocksize=

   

  DBVERIFY: Release Production on Sun Sep ::

   

  Copyright (c) Oracle Corporation  All rights reserved

   

  DBVERIFY Verification starting : FILE = usersdbf

  Page is marked corrupt

  ***

  Corrupt block relative dba: xc (file block )

  Bad check value found during dbv:

  Data in bad block

  type: format: rdba: xc

  last change scn: xab seq: x flg: x

  consistency value in tail: xb

  check value in block header: x computed block checksum: xe

  spare: x spare: x spare: x

  ***

   

  DBVERIFY Verification complete

   

  Total Pages Examined         :

  Total Pages Processed (Data) :

  Total Pages Failing   (Data) :

  Total Pages Processed (Index):

  Total Pages Failing   (Index):

  Total Pages Processed (Other):

  Total Pages Processed (Seg)  :

  Total Pages Failing   (Seg)  :

  Total Pages Empty            :

  Total Pages Marked Corrupt   :

  Total Pages Influx           :

   

  全表掃描此時出現ORA錯誤

   

  重新啟動數據庫以後執行全表掃描此時錯誤出現:

   

  SQL> startup force;

  ORACLE instance started

   

  Total System Global Area  bytes

  Fixed Size                   bytes

  Variable Size              bytes

  Database Buffers           bytes

  Redo Buffers                 bytes

  Database mounted

  Database opened

  SQL> select count(*) from bbed;

  select count(*) from bbed

  *

  ERROR at line :

  ORA: ORACLE data block corrupted (file # block # )

  ORA: data file : /opt/oracle/oradata/conner/usersdbf

   

  SQL>

   

  以上方法僅供測試使用


From:http://tw.wingwit.com/Article/program/Oracle/201311/18727.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.