飞总block里的chkval的校验是怎么计算的, | ORACLE体系架构 | ORACLE技术论坛

Please consider registering
guest

Log In

Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS Related Topics
飞总block里的chkval的校验是怎么计算的,
2013 年 10 月 11 日
15:26
srain
Guest

块检查值。我们知道如果参数DB_BLOCK_CHECKSUM=TRUE,那么数据块在读入buffer和写回数据文件之前都要做检查计算,如果计算值和数据块中记录的计算值不匹配就会标记该块是坏块。

网上是这样解释的,但它是怎么校验的呢,

2013 年 10 月 12 日
08:56
srain
Guest

scott@OMREP> show parameter db_block_checksum

NAME TYPE VALUE
———————————— ———-- ——————————
db_block_checksum string TYPICAL
scott@OMREP> create table t1(a int);

Table created.
scott@OMREP> insert into t1 values(1);

1 row created.

scott@OMREP> commit;

Commit complete.
scott@OMREP> select dbms_rowid.rowid_relative_fno(rowid) file_no,dbms_rowid.rowid_block_number(rowid) block_no from t1;

FILE_NO BLOCK_NO
———- ———-
4 365

scott@OMREP> alter system dump datafile 4 block 365;

System altered.

buffer tsn: 4 rdba: 0x0100016d (4/365)
scn: 0x0000.001094f9 seq: 0x01 flg: 0x06 tail: 0x94f90601
frmt: 0x02 chkval: 0x4f58 type: 0x06=trans data
04表明有校验,chkval0x4f58就是校验和,这个参数和db_block_checksum有关
db_block_checksum是物理的校验块,数据块尾部ide4个字节是逻辑上校验
如果块头被标识为软坏块,那么块头的seq为0xff,flg为0x00
校验方式是对数据块进行XOR计算

———————————————————————————-
下面是db_block_checksum=off时,flg和chkval的情况
scott@OMREP> alter system set db_block_checksum=off;

System altered.
scott@OMREP> create table t2 as select * from t1;

scott@OMREP> select dbms_rowid.rowid_relative_fno(rowid) file_no,dbms_rowid.rowid_block_number(rowid) block_no from t2;

FILE_NO BLOCK_NO
———- ———-
4 371

scott@OMREP> alter system dump datafile 4 block 371;

System altered.
buffer tsn: 4 rdba: 0x01000173 (4/371)
scn: 0x0000.0010e540 seq: 0x02 flg: 0x00 tail: 0xe5400602
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
flg为0x00
chlval为0x0000
————————————————————————————————————————-
下面反应数据块变化时校验位的变化,
sys@OMREP> select dbms_rowid.rowid_relative_fno(rowid) file_no,dbms_rowid.rowid_block_number(rowid) block_no from t1;

FILE_NO BLOCK_NO
———- ———-
1 33137

sys@OMREP> alter system dump datafile 1 block 33137;

System altered.
frmt: 0x02 chkval: 0xce0c type: 0x06=trans data

sys@OMREP> insert into t1 values(2);

1 row created.

sys@OMREP> commit;

Commit complete.

sys@OMREP> alter system checkpoint;

System altered.
sys@OMREP> alter system dump datafile 1 block 33137;

System altered.
frmt: 0x02 chkval: 0xb6f9 type: 0x06=trans data
—--最后还是不清楚是怎么XOR计算的

2013 年 10 月 20 日
18:04
惜分飞
Admin
Forum Posts: 349
Member Since:
2010 年 07 月 31 日
Offline

db_block_checksum实质是通过flg_kcbh来控制block checksum

http://www.xifenfei.com/4828.html

Q Q:107644445  

Tel:13429648788

个人Blog(惜分飞)

提供专业ORACLE技术支持(数据恢复,安装实施,升级迁移,备份容灾,故障诊断,系统优化等)

    

       
   

评论功能已关闭。