Oracle BBED工具及坏块修复

Oracle BBED工具及坏块修复

    • 1. BBED简介
    • 2. BBED安装
    • 3. 启动BBED
    • 4. 使用bbed模拟数据块损坏
    • 5. 修复坏块

1. BBED简介

BBED是Block Browser/Editor的缩写,是Oracle的一个内部工具,不对外发布文档及支持。 BBED随软件发布,但是我们需要进行简单的relink才能使用。

2. BBED安装

  1. 在使用bbed前,需进行编译连接。但由于Oracle 11g开始不再提供这两个库文件ssbbded.o,ssbbded.o,我们在编译时会报以下错误:

    [oracle@dbserver1 lib]$ cd $ORACLE_HOME/rdbms/lib
    
    [oracle@dbserver1 lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
    
    Linking BBED utility (bbed)
    rm -f /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/bbed
    gcc -o /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/bbed -m64 -L/u01/app/oracle/product/11.2.0/db_1/rdbms/lib/ -L/u01/app/oracle/product/11.2.0/db_1/lib/ -L/u01/app/oracle/product/11.2.0/db_1/lib/stubs/  /u01/app/oracle/product/11.2.0/db_1/lib/s0main.o /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/ssbbded.o /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/sbbdpt.o `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -ldbtools11 -lclntsh  `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnnz11 -lzt11 -lztkg11 -lztkg11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11 -lmm -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11   -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11   `cat /u01/app/oracle/product/11.2.0/db_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/11.2.0/db_1/lib -lm    `cat /u01/app/oracle/product/11.2.0/db_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/11.2.0/db_1/lib
    gcc: /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/ssbbded.o: No such file or directory
    gcc: /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/sbbdpt.o: No such file or directory
    make: *** [/u01/app/oracle/product/11.2.0/db_1/rdbms/lib/bbed] Error 1
    

    这两个文件可以从Oracle 10g拷贝相关文件到Oracle 11g对应目录下

  2. 如果没有安装Oracle 10g数据库,怎么从Oracle安装介质中提取呢?

    1)安装介质解压,把解压出来的jar包再解压,查找jar包解压出来的文件即可,可以使用以下脚本:
    
    cd database_10.2
    for jar in $(find . -type f -name "*.jar"|grep rdbms);do
    jar -tvf $jar | grep sbbd && echo $jar
    done
    
    2)示例
    [root@dbserver1 database_10.2]# for jar in $(find . -type f -name "*.jar"|grep rdbms);do
    > jar -tvf $jar | grep sbbd && echo $jar
    > done
      1863 Sat Sep 17 19:59:24 CST 2005 rdbms/lib/sbbdpt.o
      1191 Sat Sep 17 19:59:28 CST 2005 rdbms/lib/ssbbded.o
    ./stage/Components/oracle.rdbms/10.2.0.1.0/1/DataFiles/filegroup33.jar
      3043 Thu Sep 08 03:43:08 CST 2005 rdbms/lib32/sbbdpt.o
      2721 Thu Sep 08 03:43:08 CST 2005 rdbms/lib32/ssbbded.o
    ./stage/Components/oracle.rdbms.hybrid/10.2.0.1.0/1/DataFiles/filegroup1.jar
    
    3)找到了32位库文件和64位的库文件,我们只需解压64位jar文件
    
    [root@dbserver1 lib]# jar -xvf filegroup33.jar 
    [root@dbserver1 lib]# ls -l|grep sbbd
    -rw-r--r-- 1 root root    1863 Sep 17  2005 sbbdpt.o
    -rw-r--r-- 1 root root    1191 Sep 17  2005 ssbbded.o
    [root@dbserver1 lib]# chown oracle:oinstall *sbbd*
    
    4)复制到11g $ORACL_HOME/rdbms/lib目录中
    [oracle@dbserver1 lib]$ cp *sbbd* /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/
    
    5)再次编译
    [oracle@dbserver1 lib]$ make -f ins_rdbms.mk $ORACLE_HOME/rdbms/lib/bbed
    
    Linking BBED utility (bbed)
    rm -f /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/bbed
    gcc -o /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/bbed -m64 -L/u01/app/oracle/product/11.2.0/db_1/rdbms/lib/ -L/u01/app/oracle/product/11.2.0/db_1/lib/ -L/u01/app/oracle/product/11.2.0/db_1/lib/stubs/  /u01/app/oracle/product/11.2.0/db_1/lib/s0main.o /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/ssbbded.o /u01/app/oracle/product/11.2.0/db_1/rdbms/lib/sbbdpt.o `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -ldbtools11 -lclntsh  `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnnz11 -lzt11 -lztkg11 -lztkg11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11 -lmm -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lnro11 `cat /u01/app/oracle/product/11.2.0/db_1/lib/ldflags`    -lncrypt11 -lnsgr11 -lnzjs11 -ln11 -lnl11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11   -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11 -lclient11 -lnnetd11  -lvsn11 -lcommon11 -lgeneric11 -lsnls11 -lnls11  -lcore11 -lsnls11 -lnls11 -lcore11 -lsnls11 -lnls11 -lxml11 -lcore11 -lunls11 -lsnls11 -lnls11 -lcore11 -lnls11   `cat /u01/app/oracle/product/11.2.0/db_1/lib/sysliblist` -Wl,-rpath,/u01/app/oracle/product/11.2.0/db_1/lib -lm    `cat /u01/app/oracle/product/11.2.0/db_1/lib/sysliblist` -ldl -lm   -L/u01/app/oracle/product/11.2.0/db_1/lib
    
    [oracle@dbserver1 lib]$ ./bbed 
    Message 112 not found; No message file for product=RDBMS, facility=BBED
    BBED-00113: file not found
    
    6)错误Message 112 not found,说明BBED命令还缺失二个mesg文件:bbedus.msb,bbedus.msg,使用同样的方法获得:
    [oracle@dbserver1 database_10.2]$ for jar in $(find . -type f -name "*.jar"|grep rdbms);do
    > jar -tvf $jar | grep bbedus && echo $jar
    > done
      8704 Fri Sep 09 09:46:10 CST 2005 rdbms/mesg/bbedus.msb
     10270 Tue Jul 25 19:32:00 CST 2000 rdbms/mesg/bbedus.msg
    ./stage/Components/oracle.rdbms.util/10.2.0.1.0/1/DataFiles/filegroup5.jar
    
    [root@dbserver1 opt]# jar -xvf filegroup5.jar 
    
    [root@dbserver1 mesg]# chown oracle:oinstall bbedus.ms*
    
    [oracle@dbserver1 mesg]$ cp bbedus* $ORACLE_HOME/rdbms/mesg/
    

3. 启动BBED

默认情况下,bbed工具是被编译连接到rdbms/lib目录下的。因此并不是在通常的$ORACLE_HOME/bin目录。

  1. 将bbed可执行文件移到bin目录下:
    [oracle@dbserver1 lib]$ cp bbed $ORACLE_HOME/bin/
    
  2. 启动bbed
    [oracle@dbserver1 ~]$ bbed 
    Password: 
    #默认密码:blockedit
    BBED: Release 2.0.0.0.0 - Limited Production on Mon Dec 3 14:50:46 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    ************* !!! For Oracle Internal Use only !!! ***************
    
    BBED> show
    	FILE#          	0
    	BLOCK#         	1
    	OFFSET         	0
    	DBA            	0x00000000 (0 0,1)
    	FILENAME       	
    	BIFILE         	bifile.bbd
    	LISTFILE       	
    	BLOCKSIZE      	8192
    	MODE           	Browse
    	EDIT           	Unrecoverable
    	IBASE          	Dec
    	OBASE          	Dec
    	WIDTH          	80
    	COUNT          	512
    	LOGFILE        	log.bbd
    	SPOOL          	No
    
命令项 描述
BLOCKSIZE 可编辑的数据文件标准块大小。
MODE bbed可运行模式(browser或edit)
SILENT 不将输出打印到标准输出上(Y或N)
SPOOL 操作记录写出到bbed.log文件 (Y或N)
LISTFILE 列出可编辑的文件
CMDFILE 可执行命令的文件名清单
BIFILE undo文件文件名。默认为bifile.bbd
LOGFILE 用户日志文件文件名。默认为log.bbd
PARFILE 列有命令项的参数文件
  1. 测试bbed
    [oracle@dbserver1 ~]$ bbed blocksize=8192 filename=/u01/app/oracle/oradata/ocmdb/users01.dbf
    Password: 
    
    BBED: Release 2.0.0.0.0 - Limited Production on Mon Dec 3 15:10:41 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    ************* !!! For Oracle Internal Use only !!! ***************
    
    BBED> map
     File: /u01/app/oracle/oradata/ocmdb/users01.dbf (0)
     Block: 1                                     Dba:0x00000000
    ------------------------------------------------------------
     Data File Header
    
     struct kcvfh, 860 bytes                    @0       
    
     ub4 tailchk                                @8188    
    
    

4. 使用bbed模拟数据块损坏

  1. 备份数据库
    RMAN> backup database format '/tmp/db_%U.dbf';
    
    
  2. 编辑bbed参数文件
    [oracle@dbserver1 ~]$ vim bbed.par
    password=blockedit
    blocksize=8192
    listfile=/home/oracle/bbed/fileunix.log
    mode=edit
    
    fileunix.log文件内容,可以用以下sql生成:
    
    SQL> select file#||' '||name||' '||bytes from v$datafile;
    
    1 /u01/app/oracle/oradata/ocmdb/system01.dbf 1073741824
    2 /u01/app/oracle/oradata/ocmdb/sysaux01.dbf 340787200
    3 /u01/app/oracle/oradata/ocmdb/undotbs01.dbf 209715200
    4 /u01/app/oracle/oradata/ocmdb/users01.dbf 524288000
    5 /u01/app/oracle/oradata/ocmdb/apps01.dbf 524288000
    
  3. 损坏数据块
    [oracle@dbserver1 bbed]$ bbed parfile=bbed.par 
    
    BBED: Release 2.0.0.0.0 - Limited Production on Mon Dec 3 16:09:26 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    ************* !!! For Oracle Internal Use only !!! ***************
    
    BBED> info
     File#  Name                                                        Size(blks)
     -----  ----                                                        ----------
         1  /u01/app/oracle/oradata/ocmdb/system01.dbf                      131072
         2  /u01/app/oracle/oradata/ocmdb/sysaux01.dbf                       41600
         3  /u01/app/oracle/oradata/ocmdb/undotbs01.dbf                      25600
         4  /u01/app/oracle/oradata/ocmdb/users01.dbf                        64000
         5  /u01/app/oracle/oradata/ocmdb/apps01.dbf                         64000
    
    BBED> set file 4
    	FILE#          	4
    
    BBED> modify 1000 file 4 block 384
     File: /u01/app/oracle/oradata/ocmdb/users01.dbf (4)
     Block: 384              Offsets:    0 to  511           Dba:0x01000180
    ------------------------------------------------------------------------
     03e80000 80010001 4f3d0900 00000104 19840000 00000000 00000000 00000000 
     00000000 53000000 ff2f0000 20100000 52000000 0d020000 00040000 0d2f0001 
     00000000 52000000 03000000 0c2e0000 00000000 00000000 00000000 53000000 
     00000000 7c420000 00000040 81010001 07000000 88010001 08000000 90010001 
     08000000 98010001 08000000 a0010001 08000000 a8010001 08000000 b0010001 
     08000000 b8010001 08000000 c0010001 08000000 c8010001 08000000 d0010001 
     08000000 d8010001 08000000 e0010001 08000000 e8010001 08000000 f0010001 
     08000000 f8010001 08000000 00020001 80000000 00010001 80000000 80020001 
     80000000 00030001 80000000 80030001 80000000 00040001 80000000 80040001 
     80000000 00050001 80000000 80050001 80000000 00060001 80000000 80060001 
     80000000 00070001 80000000 80070001 80000000 00080001 80000000 80080001 
     80000000 00090001 80000000 80090001 80000000 000a0001 80000000 800a0001 
     80000000 000b0001 80000000 800b0001 80000000 000c0001 80000000 800c0001 
     80000000 000d0001 80000000 800d0001 80000000 000e0001 80000000 800e0001 
     80000000 000f0001 80000000 800f0001 80000000 00100001 80000000 80100001 
     80000000 00110001 80000000 80110001 80000000 00120001 80000000 80120001 
    
     <32 bytes per line>
    
    
    BBED> verify
    DBVERIFY - Verification starting
    FILE = /u01/app/oracle/oradata/ocmdb/users01.dbf
    BLOCK = 384
    
    Block 384 is corrupt
    Corrupt block relative dba: 0x01000180 (file 0, block 384)
    Bad header found during verification
    Data in bad block:
     type: 3 format: 0 rdba: 0x01000180
     last change scn: 0x0000.00093d4f seq: 0x1 flg: 0x04
     spare1: 0x0 spare2: 0x0 spare3: 0x0
     consistency value in tail: 0x3d4f1001
     check value in block header: 0x8419
     computed block checksum: 0x4a13
    
    
    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
    
    
  4. dbv工具验证
    [oracle@dbserver1 bbed]$  dbv file=/u01/app/oracle/oradata/ocmdb/users01.dbf blocksize=8192
    
    DBVERIFY: Release 11.2.0.1.0 - Production on Mon Dec 3 17:04:28 2018
    
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    
    DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/ocmdb/users01.dbf
    Page 384 is marked corrupt
    Corrupt block relative dba: 0x01000180 (file 4, block 384)
    Bad header found during dbv: 
    Data in bad block:
     type: 3 format: 0 rdba: 0x01000180
     last change scn: 0x0000.00093d4f seq: 0x1 flg: 0x04
     spare1: 0x0 spare2: 0x0 spare3: 0x0
     consistency value in tail: 0x3d4f1001
     check value in block header: 0x8419
     computed block checksum: 0x4a13
    
    
    
    DBVERIFY - Verification complete
    
    Total Pages Examined         : 64000
    Total Pages Processed (Data) : 11915
    Total Pages Failing   (Data) : 0
    Total Pages Processed (Index): 0
    Total Pages Failing   (Index): 0
    Total Pages Processed (Other): 128
    Total Pages Processed (Seg)  : 0
    Total Pages Failing   (Seg)  : 0
    Total Pages Empty            : 51956
    Total Pages Marked Corrupt   : 1
    Total Pages Influx           : 0
    Total Pages Encrypted        : 0
    Highest block SCN            : 605955 (0.605955)
    
    
  5. 查询测试
    SQL> alter system flush buffer_cache;
    
    System altered.
    
    SQL> select count(*) from wanbin.t2;
    select count(*) from wanbin.t2
                                *
    ERROR at line 1:
    ORA-01578: ORACLE data block corrupted (file # 4, block # 384)
    ORA-01110: data file 4: '/u01/app/oracle/oradata/ocmdb/users01.dbf'
    
    
  6. 告警日志显示
    ALTER SYSTEM: Flushing buffer cache
    Hex dump of (file 4, block 384) in trace file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/trace/ocmdb_ora_17882.trc
    Corrupt block relative dba: 0x01000180 (file 4, block 384)
    Bad header found during buffer read
    Data in bad block:
     type: 3 format: 0 rdba: 0x01000180
     last change scn: 0x0000.00093d4f seq: 0x1 flg: 0x04
     spare1: 0x0 spare2: 0x0 spare3: 0x0
     consistency value in tail: 0x3d4f1001
     check value in block header: 0x8419
     computed block checksum: 0x4a13
    Reading datafile '/u01/app/oracle/oradata/ocmdb/users01.dbf' for corruption at rdba: 0x01000180 (file 4, block 384)
    Reread (file 4, block 384) found same corrupt data
    Mon Dec 03 17:06:20 2018
    Corrupt Block Found
             TSN = 4, TSNAME = USERS
             RFN = 4, BLK = 384, RDBA = 16777600
             OBJN = 17020, OBJD = 17020, OBJECT = T2, SUBOBJECT = 
             SEGMENT OWNER = WANBIN, SEGMENT TYPE = Table Segment
    Errors in file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/trace/ocmdb_ora_17882.trc  (incident=9865):
    ORA-01578: ORACLE data block corrupted (file # 4, block # 384)
    ORA-01110: data file 4: '/u01/app/oracle/oradata/ocmdb/users01.dbf'
    Incident details in: /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/incident/incdir_9865/ocmdb_ora_17882_i9865.trc
    Mon Dec 03 17:06:23 2018
    Errors in file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/trace/ocmdb_ora_17882.trc  (incident=9866):
    ORA-01578: ORACLE data block corrupted (file # 4, block # 384)
    ORA-01110: data file 4: '/u01/app/oracle/oradata/ocmdb/users01.dbf'
    Incident details in: /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/incident/incdir_9866/ocmdb_ora_17882_i9866.trc
    Mon Dec 03 17:06:23 2018
    Sweep [inc][9865]: completed
    Hex dump of (file 4, block 384) in trace file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/incident/incdir_9865/ocmdb_m000_17896_i9865_a.trc
    Corrupt block relative dba: 0x01000180 (file 4, block 384)
    Bad header found during validation
    Data in bad block:
     type: 3 format: 0 rdba: 0x01000180
     last change scn: 0x0000.00093d4f seq: 0x1 flg: 0x04
     spare1: 0x0 spare2: 0x0 spare3: 0x0
     consistency value in tail: 0x3d4f1001
     check value in block header: 0x8419
     computed block checksum: 0x4a13
    Reread of blocknum=384, file=/u01/app/oracle/oradata/ocmdb/users01.dbf. found same corrupt data
    Reread of blocknum=384, file=/u01/app/oracle/oradata/ocmdb/users01.dbf. found same corrupt data
    Reread of blocknum=384, file=/u01/app/oracle/oradata/ocmdb/users01.dbf. found same corrupt data
    Reread of blocknum=384, file=/u01/app/oracle/oradata/ocmdb/users01.dbf. found same corrupt data
    Reread of blocknum=384, file=/u01/app/oracle/oradata/ocmdb/users01.dbf. found same corrupt data
    Hex dump of (file 4, block 384) in trace file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/incident/incdir_9865/ocmdb_m000_17896_i9865_a.trc
    Corrupt block relative dba: 0x01000180 (file 4, block 384)
    Bad header found during buffer read
    Data in bad block:
     type: 3 format: 0 rdba: 0x01000180
     last change scn: 0x0000.00093d4f seq: 0x1 flg: 0x04
     spare1: 0x0 spare2: 0x0 spare3: 0x0
     consistency value in tail: 0x3d4f1001
     check value in block header: 0x8419
     computed block checksum: 0x4a13
    Reading datafile '/u01/app/oracle/oradata/ocmdb/users01.dbf' for corruption at rdba: 0x01000180 (file 4, block 384)
    Reread (file 4, block 384) found same corrupt data
    Corrupt Block Found
             TSN = 4, TSNAME = USERS
             RFN = 4, BLK = 384, RDBA = 16777600
             OBJN = -1, OBJD = 17020, OBJECT = USERS, SUBOBJECT = 
             SEGMENT OWNER = , SEGMENT TYPE = Temporary Segment
    Errors in file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/trace/ocmdb_m000_17896.trc  (incident=9809):
    ORA-01578: ORACLE data block corrupted (file # 4, block # 384)
    ORA-01110: data file 4: '/u01/app/oracle/oradata/ocmdb/users01.dbf'
    Incident details in: /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/incident/incdir_9809/ocmdb_m000_17896_i9809.trc
    Mon Dec 03 17:06:24 2018
    Trace dumping is performing id=[cdmp_20181203170624]
    Mon Dec 03 17:06:25 2018
    Sweep [inc][9866]: completed
    Sweep [inc][9809]: completed
    Sweep [inc2][9866]: completed
    Sweep [inc2][9865]: completed
    Checker run found 1 new persistent data failures
    Trace dumping is performing id=[cdmp_20181203170626]
    Mon Dec 03 17:07:24 2018
    Sweep [inc2][9809]: completed
    
    

5. 修复坏块

  1. 利用rman 检测坏块
    RMAN> BACKUP CHECK LOGICAL VALIDATE DATAFILE 4;
    
    Starting backup at 03-DEC-18
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=20 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=00004 name=/u01/app/oracle/oradata/ocmdb/users01.dbf
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
    List of Datafiles
    =================
    File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
    ---- ------ -------------- ------------ --------------- ----------
    4    FAILED 0              51956        64000           605955    
      File Name: /u01/app/oracle/oradata/ocmdb/users01.dbf
      Block Type Blocks Failing Blocks Processed
      ---------- -------------- ----------------
      Data       0              11915           
      Index      0              0               
      Other      1              129             
    
    validate found one or more corrupt blocks
    See trace file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/trace/ocmdb_ora_18045.trc for details
    Finished backup at 03-DEC-18
    
    SQL> select * from v$database_block_corruption where file#=4;
    
         FILE#     BLOCK#	  BLOCKS CORRUPTION_CHANGE# CORRUPTIO
    ---------- ---------- ---------- ------------------ ---------
    	 4	  384	       1		  0 CORRUPT
    
    
  2. dump块号,查找块号所属的数据库对象
    SQL> alter system dump datafile 4 block 384;   
    
    [oracle@dbserver1 trace]$ more ocmdb_ora_18184.trc
    
    Trace file /u01/app/oracle/diag/rdbms/ocmdb/ocmdb/trace/ocmdb_ora_18184.trc
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
    System name:	Linux
    Node name:	dbserver1
    Release:	2.6.32-200.13.1.el5uek
    Version:	#1 SMP Wed Jul 27 21:02:33 EDT 2011
    Machine:	x86_64
    Instance name: ocmdb
    Redo thread mounted by this instance: 1
    Oracle process number: 26
    Unix process pid: 18184, image: oracle@dbserver1 (TNS V1-V3)
    
    
    *** 2018-12-03 17:23:12.661
    *** SESSION ID:(20.98) 2018-12-03 17:23:12.661
    *** CLIENT ID:() 2018-12-03 17:23:12.661
    *** SERVICE NAME:(SYS$USERS) 2018-12-03 17:23:12.661
    *** MODULE NAME:(sqlplus@dbserver1 (TNS V1-V3)) 2018-12-03 17:23:12.661
    *** ACTION NAME:() 2018-12-03 17:23:12.661
     
    Start dump data blocks tsn: 4 file#:4 minblk 384 maxblk 384
    Block dump from cache:
    Dump of buffer cache at level 4 for tsn=4, rdba=16777600
    BH (0x9bf85538) file#: 4 rdba: 0x01000180 (4/384) class: 4 ba: 0x9b34e000
      set: 6 pool 3 bsz: 8192 bsi: 0 sflg: 2 pwc: 77,28
      dbwrid: 0 obj: 17020 objn: -1 tsn: 4 afn: 4 hint: f
      hash: [0x9bfcafc8,0xbff4e700] lru: [0x9bf85750,0xbd260578]
      ckptq: [NULL] fileq: [NULL] objq: [NULL]
      st: CR md: NULL tch: 0
      cr: [scn: 0x0.94ddd],[xid: 0x0.0.0],[uba: 0x0.0.0],[cls: 0x0.94ddd],[sfl: 0x0],[lc: 0x0.0]
      flags:
      cr pin refcnt: 0 sh pin refcnt: 0
    ...
    
    
    根据dump文件,可以知道损坏的块所属的对象编号为17020,根据对象号,我们来查找对象类型
    
    SQL> select owner,object_name,object_type from dba_objects o where o.object_id='17020';
    
    OWNER			       OBJECT_NAME		      OBJECT_TYPE
    ------------------------------ ------------------------------ -------------------
    WANBIN			       T2			      TABLE
    
    
  3. 有备份情况下的恢复:
    RMAN> blockrecover datafile 4 block 384 from backupset;
    或者使用
    RMAN> recover corruption list;
    
    
    Starting recover at 03-DEC-18
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=87 device type=DISK
    
    channel ORA_DISK_1: restoring block(s)
    channel ORA_DISK_1: specifying block(s) to restore from backup set
    restoring blocks of datafile 00004
    channel ORA_DISK_1: reading from backup piece /tmp/db_04tjrtom_1_1.dbf
    channel ORA_DISK_1: piece handle=/tmp/db_04tjrtom_1_1.dbf tag=TAG20181203T155814
    channel ORA_DISK_1: restored block(s) from backup piece 1
    channel ORA_DISK_1: block restore complete, elapsed time: 00:00:03
    
    starting media recovery
    media recovery complete, elapsed time: 00:00:03
    
    Finished recover at 03-DEC-18
    
    RMAN> validate datafile 4 block 384;
    
    Starting validate at 03-DEC-18
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting validation of datafile
    channel ORA_DISK_1: specifying datafile(s) for validation
    input datafile file number=00004 name=/u01/app/oracle/oradata/ocmdb/users01.dbf
    channel ORA_DISK_1: validation complete, elapsed time: 00:00:01
    List of Datafiles
    =================
    File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
    ---- ------ -------------- ------------ --------------- ----------
    4    OK     0              0            1               605519    
      File Name: /u01/app/oracle/oradata/ocmdb/users01.dbf
      Block Type Blocks Failing Blocks Processed
      ---------- -------------- ----------------
      Data       0              0               
      Index      0              0               
      Other      0              1               
    
    Finished validate at 03-DEC-18
    
    SQL> select count(*) from wanbin.t2;
    
      COUNT(*)
    ----------
        865664
    
    
  4. 没有备份情况下的恢复(跳过坏块)
    SQL> exec dbms_repair.skip_corrupt_blocks('WANBIN','T2');
    
    或者设置事件( alter system set events '10231 trace name context forever,level 10'
    exp,imp导出导入表数据)
    
    SQL> select skip_corrupt from user_tables where table_name='T2';
     
    SKIP_COR
    --------
    ENABLED
    
    

你可能感兴趣的:(故障解决)