iis服务器助手广告广告
返回顶部
首页 > 资讯 > 数据库 >怎么计算出正确的checksum值?
  • 513
分享到

怎么计算出正确的checksum值?

2024-04-02 19:04:59 513人浏览 安东尼
摘要

1)创建一个测试表 sql> create table test (id int, name varchar2(10));   Table created.

1)创建一个测试

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

 

Table created.

 

SQL> insert into test values(1,'AAAAA');

 

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

 

通过BBED查看当前的CHECKSUM值

[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

 

把284号数据块dump出来。

[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

 

我们使用UE编辑器打开test.dd数据块

然后把C1 02改成C1 03

 

然后把test.dd数据块copy回去

[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

 

 

然后重启一下数据库

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/app/oracle/oradata/dsidb/users01.dbf'

 

可以看到数据库查询表test报错,我们再看一下数据库日志

2018-05-25 01:16: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/app/oracle/oradata/dsidb/users01.dbf'

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

 

可以看到文件头上的check value值为0xf9ff,计算的check sum值为0x100

 

然后我们再使用BBED去sum一下这个数据块,可以看到,当前check value的值为f9ff,而需要的值为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

 

我们根据 0xf9ff与0x100计算一下当前block正常的checksum值应该是多少。

F9FF= 1111 1001 1111 1111

100=  0000 0001 0000 0000

根据异或算法原理,这里很容易可以看出oracle计算出来的正确的checksum值应该是:  1111 1000 1111 1111, 也就是f8ff

 

好了,我们这里如法炮制再改一次上述block的checksum值,即将上述block的checksum值改为f8 ff

 

我们先verify一下

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? (Y/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 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 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 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

 

 <32 bytes per line>

 

BBED> sum apply

Check value for File 4, Block 284:

current = 0xf8ff, required = 0xf8ff

 

 

然后再次verify,可以看到,已经不报坏块了。

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

 

数据也可以正常返回了。

SQL> select * from test;

 

        ID NAME

---------- ----------

         2 AAAAA

 

 

 

2.重现数据块内空间计算错误?(详细的实验操作步骤,BBED工具verify如下命令提示)

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(1,'AAAAA');

 

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

 

 <32 bytes per line>

 

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

您可能感兴趣的文档:

--结束END--

本文标题: 怎么计算出正确的checksum值?

本文链接: https://www.lsjlt.com/news/49351.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 怎么计算出正确的checksum值?
    1)创建一个测试表 SQL> create table test (id int, name varchar2(10));   Table created. ...
    99+
    2024-04-02
  • php怎么正确计算中文字符串的长度
    今天小编给大家分享一下php怎么正确计算中文字符串的长度的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。一、PHP中字符串长度...
    99+
    2023-07-05
  • 开发函数计算的正确姿势——tensor
    前言 首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行...
    99+
    2023-01-31
    函数 姿势 正确
  • C++的运算符怎么正确使用
    今天小编给大家分享一下C++的运算符怎么正确使用的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。前言运算符的作用:用于执行代码...
    99+
    2023-06-29
  • 开发函数计算的正确姿势 —— 爬虫
    在 《函数计算本地运行与调试 - Fun Local 基本用法》 中,我们介绍了利用 Fun Local 本地运行、调试函数的方法。但如果仅仅这样简单的介绍,并不能展现 Fun Local 对函数计算开发的巨大效率的提升。这一次,我们拿一个...
    99+
    2023-06-03
  • 选择云计算数据库的正确方法是什么
    这篇文章将为大家详细讲解有关选择云计算数据库的正确方法是什么,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。近年来,企业将本地部署的数据迁移云端越来越成为一种...
    99+
    2024-04-02
  • jquery怎么在IE8中正确设置text的值
    这篇文章主要介绍“jquery怎么在IE8中正确设置text的值”,在日常操作中,相信很多人在jquery怎么在IE8中正确设置text的值问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”jquery怎么在IE...
    99+
    2023-07-06
  • 怎么正确设计404错误页面
    小编给大家分享一下怎么正确设计404错误页面,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!404错误页面是什么?HTTP 404 错误意味着链接指向的网页不存在,...
    99+
    2023-06-10
  • 开发函数计算的正确姿势 —— 安装第三
    前言 首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传。函数计算准备计算资源,并以弹性伸缩的方式运行...
    99+
    2023-01-31
    函数 姿势 正确
  • Python中怎么正确实现一个算法
    本篇文章给大家分享的是有关Python中怎么正确实现一个算法,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。Python算法具体操作代码示例:# -*- co...
    99+
    2023-06-17
  • 怎么为Edm.DateTime的OData参数指定正确格式的值
    这篇文章主要讲解了“怎么为Edm.DateTime的OData参数指定正确格式的值”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么为Edm.DateTime的OData参数指定正确格式的值...
    99+
    2023-06-03
  • 怎么用VBS精确计算2的100次方
    这篇文章主要介绍了怎么用VBS精确计算2的100次方,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。既然Python可以计算2的100次方,那么我就要用VBS实现。不过这个效率...
    99+
    2023-06-08
  • Java中怎么精确计算浮点数
    今天就跟大家聊聊有关Java中怎么精确计算浮点数,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。问题的提出:XML:namespace prefix = o ns = "ur...
    99+
    2023-06-03
  • Java精确计算BigDecimal类怎么使用
    本篇内容主要讲解“Java精确计算BigDecimal类怎么使用”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Java精确计算BigDecimal类怎么使用”吧!引言float和double类型...
    99+
    2023-06-25
  • win10的计算器怎么调出来
    这篇“win10的计算器怎么调出来”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“win10的计算器怎么调出来”文章吧。win...
    99+
    2023-06-30
  • java怎么计算数组的平均值
    要计算一个数组的平均值,可以使用以下Java代码: public class AverageCalculator { pub...
    99+
    2024-03-14
    java
  • 详解php如何正确计算中文字符串的长度
    在PHP编程中,我们常常遇到需要计算字符串长度的场景。一般情况下,我们习惯用 strlen() 函数或 mb_strlen() 函数来计算字符串长度。然而,在处理中文字符串时,我们会发现使用 strlen() 函数会出现问题,因为中文字符不...
    99+
    2023-05-14
    php字符串 php
  • vue3怎么使用reactive包裹数组正确赋值
    使用reactive包裹数组正确赋值需求:将接口请求到的列表数据赋值给响应数据arrconst arr = reactive([]); const load = () => { const res = [2, 3, 4, 5]...
    99+
    2023-05-16
    Vue3 reactive
  • 在pytorch中计算准确率,召回率和F1值的操作
    看代码吧~ predict = output.argmax(dim = 1) confusion_matrix =torch.zeros(2,2) for t, p in zip...
    99+
    2024-04-02
  • 怎么正确的配置cdn
    正确配置CDN的步骤如下:1.选择合适的CDN服务提供商:根据自己的需求选择合适的CDN服务提供商,考虑到价格、性能、服务质量、服务...
    99+
    2023-09-16
    cdn
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作