[20150527]bbed与数据块检查和2.txt

[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参看数据块还是很方便的.

上一篇:SQLServer 理解copyonly备份操作


下一篇:Script Lab 10:为Officejs开发配置VSCode环境(02)