<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>惜分飞 &#187; rman构造坏块</title>
	<atom:link href="https://www.xifenfei.com/tag/rman%e6%9e%84%e9%80%a0%e5%9d%8f%e5%9d%97/feed" rel="self" type="application/rss+xml" />
	<link>https://www.xifenfei.com</link>
	<description>提供7*24专业数据库(Oracle,SQL Server,MySQL,PostgreSQL等)恢复和技术支持@Tel:17813235971</description>
	<lastBuildDate>Thu, 29 Oct 2026 15:31:46 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>rman制造坏块,bbed修复坏块</title>
		<link>https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html</link>
		<comments>https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html#comments</comments>
		<pubDate>Thu, 21 Feb 2013 15:10:52 +0000</pubDate>
		<dc:creator><![CDATA[惜分飞]]></dc:creator>
				<category><![CDATA[Oracle备份恢复]]></category>
		<category><![CDATA[bbed修复坏块]]></category>
		<category><![CDATA[rman bbed]]></category>
		<category><![CDATA[rman构造坏块]]></category>

		<guid isPermaLink="false">https://www.xifenfei.com/?p=4164</guid>
		<description><![CDATA[联系：手机/微信(+86 17813235971) QQ(107644445)  &#8230; <a href="https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html">继续阅读 <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div id="xifenfeicopyright">
<p>联系：<a href="https://www.xifenfei.com/about_xifenfei" target="_blank">手机/微信(+86 17813235971)   QQ(107644445)</a><a target="_blank" href="http://wpa.qq.com/msgrd?v=3&#038;uin=107644445&#038;site=qq&#038;menu=yes"><img src="https://www.xifenfei.com/wp-content/themes/img/site_qq.jpg" alt="QQ咨询惜分飞" title="QQ咨询惜分飞"/></a></p>
<p>标题：<a href="https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html" target="_blank">rman制造坏块,bbed修复坏块</a></p>
<p>作者：<a href="https://www.xifenfei.com" target="_blank">惜分飞</a>©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]</p>
</div>
<p>在rman中有隐藏的命令clear,可以标记数据块为corrupt,从而实现数据库坏块试验,本篇blog通过dbv,bbed,table select来验证坏块的出现和修复<br />
<strong>创建测试表</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt;  create table t_xifenfei as  
  2   select object_id,object_name from dba_objects where rownum&lt;10;

Table created.

SQL&gt;  select rowid,
  2   dbms_rowid.rowid_relative_fno(rowid) rel_fno,
  3   dbms_rowid.rowid_block_number(rowid) block
  4   from chf.t_xifenfei;

ROWID                 REL_FNO      BLOCK
------------------ ---------- ----------
AAAStAAAEAAAACrAAA          4        171
AAAStAAAEAAAACrAAB          4        171
AAAStAAAEAAAACrAAC          4        171
AAAStAAAEAAAACrAAD          4        171
AAAStAAAEAAAACrAAE          4        171
AAAStAAAEAAAACrAAF          4        171
AAAStAAAEAAAACrAAG          4        171
AAAStAAAEAAAACrAAH          4        171
AAAStAAAEAAAACrAAI          4        171

9 rows selected.

SQL&gt; alter system checkpoint;

System altered.
</pre>
<p><strong>dbv验证坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
[oracle@xifenfei ~]$ dbv file=/u01/oracle/oradata/ora11g/users01.dbf

DBVERIFY: Release 11.2.0.3.0 - Production on Sun Jan 20 09:12:16 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/oracle/oradata/ora11g/users01.dbf


DBVERIFY - Verification complete

Total Pages Examined         : 7680
Total Pages Processed (Data) : 3776
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 167
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 744
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2993
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1006717955 (2956.1006717955)
</pre>
<p>这里创建了t_xifenfei表,数据存储在file 4 block 171中,现在该block一切正常,本试验就是要通过rman来使得该block corrupt,然后通过bbed来修复<br />
<br />
<strong>bbed查看kcbh</strong></p>
<pre class="brush: bash; title: ; notranslate">
BBED&gt; set block 171
        BLOCK#          171

BBED&gt; p kcbh
struct kcbh, 20 bytes                       @0       
   ub1 type_kcbh                            @0        0x06
   ub1 frmt_kcbh                            @1        0xa2
   ub1 spare1_kcbh                          @2        0x00
   ub1 spare2_kcbh                          @3        0x00
   ub4 rdba_kcbh                            @4        0x010000ab
   ub4 bas_kcbh                             @8        0x3c014bfe
   ub2 wrp_kcbh                             @12       0x0b8c
   ub1 seq_kcbh                             @14       0x02
   ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
   ub2 chkval_kcbh                          @16       0x6e0c  &lt;--重点关注
   ub2 spare3_kcbh                          @18       0x0000
</pre>
<p><strong>rman标记坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
RMAN&gt; BLOCKRECOVER DATAFILE 4 block 171 clear;

Starting recover at 20-JAN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
Finished recover at 20-JAN-13
</pre>
<p><strong>dbv再次检查坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
[oracle@xifenfei ~]$ dbv file=/u01/oracle/oradata/ora11g/users01.dbf

DBVERIFY: Release 11.2.0.3.0 - Production on Sun Jan 20 09:53:16 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/oracle/oradata/ora11g/users01.dbf
Page 171 is marked corrupt
Corrupt block relative dba: 0x010000ab (file 4, block 171)
Bad check value found during dbv: 
Data in bad block:
 type: 6 format: 2 rdba: 0x010000ab
 last change scn: 0x0b8c.3c014bfe seq: 0x2 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x4bfe0602
 check value in block header: 0x6e0c
 computed block checksum: 0xb5bc


DBVERIFY - Verification complete

Total Pages Examined         : 7680
Total Pages Processed (Data) : 3775
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 167
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 744
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2993
Total Pages Marked Corrupt   : 1
Total Pages Influx           : 1
Total Pages Encrypted        : 0
Highest block SCN            : 1006717955 (2956.1006717955)
</pre>
<p><strong>尝试查询数据</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select count(*) from t_xifenfei;
select count(*) from t_xifenfei
                     *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 4, block # 171)
ORA-01110: data file 4: '/u01/oracle/oradata/ora11g/users01.dbf'
</pre>
<p><strong>bbed验证坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
BBED&gt; set block 171
        BLOCK#          171

BBED&gt; p kcbh
struct kcbh, 20 bytes                       @0       
   ub1 type_kcbh                            @0        0x06
   ub1 frmt_kcbh                            @1        0xa2
   ub1 spare1_kcbh                          @2        0x00
   ub1 spare2_kcbh                          @3        0x00
   ub4 rdba_kcbh                            @4        0x010000ab
   ub4 bas_kcbh                             @8        0x3c014bfe
   ub2 wrp_kcbh                             @12       0x0b8c
   ub1 seq_kcbh                             @14       0x02
   ub1 flg_kcbh                             @15       0x04 (KCBHFCKV)
   ub2 chkval_kcbh                          @16       0x6e0c  &lt;--注意该值未变化
   ub2 spare3_kcbh                          @18       0x0000

BBED&gt; verify
DBVERIFY - Verification starting
FILE = /u01/oracle/oradata/ora11g/users01.dbf
BLOCK = 171

Block 171 is corrupt
Corrupt block relative dba: 0x010000ab (file 0, block 171)
Bad check value found during verification
Data in bad block:
 type: 6 format: 2 rdba: 0x010000ab
 last change scn: 0x0b8c.3c014bfe seq: 0x2 flg: 0x04
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x4bfe0602
 check value in block header: 0x6e0c
 computed block checksum: 0xb5bc


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 0
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 1
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED
</pre>
<p>这里通过dbv,bbed,select table都证明rman能够标记block为Corrupt.<br />
这里需要分析:block已经被标记,那证明该块肯定有修改,也就是说chkval_kcbh一定要变化,但是这里没有变化,证明该处异常<br />
<br />
<strong>bbed修复rman生成坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
BBED&gt; sum apply
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
Check value for File 0, Block 171:
current = 0xdbb0, required = 0xdbb0

BBED&gt; verify
DBVERIFY - Verification starting
FILE = /u01/oracle/oradata/ora11g/users01.dbf
BLOCK = 171


DBVERIFY - Verification complete

Total Blocks Examined         : 1
Total Blocks Processed (Data) : 1
Total Blocks Failing   (Data) : 0
Total Blocks Processed (Index): 0
Total Blocks Failing   (Index): 0
Total Blocks Empty            : 0
Total Blocks Marked Corrupt   : 0
Total Blocks Influx           : 0
Message 531 not found;  product=RDBMS; facility=BBED
</pre>
<p><em>bbed测试坏块已经修复</em><br />
<br />
<strong>dbv验证坏块</strong></p>
<pre class="brush: bash; title: ; notranslate">
[oracle@xifenfei ~]$ dbv file=/u01/oracle/oradata/ora11g/users01.dbf

DBVERIFY: Release 11.2.0.3.0 - Production on Sun Jan 20 10:01:46 2013

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/oracle/oradata/ora11g/users01.dbf

DBVERIFY - Verification complete

Total Pages Examined         : 7680
Total Pages Processed (Data) : 3776
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 167
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 744
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 2993
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Total Pages Encrypted        : 0
Highest block SCN            : 1006717955 (2956.1006717955)
</pre>
<p>dbv测试坏块也被修复<br />
<br />
<strong>查询表验证</strong></p>
<pre class="brush: sql; title: ; notranslate">
SQL&gt; select count(*) from t_xifenfei;

  COUNT(*)
----------
         9
</pre>
<p>数据也可以正常查询,证明rman的坏块问题通过bbed解决<br />
<br />
<strong>总结说明</strong><br />
1.我们可以通过rman的clear命令来标记坏块(BLOCKRECOVER DATAFILE file# BLOCK block1#, block2#, block3#&#8230; CLEAR ;)<br />
2.我们可以通过bbed的sum apply命令来修复该类型坏块</p>
<div id="crp_related"><ul><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/07/dbv-controlfile.html" rel="bookmark" class="crp_title">需要注意:dbv 检测controlfile可能不准</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/09/%e5%81%87%e5%9d%8f%e5%9d%97%e5%bc%95%e8%b5%b7%e6%81%90%e6%85%8c.html" rel="bookmark" class="crp_title">假坏块引起恐慌</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2023/09/bbed-ora-1578.html" rel="bookmark" class="crp_title">bbed解决ORA-01578</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/ora-01578%e5%9d%8f%e5%9d%97%e8%a7%a3%e5%86%b31.html" rel="bookmark" class="crp_title">ORA-01578坏块解决(1)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2026/09/obet-repair-oracle-block.html" rel="bookmark" class="crp_title">obet快速修复oracle 位图损坏块</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/06/ora-00756-ora-10567-0-lost-recovery.html" rel="bookmark" class="crp_title">ORA-00756 ORA-10567故障数据0丢失恢复</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/02/table%e4%b8%ad%e5%90%84%e7%a7%8d%e5%9d%8f%e5%9d%97%e5%af%b9selectdml%e6%93%8d%e4%bd%9c%e5%bd%b1%e5%93%8d.html" rel="bookmark" class="crp_title">table中各种坏块对select/dml操作影响</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2011/08/ora-01578%e5%9d%8f%e5%9d%97%e8%a7%a3%e5%86%b32.html" rel="bookmark" class="crp_title">ORA-01578坏块解决(2)</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/undo%e5%9d%8f%e5%9d%97%e5%af%bc%e8%87%b4%e6%95%b0%e6%8d%ae%e5%ba%93%e5%bc%82%e5%b8%b8%e7%bb%88%e6%ad%a2%e6%a1%88%e4%be%8b.html" rel="bookmark" class="crp_title">undo坏块导致数据库异常终止案例</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2012/06/%e6%89%be%e5%87%badbv%e7%9b%b8%e5%85%b3dba%e5%80%bc%e5%9c%a8%e6%95%b0%e6%8d%ae%e6%96%87%e4%bb%b6%e4%b8%ad%e5%af%b9%e5%ba%94%e4%bd%8d%e7%bd%ae.html" rel="bookmark" class="crp_title">找出dbv相关dba值在数据文件中对应位置</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2013/02/table%e4%b8%ad%e5%90%84%e7%a7%8d%e7%b1%bb%e5%9e%8bblock%e5%9d%8f%e5%9d%97%e6%98%af%e5%90%a6%e8%83%bd%e8%a2%ab%e8%b7%b3%e8%bf%87.html" rel="bookmark" class="crp_title">table中各种类型block坏块是否能被跳过</a></li><li style="list-style-type:decimal;font-size:11px;" ><a href="https://www.xifenfei.com/2025/11/patch_blk.html" rel="bookmark" class="crp_title">Oracle坏块修复工具:Patch_blk</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>https://www.xifenfei.com/2013/02/rman%e5%88%b6%e9%80%a0%e5%9d%8f%e5%9d%97bbed%e4%bf%ae%e5%a4%8d%e5%9d%8f%e5%9d%97.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
