Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to calculate the correct checksum value?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1) create a test table

SQL > create table test (id int, name varchar2 (10))

Table created.

SQL > insert into test values (1 recording AAAAAAA')

1 row created.

SQL > commit

Commit complete.

SQL > select dbms_rowid.ROWID_RELATIVE_FNO (rowid) file#,dbms_rowid.ROWID_BLOCK_NUMBER (rowid) blk# from test

FILE# BLK#

--

4 284

View the current checksum value through BBED

[oracle@Mysql ~] $bbed

BBED: Release 2.0.0.0.0-Limited Production on Fri May 25 00:54:11 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

*! For Oracle Internal Use only!! *

BBED > set file 4 block 284

FILE# 4

BLOCK# 284

BBED > sum

Check value for File 4, Block 284:

Current = 0xf9ff, required = 0xf9ff

Dump the data block 284.

[oracle@Mysql ~] $dd if=/u01/app/oracle/oradata/dsidb/users01.dbf of=/tmp/test.dd count=1 skip=284 bs=8192

1: 0 records in

1: 0 records out

8192 bytes (8.2 kB) copied, 0.000435816 s, 18.8 MB/s

We use the UE editor to open the test.dd block

And then change from C02 to C03.

Then copy the test.dd data block back

[oracle@Mysql tmp] $dd if=/tmp/test.dd of=/u01/app/oracle/oradata/dsidb/users01.dbf count=1 seek=284 bs=8192 conv=notrunc

1: 0 records in

1: 0 records out

8192 bytes (8.2 kB) copied, 0.000339993 s, 24.1 MB/s

Then restart the database.

SQL > startup force

ORACLE instance started.

Total System Global Area 588746752 bytes

Fixed Size 2230592 bytes

Variable Size 201328320 bytes

Database Buffers 377487360 bytes

Redo Buffers 7700480 bytes

Database mounted.

Database opened.

SQL > conn scott/oracle

Connected.

SQL > select * from test

Select * from test

*

ERROR at line 1:

ORA-01578: ORACLE data block corrupted (file # 4, block # 284)

ORA-01110: data file 4:'/ u01 *

You can see that the database query table test reported an error. Let's take a look at the database log again.

2018-05-25 01 purl 16 purl 29.248000 + 08:00

Errors in file / u01/app/oracle/diag/rdbms/dsidb/dsidb/trace/dsidb_ora_10666.trc (incident=102183):

ORA-01578: ORACLE data block corrupted (file # 4, block # 284)

ORA-01110: data file 4:'/ u01 *

Incident details in: / u01/app/oracle/diag/rdbms/dsidb/dsidb/incident/incdir_102183/dsidb_ora_10666_i102183.trc

Sweep [inc] [102182]: completed

Hex dump of (file 4, block 284) in trace file / u01/app/oracle/diag/rdbms/dsidb/dsidb/incident/incdir_102182/dsidb_m000_10668_i102182_a.trc

Corrupt block relative dba: 0x0100011c (file 4, block 284)

Bad check value found during validation

Data in bad block:

Type: 6 format: 2 rdba: 0x0100011c

Last change scn: 0x0000.003ffe2d seq: 0x1 flg: 0x06

Spare1: 0x0 spare2: 0x0 spare3: 0x0

Consistency value in tail: 0xfe2d0601

Check value in block header: 0xf9ff

Computed block checksum: 0x100

You can see that the check value value on the file header is 0xf9ff, and the calculated check sum value is 0x100

Then we use BBED to sum this data block, and we can see that the current value of check value is f9ff, while the required value is f8ff

[oracle@Mysql ~] $bbed

BBED: Release 2.0.0.0.0-Limited Production on Fri May 25 01:18:44 2018

Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.

*! For Oracle Internal Use only!! *

BBED > set file 4 block 284

FILE# 4

BLOCK# 284

BBED > sum

Check value for File 4, Block 284:

Current = 0xf9ff, required = 0xf8ff

Let's calculate what the normal checksum value of the current block should be based on 0xf9ff and 0x100.

F9FF = 1111 1001 1111 1111

100 = 0000 0001 0000 0000

According to the principle of the XOR algorithm, it is easy to see that the correct checksum value calculated by oracle should be: 1111 1000 1111 1111, that is, f8ff

All right, let's do the same here and change the checksum value of the above block again, that is, the checksum value of the above block will be changed to f8 ff.

Let's verify first.

BBED > verify

DBVERIFY-Verification starting

FILE = / u01/app/oracle/oradata/dsidb/users01.dbf

BLOCK = 284

Block 284 is corrupt

Corrupt block relative dba: 0x0100011c (file 0, block 284)

Bad check value found during verification

Data in bad block:

Type: 6 format: 2 rdba: 0x0100011c

Last change scn: 0x0000.003ffe2d seq: 0x1 flg: 0x06

Spare1: 0x0 spare2: 0x0 spare3: 0x0

Consistency value in tail: 0xfe2d0601

Check value in block header: 0xf9ff

Computed block checksum: 0x100

DBVERIFY-Verification complete

Total Blocks Examined: 1

Total Blocks Processed (Data): 0

Total Blocks Failing (Data): 0

Total Blocks Processed (Index): 0

Total Blocks Failing (Index): 0

Total Blocks Empty: 0

Total Blocks Marked Corrupt: 1

Total Blocks Influx: 0

BBED > sum

Check value for File 4, Block 284:

Current = 0xf9ff, required = 0xf8ff

BBED > sum

Check value for File 4, Block 284:

Current = 0xf9ff, required = 0xf8ff

BBED > modify / x 0xf8ff offset 16

Warning: contents of previous BIFILE will be lost. Proceed? (Ybig N) y

File: / u01/app/oracle/oradata/dsidb/users01.dbf (4)

Block: 284 Offsets: 16 to 527 Dba:0x0100011c

F8ff0000 01000000 fa2a0100 2cfe3f00 00000000 02003200 18010001 1d000900

A0000000 ba040002 4d001100 01200000 2dfe3f00 00000000 00000000 00000000

00000000 00000000 00000000 00010100 ffff1400 8c1f781f

781f0000 01008c1f ffff3200 a0046e04 6e040000 1000c01d 961c7b1b b9190418

50167a14 9812f110 4b0f830d ba0bde09 29087606 a0040000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

00000000 00000000 00000000

BBED > sum apply

Check value for File 4, Block 284:

Current = 0xf8ff, required = 0xf8ff

Then verify again, and you can see that the bad blocks are no longer reported.

BBED > verify

DBVERIFY-Verification starting

FILE = / u01/app/oracle/oradata/dsidb/users01.dbf

BLOCK = 284

DBVERIFY-Verification complete

Total Blocks Examined: 1

Total Blocks Processed (Data): 1

Total Blocks Failing (Data): 0

Total Blocks Processed (Index): 0

Total Blocks Failing (Index): 0

Total Blocks Empty: 0

Total Blocks Marked Corrupt: 0

Total Blocks Influx: 0

BBED > sum

Check value for File 4, Block 284:

Current = 0xf8ff, required = 0xf8ff

The data can also be returned normally.

SQL > select * from test

ID NAME

--

2 AAAAA

two。 Reproduce the calculation error of the space in the data block? (for the detailed operation steps of the experiment, the BBED tool verify follows the command prompt)

BBED > verify

Kdbchk:the amount of space used is not equal to block size

Total Blocks Failing (Data)

SQL > create table T2 (id int,name varchar2 (10))

Table created.

SQL > insert into T2 values (1mai AAAAAAA')

1 row created.

SQL > commit

Commit complete.

SQL > alter system flush buffer_cache

System altered.

SQL > select dbms_rowid.rowid_relative_fno (rowid) file#,dbms_rowid.rowid_block_number (rowid) blk# from T2

FILE# BLK#

--

4 220

SQL > delete from T2

1 row deleted.

SQL > alter system flush buffer_cache

System altered.

BBED > set file 4 block 220

FILE# 4

BLOCK# 220

BBED > map

File: / u01/app/oracle/oradata/dsidb/users01.dbf (4)

Block: 220 Dba:0x010000dc

KTB Data Block (Table/Cluster)

Struct kcbh, 20 bytes @ 0

Struct ktbbh, 72 bytes @ 20

Struct kdbh, 14 bytes @ 100

Struct kdbt [1], 4 bytes @ 114

Sb2 kdbr [1] @ 118

Ub1 freespace [8055] @ 120

Ub1 rowdata [13] @ 8175

Ub4 tailchk @ 8188

BBED > p rowdata

Ub1 rowdata [0] @ 8175 0x3c

Ub1 rowdata [1] @ 8176 0x02

Ub1 rowdata [2] @ 8177 0x02

Ub1 rowdata [3] @ 8178 0x02

Ub1 rowdata [4] @ 8179 0xc1

Ub1 rowdata [5] @ 8180 0x02

Ub1 rowdata [6] @ 8181 0x06

Ub1 rowdata [7] @ 8182 0x41

Ub1 rowdata [8] @ 8183 0x41

Ub1 rowdata [9] @ 8184 0x41

Ub1 rowdata [10] @ 8185 0x41

Ub1 rowdata [11] @ 8186 0x41

Ub1 rowdata [12] @ 8187 0x0a

BBED > modify / x 2c offset 8175

File: / u01/app/oracle/oradata/dsidb/users01.dbf (4)

Block: 220 Offsets: 8175 to 8191 Dba:0x010000dc

2c020202 c1020641 41414141 0a010621 59

BBED > sum apply

Check value for File 4, Block 220:

Current = 0x1f3f, required = 0x1f3f

BBED > verify

DBVERIFY-Verification starting

FILE = / u01/app/oracle/oradata/dsidb/users01.dbf

BLOCK = 220

Block Checking: DBA = 16777436, Block Type = KTB-managed data block

Data header at 0x24d9064

Kdbchk: the amount of space used is not equal to block size

Used=33 fsc=11 avsp=8055 dtl=8088

Block 220 failed with check code 6110

DBVERIFY-Verification complete

Total Blocks Examined: 1

Total Blocks Processed (Data): 1

Total Blocks Failing (Data): 1

Total Blocks Processed (Index): 0

Total Blocks Failing (Index): 0

Total Blocks Empty: 0

Total Blocks Marked Corrupt: 0

Total Blocks Influx: 0

Message 531 not found; product=RDBMS; facility=BBED

BBED > p kdbh

Struct kdbh, 14 bytes @ 100

Ub1 kdbhflag @ 100 0x00 (NONE)

Sb1 kdbhntab @ 101 1

Sb2 kdbhnrow @ 102 1

Sb2 kdbhfrre @ 104-1

Sb2 kdbhfsbo @ 106 20

Sb2 kdbhfseo @ 108 8075

Sb2 kdbhavsp @ 110 8055

Sb2 kdbhtosp @ 112 8068

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report