一、现象

● 在数据库中有一个概念叫做数据块的一致性,Oracle 的数据块的一致性包括了两个层次:物理一致性和逻辑一致性,如果一个数据块在这两个层次上存在不一致性,那就对应到了物理坏块和逻辑坏块。在物理块损坏(也称为媒体损坏)中,数据库根本无法识别该块:校验和无效,块包含全零,块的页眉和页脚不匹配,或者关键数据块数据结构之一不正确等。在逻辑块损坏中,块的内容在物理上是健全的,并且通过了物理块检查;然而,该块在逻辑上可能不一致。逻辑损坏的示例包括行或索引条目的损坏。具体介绍请参考MOS文章:Physical and Logical Block Corruptions. All you wanted to know about it. (Doc ID 840978.1),本文主要介绍发生坏块故障时,应该如何修复。一、现象客户一套 12.1.0.2 RAC 数据库在做 Rman 备份的时候报错 ORA-19566 如下图所示:

 ORA - 19566: exceeded limit of 0 corrupt blocks for file……” ,意思是在文件中检测到的损坏块数量超过了允许的最大限制,根据报错可以很明确看到,数据文件 tbs_bffl_0566.dbf 中出现了坏块。

二、坏块修复1.dbv 检查坏块

dbv file='+DATAC1/DBM/DATAFILE/tbs_bffl_0566.dbf'

 

检查发现存在 870988 和 871208 两个坏块,可以通过 Rman 继续查询坏块信息:

RMAN>backup validate datafile 721;

RMAN VALIDATE 后,错误信息会记录到 v$database_block_corruption 视图中,查询 v$database_block_corruption 视图:

select * from v$database_block_corruption;

可看到有两个坏块,通过 dba_extents 视图查看坏块上的对象是什么

SELECT * FROM dba_extentsWHERE file_id = &AFNand &BL between block_id AND block_id + blocks - 1;

问题到这里有个疑问,这个数据库有灾备环境,正常来说11g之后如果有灾备,可以自行修复坏块,为什么没自动修复呢?查询官网资料:https://docs.oracle.com/cd/E18283_01/server.112/e17022/manage_ps.htm#SBYDB00707,以下摘自官网说明:

9.2.1.5 Automatic Repair of Corrupt Data Blocks

A physical standby database operating in real-time query mode can also be used to repair corrupt data blocks in a primary database. If possible, any corrupt data block encountered when a primary database is accessed is automatically replaced with an uncorrupted copy of that block from a physical standby database operating in real-time query mode. Note that for this to work, the standby database must be synchronized with the primary database.

If a corrupt data block is discovered on a physical standby database, the server attempts to automatically repair the corruption by obtaining a copy of the block from the primary database if the following database initialization parameters are configured on the standby database:

● The parameter is configured with a list and a parameter is configured for the primary database LOG_ARCHIVE_CONFIG DG_CONFIG LOG_ARCHIVE_DEST_n

or

● The parameter is configured and its value contains an Oracle Net service name for the primary database FAL_SERVER

If automatic repair is not possible, an error is returned ORA-1578

总结起来就是:

主库出现坏块自动用备库的块拷贝修复,要求有下:

standby 库需要 using current logfile。

 

备库出现坏块自动用主库的块修复,要求如下:

The LOG_ARCHIVE_CONFIG 参数配置了 DG_CONFIG 列表,且 LOG_ARCHIVE_DEST_n parameter is configured for the primary database ,或者:备库配置了 FAL_SERVER 指向主库。

 

 

经过检查发现 ADG 配置不满足要求因此无法自动修复。由于客户生产端 Rman 备份好久没成功,因此从灾备备份相应文件传输到主库修复。

2.灾备 ADG 端备份相应数据文件

backup datafile 721 format '/u01/app/oracle/rmanbk/721,bak';

scp 传输到主库。

3.主库修复 

rman>catalog start with '/u01/app/oracle/rmanbk';
rman>blockrecover datafile 721 block 870988 from packupset;
rman>blockrecover datafile 721 block 871208 from packupset;

dbv检查:

dbv file='+DATAC1/DBM/DATAFILE/tbs_bffl_0566.dbf'

至此修复完成,本次就分享到这里,如有不对,请指正!

 posted on 2025-02-14 09:47  xibuhaohao  阅读(46)  评论(0)    收藏  举报