[20150527]bbed與資料塊檢查和2.txt

lfree發表於2015-05-27

[20150527]bbed與資料塊檢查和2.txt

http://blog.itpub.net/267265/viewspace-1666781/

--我現在基本拿bbed學習,基本是拿bbed檢視,而使用bvi修改資料.我感覺這種方便1寫.
--實際上使用bbed的好處就是修改資料塊檢查和不一致,而使用bbed修改很簡單僅僅需要執行sum apply就ok了.

--對比dbv與bbed確定檢查和位置.

--實際上既然檢查和在16,17位元組,只要清零,加上dbv就很容易確定要修改的內容.

1.建立測試環境:

SCOTT@test> @ &r/ver1

PORT_STRING                    VERSION        BANNER
------------------------------ -------------- ----------------------------------------------------------------
x86_64/Linux 2.4.xx            10.2.0.4.0     Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

SCOTT@test> select rowid,deptx.* from deptx;
ROWID                    DEPTNO DNAME          LOC
------------------ ------------ -------------- -------------
AAAO1FAAGAAAAAKAAA           10 ACCOUNTING     NEW aaaa
AAAO1FAAGAAAAAKAAB           20 RESEARCH       DALLAS
AAAO1FAAGAAAAAKAAC           30 SALES          CHICAGO
AAAO1FAAGAAAAAKAAD           40 OPERATIONS     BOSTON

SCOTT@test> @ &r/lookup_rowid AAAO1FAAGAAAAAKAAA
      OBJECT         FILE        BLOCK          ROW DBA                  TEXT
------------ ------------ ------------ ------------ -------------------- ----------------------------------------
       60741            6           10            0 6,10                 alter system dump datafile 6 block 10 ;


SCOTT@test> alter system checkpoint;
System altered.

SCOTT@test> alter system flush buffer_cache;
System altered.

2.修改塊:

$  bvi -b 81920 -s 8192 /mnt/ramdisk/test/mssm01.dbf
--修改.
aaaa=>YORK
--說明:bvi修改很簡單選擇R,替換裡面的K->k. 前面的引數-b 表示開始偏移量,10*8192=81920. -s表示顯示大小.
--這樣就人為的破壞了檢查和.

--同時修改16,17位元組為00.
SCOTT@test>  select rowid,deptx.* from deptx;
select rowid,deptx.* from deptx
                           *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 6, block # 10)
ORA-01110: data file 6: '/mnt/ramdisk/test/mssm01.dbf

$  dbv file=/mnt/ramdisk/test/mssm01.dbf

DBVERIFY: Release 10.2.0.4.0 - Production on Wed May 27 10:22:30 2015

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

DBVERIFY - Verification starting : FILE = /mnt/ramdisk/test/mssm01.dbf
Page 10 is marked corrupt
Corrupt block relative dba: 0x0180000a (file 6, block 10)
Bad check value found during dbv:
Data in bad block:
type: 6 format: 2 rdba: 0x0180000a
last change scn: 0x0002.f445ace5 seq: 0x2 flg: 0x06
spare1: 0x0 spare2: 0x0 spare3: 0x0
consistency value in tail: 0xace50602
check value in block header: 0x0
computed block checksum: 0x893e

DBVERIFY - Verification complete

Total Pages Examined         : 2048
Total Pages Processed (Data) : 1
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 10
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2036
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 0
Highest block SCN            : 4098132609 (2.4098132609)

--可以看到應該是 computed block checksum: 0x893e.

$  bvi -b 81920 -s 8192 /mnt/ramdisk/test/mssm01.dbf
--修改16,17位元組為3e 89 (我的cpu是intel的,要反過來輸入).

SCOTT@test> alter system flush buffer_cache;
System altered.

SCOTT@test> select rowid,deptx.* from deptx;
ROWID                    DEPTNO DNAME          LOC
------------------ ------------ -------------- -------------
AAAO1FAAGAAAAAKAAA           10 ACCOUNTING     NEW YORK
AAAO1FAAGAAAAAKAAB           20 RESEARCH       DALLAS
AAAO1FAAGAAAAAKAAC           30 SALES          CHICAGO
AAAO1FAAGAAAAAKAAD           40 OPERATIONS     BOSTON

--OK現在正常顯示了,透過這個方法可以不使用bbed做sum apply操作.不過我覺得使用bbed參看資料塊還是很方便的.

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

相關文章