设为首页 收藏本站
查看: 326|回复: 0

[经验分享] 基于rman的坏块恢复

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-6-17 08:59:47 | 显示全部楼层 |阅读模式
实验步骤如下:

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号块做测试,现在可以查出记录



    gyj@PROD> 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



    [iyunv@jfdb ~]# su - oracle  
    [oracle@jfdb ~]$ 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表的记录



    gyj@PROD> alter system flush buffer_cache;  
      
    System altered.  
      
    gyj@PROD> 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号文件的坏块



    gyj@PROD> 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;)



    gyj@PROD> select FILE#,BLOCK#,BLOCKS,CORRUPTION_CHANGE#,CORRUPTION_TYPE from v$database_block_corruption where file#=5;  
      
    no rows selected  



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



    gyj@PROD> 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  


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-20637-1-1.html 上篇帖子: oracle 11g ocr 冗余配置 下篇帖子: Oracle递归查询的原理
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表