共计 2826 个字符,预计需要花费 8 分钟才能阅读完成。
检测 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。
更多 Oracle 相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-05/131758.htm