暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

在Oracle中,什么是坏块?坏块可以分为哪几类?

DB宝 2020-04-26
2053


题目部分

在Oracle中,什么是坏块?坏块可以分为哪几类?


     





答案部分


Oracle数据文件的坏块可以分为物理坏块Physical Block Corruptions和逻辑坏块Logical Block Corruptions。坏块通常是通过OracleORA-01578错误报告出来的,详细的损坏描述会在告警日志中打印出来,“oerr ora”对该错误的解释如下所示:

1[root@rhel6lhr ~]# oerr ora 1578
201578, 00000, "ORACLE data block corrupted (file # %s, block # %s)"
3// *Cause:  The data block indicated was corrupted, mostly due to software
4//          errors.
5// *Action: Try to restore the segment containing the block indicated. This
6//          may involve dropping the segment and recreating it. If there
7//          is a trace file, report the errors in it to your ORACLE
8//          representative.

可能的报错如下所示:

1ORA-01578: ORACLE data block corrupted (file # 11, block # 110)
2ORA-01110: data file 6: '/u01/app/oracle/oradata/orcl/tbs01.dbf'

在以上示例中,绝对文件号(AFNAbsolute File Number)为11,块号(Block Number)为110

使用如下的SQL可以获取相对文件号RFNRFNRelative File Number):

1SELECT DBMS_UTILITY.DATA_BLOCK_ADDRESS_FILE(&&RDBA) RFN,
2       DBMS_UTILITY.DATA_BLOCK_ADDRESS_BLOCK(&&RDBA) BL
3FROM DUAL;

其中,RDBARelative Data Block Address)表示相对数据块地址。

使用如下的SQL可以获取绝对文件号AFN

1SELECT FILE_ID AFN, RELATIVE_FNO, TABLESPACE_NAME
2FROM DBA_DATA_FILES
3WHERE RELATIVE_FNO=&RFN;


物理坏块指的是块格式本身已经损坏,块内的数据没有任何意义。物理坏块一般是由于内存问题、OS问题、I/O子系统问题或硬件引起的,逻辑坏块一般是Oracle Bug等原因引起的。物理块损坏也可以称为介质块损坏(Media Corrupt Block)。物理坏块可以分为以下几类:

① 坏头Bad header):数据块头(Cache Header)被无效值损坏

② 有裂缝/不完整(Fractured/Incompleted Block数据块头和块尾不匹配,其trace文件内容如下所示:

 1Corrupt block relative dba: 0x0380e573 (file 14, block 58739)
2Fractured block found during buffer read
3Data in bad block -
4type: 6 format: 2 rdba: 0x0380e573
5last change scn0x0288.8e5a2f78 seq: 0x1 flg: 0x04
6consistency value in tail: 0x00780601
7check value in block header: 0x8739, computed block checksum0x2f00
8spare1: 0x0, spare2: 0x0, spare3: 0x0
9***
10Reread of rdba: 0x0380e573 (file 14block 58739found same corrupted data

③ 块的块校验和checksum无效,其trace内容如下所示:

 1Corrupt block relative dba: 0x0380a58f (file 14, block 42383)
2Bad check value found during buffer read
3Data in bad block -
4type6 format2 rdba: 0x0380a58f
5last change scn0x0288.7784c5ee seq: 0x1 flg: 0x06
6consistency value in tail: 0xc5ee0601
7check value in block header: 0x68a7, computed block checksum0x2f00
8spare1: 0x0, spare2: 0x0, spare3: 0x0
9***
10Reread of rdba: 0x0380a58f (file 14block 42383found same corrupted data

④ 块的位置错误Block Misplaced):检验和正确,但是正在被读取的数据块的内容属于另外一个块

1Corrupt block relative dba: 0x0d805a89 (file 54, block 23177)
2Bad header found during buffer read
3Data in bad block -
4type: 6 format: 2 rdba: 0x0d805b08 ----> Block is different than expected 0x0d805a89
5last change scn0x0692.86dc08e3 seq: 0x1 flg: 0x04
6consistency value in tail: 0x08e30601
7check value in block header: 0x2a6e, computed block checksum0x0
8spare1: 0x0, spare2: 0x0, spare3: 0x0
9***

⑤ 归零的块Zeroed out blocks):可参考Note 1545366.1

 

逻辑坏块指的是块内的数据在逻辑上存在问题,比如说索引块的索引值没有按顺序排列导致的逻辑坏块。逻辑坏通常包含一个正确的checksum和结构,但是块头下的部分(块的内容)被损坏,可能引起不同的ORA-600错误。逻辑损坏详细的损坏信息通常不打印在alert告警日志中,但是DBV将报告逻辑损坏的块。

逻辑坏块可以分为以下几类:

① 行被不存在的事务锁定--ORA-600[4512]

② 使用的空间大小不等于块的大小

③ avsp bad

④ 其它



本文选自《Oracle程序员面试笔试宝典》,作者:小麦苗




    ==================================================================================================================

    【干货来了|小麦苗IT资料分享】
    ★小麦苗DB职场干货:https://mp.weixin.qq.com/s/Vm5PqNcDcITkOr9cQg6T7w
    ★小麦苗数据库健康检查:https://share.weiyun.com/5lb2U2M
    ★小麦苗微店:https://weidian.com/?userid=793741433
    ★各种操作系统下的数据库安装文件(Linux、Windows、AIX等):https://pan.baidu.com/s/1hqff3Evv6oj2-Tn87MpFkQ
    ★小麦苗分享的资料:https://share.weiyun.com/57HUxNi
    ★小麦苗课堂资料:https://share.weiyun.com/5fAdN5m
    ★小麦苗课堂试听资料:https://share.weiyun.com/5HnQEuL
    ★小麦苗出版的相关书籍:https://share.weiyun.com/5sQBQpY
    ★小麦苗博客文章:https://share.weiyun.com/5ufi4Dx
    ★数据库系列(Oracle、MySQL、NoSQL):https://share.weiyun.com/5n1u8gv
    ★公开课录像文件:https://share.weiyun.com/5yd7ukG
    ★其它常用软件分享:https://share.weiyun.com/53BlaHX
    ★其它IT资料(OS、网络、存储等):https://share.weiyun.com/5Mn6ESi
    ★Python资料:https://share.weiyun.com/5iuQ2Fn
    ★已安装配置好的虚拟机:https://share.weiyun.com/5E8pxvT
    ★小麦苗腾讯课堂:https://lhr.ke.qq.com/
    ★小麦苗博客:http://blog.itpub.net/26736162/
    ★OCP培训:https://mp.weixin.qq.com/s/2cymJ4xiBPtTaHu16HkiuA
    ★12c的OCP培训:https://mp.weixin.qq.com/s/hMLHlyjMHhLmA0xN4hLvfw
    ★OCM培训:https://mp.weixin.qq.com/s/7-R6Cz8RcJKduVv6YlAxJA
    ★高可用(RAC+DG+OGG)培训:https://mp.weixin.qq.com/s/4vf042CnOdAD8zDyjUueiw
    ★小麦苗课堂腾讯视频:http://v.qq.com/vplus/71f69a319a24c6808cd6e6189ae90664


    ==================================================================================================================

     本文作者:小麦苗,只专注于数据库的技术,更注重技术的运用

    ● 作者博客地址:http://blog.itpub.net/26736162/abstract/1/

     本系列题目来源于作者的学习笔记,部分整理自网络,若有侵权或不当之处还请谅解

     版权所有,欢迎分享本文,转载请保留出处

     QQ:646634621  QQ群:230161599、618766405

     微信:lhrbestxh

     微信公众号:DB宝

     提供Oracle OCP、OCM、高可用(rac+dg+ogg)和MySQL最实用的技能培训

    ● 题目解答若有不当之处,还望各位朋友批评指正,共同进步

    长按下图识别二维码或微信扫描下图二维码来关注小麦苗的微信公众号:DB宝,学习最实用的数据库技术。



    最后修改时间:2020-06-12 12:44:19
    文章转载自DB宝,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

    评论