检测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;

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。 分析对象失败。

后台进程,如dbwr,lgwr出现长时间异常等待,如lgwr wait for redo copy。

以上所述是www.887551.com给大家介绍的检测oracle数据库坏块的方法 ,希望对大家有所帮助

(0)
上一篇 2022年3月22日
下一篇 2022年3月22日

相关推荐