检测Oracle数据库坏块的方法

检测Oracle数据库坏块的办法:

1、使用DBV(DB File Verify)工具;

2、使用RMAN(Recovery Manager)工具;

DBV(DB File Verify)工具:

外部命令,物理介质数据结构完整性检查;

只能用于数据文件(offline或online),不支持控制文件和重做日志文件的块检查;

也可以验证备份文件(rman的copy命令备份或操作系统CP命令备份);

进入盘符,然后执行以下脚本:

D:\app\Administrator\oradata\orcl>dbv file=ZL9MTLBASE.DBF blocksize=8192;

检测Oracle数据库坏块的方法

RMAN(Recovery Manager)工具:

逻辑数据结构完整性检查

在线使用Recovery Manager扫描坏块和备份时,需要数据库运行在归档模式(archive log),否则只能在数据库未打开(mount)的情况下进行;

RMAN>backup check logical validate datafile n ;

以上命令可以检查数据文件是否包含坏块,同时并不产生实际的备份输出。

而且当使用Recovery Manager进行实际的数据库备份时,同时也就进行了坏块检查。

直接使用RMAN的命令:backup validate check logical database;

结合V$DATABASE_BLOCK_CORRUPTION视图更方便。

1)、rman target / nocatalog

2)、RMAN> spool log to 'd:/dbbak/rmanlog.log';---指定输出rman日志文件

RMAN> run {
 
allocate channel d1 type disk;
 
allocate channel d2 type disk;
 
allocate channel d3 type disk;
 
allocate channel d4 type disk;
 
backup validate check logical database;
 
};

3)、select * from V$DATABASE_BLOCK_CORRUPTION;

4) 、--If V$DATABASE_BLOCK_CORRUPTION contains rows please run this query to find the objects that contains the corrupted blocks:


SELECT e.owner,

e.segment_type,

e.segment_name,

e.partition_name,

c.file#,

greatest(e.block_id, c.block#) corr_start_block#,

least(e.block_id + e.blocks - 1, c.block# + c.blocks - 1) corr_end_block#,

least(e.block_id + e.blocks - 1, c.block# + c.blocks - 1) -

greatest(e.block_id, c.block#) + 1 blocks_corrupted,

null description

FROM dba_extents e, v$database_block_corruption c

WHERE e.file_id = c.file#

AND e.block_id <= c.block# + c.blocks - 1

AND e.block_id + e.blocks - 1 >= c.block#

UNION

SELECT s.owner,

s.segment_type,

s.segment_name,

s.partition_name,

c.file#,

header_block corr_start_block#,

header_block corr_end_block#,

1 blocks_corrupted,

'Segment Header' description

FROM dba_segments s, v$database_block_corruption c

WHERE s.header_file = c.file#

AND s.header_block between c.block# and c.block# + c.blocks - 1

UNION

SELECT null owner,

null segment_type,

null segment_name,

null partition_name,

c.file#,

greatest(f.block_id, c.block#) corr_start_block#,

least(f.block_id + f.blocks - 1, c.block# + c.blocks - 1) corr_end_block#,

least(f.block_id + f.blocks - 1, c.block# + c.blocks - 1) -

greatest(f.block_id, c.block#) + 1 blocks_corrupted,

'Free Block' description

FROM dba_free_space f, v$database_block_corruption c

WHERE f.file_id = c.file#

AND f.block_id <= c.block# + c.blocks - 1

AND f.block_id + f.blocks - 1 >= c.block#

order by file#, corr_start_block#;

5)、

SELECT tablespace_name, segment_type, owner, segment_name
FROM dba_extents
        WHERE file_id = &fileid
and &blockid between block_id AND block_id + blocks - 1;

告警日志中快速识别:

遇到坏块问题时,数据库的异常表现通常有: 

报告ORA-01578错误。 

报告ORA-1110错误。 

报告ORA-00600错误。其中,第一个参数为2000-8000,Cache layer 2000 – 4000,Transaction layer 4000 – 6000,Data layer 6000 - 8000。 

Trace文件中出现Corrupt block dba: 0x160c5958 . found。 分析对象失败。 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/dfaa11096f2eb95693f07f3823319eb3.html