基于rman的坏块恢复

转载请注明出处 http://blog.csdn.net/guoyjoe/article/details/30965303

  实验步骤如下:

1、使用rman备份全库

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Jun 8 15:30:35 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PROD (DBID=254815294)

RMAN> backup database;

Starting backup at 08-JUN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=142 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/PROD/system01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/tp01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/PROD/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/PROD/undotbs01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/PROD/users01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JUN-14
channel ORA_DISK_1: finished piece 1 at 08-JUN-14
piece handle=/u01/app/oracle/product/11.2.0/dbs/01pab691_1_1 tag=TAG20140608T153040 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 08-JUN-14
channel ORA_DISK_1: finished piece 1 at 08-JUN-14
piece handle=/u01/app/oracle/product/11.2.0/dbs/02pab69q_1_1 tag=TAG20140608T153040 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-JUN-14

2、利用BBED破坏块

(1)针对gyj_t1表的20869号块做测试,现在可以查出记录

[email protected]> select id,name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from gyj_t1;

        ID NAME       DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
---------- ---------- ------------------------------------ ------------------------------------
         1 oracledba                                     5                                20869

(2)使用BBED破坏20869号块的seq

[[email protected] ~]# su - oracle
[[email protected] ~]$ bbed parfile=par.txt
Password: 

BBED: Release 2.0.0.0.0 - Limited Production on Sun Jun 8 15:33:10 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

************* !!! For Oracle Internal Use only !!! ***************

BBED> set file 5   block 20869
        FILE#           5
        BLOCK#          20869

BBED> map /v
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20869                                 Dba:0x01405185
------------------------------------------------------------
 KTB Data Block (Table/Cluster)

 struct kcbh, 20 bytes                      @0
    ub1 type_kcbh                           @0
    ub1 frmt_kcbh                           @1
    ub1 spare1_kcbh                         @2
    ub1 spare2_kcbh                         @3
    ub4 rdba_kcbh                           @4
    ub4 bas_kcbh                            @8
    ub2 wrp_kcbh                            @12
    ub1 seq_kcbh                            @14
    ub1 flg_kcbh                            @15
    ub2 chkval_kcbh                         @16
    ub2 spare3_kcbh                         @18      

 struct ktbbh, 72 bytes                     @20
    ub1 ktbbhtyp                            @20
    union ktbbhsid, 4 bytes                 @24
    struct ktbbhcsc, 8 bytes                @28
    sb2 ktbbhict                            @36
    ub1 ktbbhflg                            @38
    ub1 ktbbhfsl                            @39
    ub4 ktbbhfnx                            @40
    struct ktbbhitl[2], 48 bytes            @44      

 struct kdbh, 14 bytes                      @100
    ub1 kdbhflag                            @100
    sb1 kdbhntab                            @101
    sb2 kdbhnrow                            @102
    sb2 kdbhfrre                            @104
    sb2 kdbhfsbo                            @106
    sb2 kdbhfseo                            @108
    sb2 kdbhavsp                            @110
    sb2 kdbhtosp                            @112     

 struct kdbt[1], 4 bytes                    @114
    sb2 kdbtoffs                            @114
    sb2 kdbtnrow                            @116     

 sb2 kdbr[1]                                @118     

 ub1 freespace[8038]                        @120     

 ub1 rowdata[30]                            @8158    

 ub4 tailchk                                @8188    

BBED> 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        0x01405185
   ub4 bas_kcbh                             @8        0x00176fed
   ub2 wrp_kcbh                             @12       0x0000
   ub1 seq_kcbh                             @14       0x01
   ub1 flg_kcbh                             @15       0x06 (KCBHFDLC, KCBHFCKV)
   ub2 chkval_kcbh                          @16       0xc140
   ub2 spare3_kcbh                          @18       0x0000

BBED> m /x ff offset 14
Warning: contents of previous BIFILE will be lost. Proceed? (Y/N) y
 File: /u01/app/oracle/oradata/PROD/tp01.dbf (5)
 Block: 20869            Offsets:   14 to  525           Dba:0x01405185
------------------------------------------------------------------------
 ff0640c1 00000100 00003945 0000eb6f 17000000 00000200 32008051 40010700
 20008b02 00002c49 c0002301 02000080 0000876d 17000300 1a007503 0000bf1f
 c0002501 0c000120 0000ed6f 17000000 00000000 00000001 0100ffff 14007a1f
 741f741f 00000100 7a1f0000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 

 <32 bytes per line>

BBED> sum apply
Check value for File 5, Block 20869:
current = 0xc1be, required = 0xc1be

(3)校验报坏块

BBED> verify
DBVERIFY - Verification starting
FILE = /u01/app/oracle/oradata/PROD/tp01.dbf
BLOCK = 20869

Block 20869 is corrupt
Corrupt block relative dba: 0x01405185 (file 0, block 20869)
Fractured block found during verification
Data in bad block:
 type: 6 format: 2 rdba: 0x01405185
 last change scn: 0x0000.00176fed seq: 0xff flg: 0x06
 spare1: 0x0 spare2: 0x0 spare3: 0x0
 consistency value in tail: 0x6fed0601
 check value in block header: 0xc1be
 computed block checksum: 0x0

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           : 2
Message 531 not found;  product=RDBMS; facility=BBED

(4)确定不能查gyj_t1表的记录

[email protected]> alter system flush buffer_cache;

System altered.

[email protected]> select id,name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from gyj_t1;
select id,name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from gyj_t1
*
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 5, block # 20869)
ORA-01110: data file 5: ‘/u01/app/oracle/oradata/PROD/tp01.dbf‘

3、使用RMAN验证5号数据文件

RMAN> backup validate datafile 5;

Starting backup at 08-JUN-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/PROD/tp01.dbf
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
5    FAILED 0              114          64000           1659211
  File Name: /u01/app/oracle/oradata/PROD/tp01.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       1              58883
  Index      0              4221
  Other      0              782             

validate found one or more corrupt blocks
See trace file /u01/app/oracle/diag/rdbms/prod/PROD/trace/PROD_ora_2750.trc for details
Finished backup at 08-JUN-14

4、查5号文件的坏块

[email protected]> select FILE#,BLOCK#,BLOCKS,CORRUPTION_CHANGE#,CORRUPTION_TYPE from v$database_block_corruption where file#=5;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTIO
---------- ---------- ---------- ------------------ ---------
         5      20869          1                  0 FRACTURED

5、使用rman恢复坏块

RMAN> blockrecover datafile 5 block  20869;

Starting recover at 08-JUN-14
using channel ORA_DISK_1

channel ORA_DISK_1: restoring block(s)
channel ORA_DISK_1: specifying block(s) to restore from backup set
restoring blocks of datafile 00005
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/product/11.2.0/dbs/01pab691_1_1
channel ORA_DISK_1: piece handle=/u01/app/oracle/product/11.2.0/dbs/01pab691_1_1 tag=TAG20140608T153040
channel ORA_DISK_1: restored block(s) from backup piece 1
channel ORA_DISK_1: block restore complete, elapsed time: 00:00:01

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 08-JUN-14

6、再次查5号文件的坏块,已经消息了(如果还有记录,那再次执行backup validate datafile 5;)

[email protected]> select FILE#,BLOCK#,BLOCKS,CORRUPTION_CHANGE#,CORRUPTION_TYPE from v$database_block_corruption where file#=5;

no rows selected

7、查表gyj_t1记录也有了,说明恢复成功

[email protected]> select id,name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from gyj_t1;

        ID NAME       DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID) DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
---------- ---------- ------------------------------------ ------------------------------------
         1 oracledba                                     5                                20869

基于rman的坏块恢复

时间: 2024-08-07 00:33:27

基于rman的坏块恢复的相关文章

【转】基于RMAN实现坏块介质恢复(blockrecover)

本文转自:乐沙弥的世界 对于物理损坏的数据块,我们可以通过RMAN块介质恢复(BLOCK MEDIA RECOVERY)功能来完成受损块的恢复,而不需要恢复整个数据库或所有文件来修复这些少量受损的数据块.恢复整个数据库或数据文件那不是大炮用来打蚊子,有点不值得!但前提条件是你得有一个可用的RMAN备份存在,因此,无论何时备份就是一切.本文演示了产生坏块即使用RMAN实现坏块恢复的全过程. 1.创建演示环境 SQL> select * from v$version where rownum<2;

无RMAN备份集情况下的坏块恢复

测试的环境是没有可用的RMAN备份集,但是有数据文件的热备,下面来看测试: --创建测试用户和测试表 [[email protected] ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on 16 16:01:02 2014 Copyright (c) 1982, 2005, Oracle.  All rights reserved. Connected to: Oracle Database 10g Ente

使用BBED修复Oracle坏块恢复方法

BBED是Block Browser/Editor的缩写,是Oracle的一个内部工具,不对外发布文档及支持. BBED随软件发布,但是我们需要进行简单的relink才能使用. 虽然BBED工具的使用存在很多风险,但是如果利用得当,可以以之解决很多棘手的问题,并且可以练习坏块修复等技术. 例如在Oracle10g中的bbed工具,同样需要我们手工relink才能使用,这个版本的工具同样可以在其他版本的数据库中使用: [[email protected] lib]$ make -f ins_rdb

Oracle数据库坏块的恢复

模拟数据块坏块: 对于发生数据块不一致的数据块,如果当前数据库有备份且处于归档模式,那么就可以利用rman工具数据块恢复功能 对数据块进行恢复,这种方法最简单有效,而且可以在数据文件在线时进行,不会发生数据丢失.对于被有备份的数据库 发生数据块损坏,可能会发生数据的丢失或数据不丢失,这要根据发生坏块的所在的对象决定的,如索引块发生损坏,数据 就不会丢失,重建索引就可以了,发生数据丢失的多发生在表或分区表数据块上. 1.不丢数据的恢复方法 ---使用rman工具的 blockrecover blo

Oracle Rman修复逻辑坏块

RMAN 实现数据块恢复试用Rman可以实现数据块级的数据恢复,在传统恢复手段中即某个数据文件的一个数据块被损坏,就造成整个数据文件无法试用,此时必须通过备份恢复整个数据文件.显然这样的方法会会时间较长,而RMAN实现块级恢复,如果某个数据文件的数据损坏,通过数据文件的完整备份就可以恢复数据块. 案例:数据库是一个单实例ORACLE数据库,该库的总大小有700G.存储设备使用华为存储,备份设备使用希捷3T的移动硬盘.该数据库无DG无OGG.备份策略为每周六0点全库备份,周三0点1级差异备份其余时

oracle数据坏块检测

1.使用dbv检查 D:\oradata\eygle>dbv file=EYGLE.DBF blocksize=8192 DBVERIFY: Release 10.1.0.4.0 - Production on 星期六 6月 11 17:36:37 2005 Copyright (c) 1982, 2004, Oracle.  All rights reserved. DBVERIFY - 开始验证: FILE = EYGLE.DBF 页 219 标记为损坏 Corrupt block rela

[Oracle]ORA-600[kdBlkCheckError]LOB坏块处理

客户环境报如下错误: ORA - 00600: Internal error code, arguments: [kdBlkCheckError], [2], [10388], [63068], [], [], [], [], [], [], [], [] alert log 中有这样的信息: Thu Sep 07 19:14:00 2017Corrupt Block Found        CONT = 0, TSN = 1, TSNAME = SYSAUX        RFN = 2,

恢复数据块坏块

2014.7.22研究恢复数据库坏块: Oracle调用标准C的系统函数,对数据块进行读写操作,因此,坏块是有可能由以下几种原因产生: 硬件的I/O错误 操作系统的I/O错误或缓冲问题 内存或paging问题 磁盘修复工具 一个数据文件的一部分正在被覆盖 Oracle试图访问一个未被格式化的系统块失败 数据文件部分溢出 Oracle或者操作系统的bug 遇到"ORA-01578:ORACLE data block corrupted"错误 处理方法:1.rman的recover命令可以

案例:Oracle exp dmp文件存在坏块并损坏 使用CPFL跳过坏块并成功导入恢复

Oracle数据库exp导出dmp文件损坏存在坏块/corruption通过CPFL工具跳过dmp坏块进发导入 在有些情况下,大家都知道通过dul可以恢复损坏的dmp文件的表的数据,但是该方法有很多问题,特别是对很多数据类型的支持不够完美,比如lob,long raw类型等,而且还有可能恢复出来数据大量丢失,本人通过对dmp结构的分析,使用使用一些特殊的技巧方法,可以实现对于损坏的dmp文件,通过跳过异常坏块所在表,继续恢复后续表,从而最大程度减少损坏 1.创建Oracle测试表 SQL> co