rman备份发现坏块之后的处理

RMAN> backup datafile 28;

启动 backup 于 28-11月-04
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在启动 full 数据文件备份集
通道 ORA_DISK_1: 正在指定备份集中的数据文件
输入数据文件 fno=00028 name=E:ORACLEORADATAORABD02TS_TEST01.DBF
通道 ORA_DISK_1: 正在启动段 1 于 28-11月-04
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/28/2004 15:45:
51
ORA-19566: 超出损坏块限制 0 (文件 E:ORACLEORADATAORABD02TS_TEST01.DBF)

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
扫描数据库的物理错误和逻辑错误
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
RMAN> backup validate  datafile 28;

启动 backup 于 28-11月-04
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在启动 full 数据文件备份集
通道 ORA_DISK_1: 正在指定备份集中的数据文件
输入数据文件 fno=00028 name=E:ORACLEORADATAORABD02TS_TEST01.DBF
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:00:01
完成 backup 于 28-11月-04

注意:在rman validate操作期间会生成一些文本,看起来像是创建了一个备份集

但只是一个扫描错误的操作,在rman操作期间不会生成任何备份文件片

RMAN>

SQL> select * from V$BACKUP_CORRUPTION;

     RECID      STAMP  SET_STAMP  SET_COUNT     PIECE#      FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# MARKED
---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------
         1  543426383  543426382         31          1         28         20          1                  0 YES    FRACTURED

已用时间:  00: 00: 00.00
SQL> select * from v$database_block_corruption;

     FILE#     BLOCK#     BLOCKS CORRUPTION_CHANGE# CORRUPTION_TYPE
---------- ---------- ---------- ------------------ ------------------
        28         20          1                  0 FRACTURED

已用时间:  00: 00: 00.00
SQL>

 

先看一下坏块是在表上还是索引上吧。


SELECT segment_name,segment_type,extent_id,block_id, blocks
from dba_extents t
where file_id = 6
AND 187 between block_id and (block_id + blocks - 1) ;


运气好,在索引上的话,直接重建就好了

例如:

我的数据库出现ORA-01578错误:数据块损坏(文件号8,块号36385)

用以下语句查询:
    
 SELECT segment_name,segment_type FROM dba_extents  WHERE file_id=8 AND 36385 BETWEEN block_id AND block_id + blocks -1;

结果为:
segment_name     segment_type
-----------------------     ------------------------
  PK_KC03                    INDEX


有的文章介绍说如果segment_type为INDEX的话,只要删除该索引再重建即可

使用:

alter index pk_kc03 rebuild nologging;
or
alter index pk_kc03 rebuild



 dbms_repair.skip_corrupt_blocks过程设置表在读取数据时,跳过坏块

————————-——————————————————————————————————

 

 

 


四月 16 16:30:19 ur_bak01: NetWorker savegroup: (alert) urmdborafull completed, total 2 client(s), 0 Hostname(s) Unresolved, 1 Failed, 1 Succeeded. (ur_mdb01 Failed)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on t2 channel at 03/20/2009 13:49:09
ORA-19566: exceeded limit of 0 corrupt blocks for file /dev/vg_mdb02/rdata_2g_050
ORA-000060: Deadlock detected. More info in file /oracle/app/oracle/admin/uradt/udump/uradt_ora_3035.trc.
***
Corrupt block relative dba: 0x1a43d4e3 (file 105, block 251107)
Fractured block found during backing up datafile
Data in bad block -
 type: 0 format: 0 rdba: 0x00000000
 last change scn: 0x0000.00000000 seq: 0x0 flg: 0x00
 consistency value in tail: 0x00000000
 check value in block header: 0x0, block checksum disabled
 spare1: 0x0, spare2: 0x0, spare3: 0x0
***
Reread of blocknum=251107, file=/dev/vg_mdb02/rdata_2g_050. found same corrupt data
Thu Apr 16 16:31:04 2009

 

 



用dbv检查发现有至少有45个坏块:

 

[oracle@ur_mdb01 /oracle$]dbv file=/dev/vg_mdb02/rdata_2g_050 BLOCKSIZE=8192
 
DBVERIFY: Release 9.2.0.6.0 - Production on Mon Apr 20 09:55:07 2009
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
DBVERIFY - Verification starting : FILE = /dev/vg_mdb02/rdata_2g_050
Page 251107 is influx - most likely media corrupt
***
Corrupt block relative dba: 0x1a43d4e3 (file 105, block 251107)
Fractured block found during dbv:
Data in bad block -
 type: 0 format: 0 rdba: 0x00000000
 last change scn: 0x0000.00000000 seq: 0x0 flg: 0x00
 consistency value in tail: 0x00000000
 check value in block header: 0x0, block checksum disabled
 spare1: 0x0, spare2: 0x0, spare3: 0x0
***
 
Page 251108 is marked corrupt
***
Corrupt block relative dba: 0x1a43d4e4 (file 105, block 251108)
Bad header found during dbv:
Data in bad block -
 type: 181 format: 6 rdba: 0x00000000
 last change scn: 0x0000.00000000 seq: 0x0 flg: 0x00
 consistency value in tail: 0x00000000
 check value in block header: 0x0, block checksum disabled
 spare1: 0x7, spare2: 0xc, spare3: 0x0
***
 
……
 
Corrupt block relative dba: 0x1a43d56f (file 105, block 251247)
Bad header found during dbv:
Data in bad block -
 type: 65 format: 5 rdba: 0x527002c2
 last change scn: 0x3131.02063033 seq: 0x30 flg: 0x31
 consistency value in tail: 0x3635032d
 check value in block header: 0x180, block checksum disabled
 spare1: 0x50, spare2: 0x72, spare3: 0x430
***
 
 
 
DBVERIFY - Verification complete
 
Total Pages Examined         : 262016
Total Pages Processed (Data) : 60240
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 568
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 201163
Total Pages Marked Corrupt   : 45
Total Pages Influx           : 11
Highest block SCN            : 10816042273 (2.2226107681)

 

 


经检查,发现这些坏块上没有任何数据对象:

方法1.可以找到这个数据文件所在的表空间,这个表空间下的所有对象:如果都是表,可以对这些表都做一次全部扫描,发现没有报错。如果都是索引,可以都走一次iff,没有报错的话,说明对象都不在坏块上。


方法2.用

select * from dba_extents where file_id=坏块file_id

and 坏块block_id between block_id and block_id+blocks-1;

如果所有的坏块执行这个sql检查出来的结果都是返回0行,说明没有对象在坏块上。

 


我们用格式化的方式来清除这样的坏块:

--预估剩余空间大小:


SQL> select tablespace_name,file_id,sum(bytes)/1024/1024 size_m from dba_free_space
  2  where file_id=105 group by tablespace_name,file_id;
 
TABLESPACE_NAME                   FILE_ID     SIZE_M
------------------------------ ---------- ----------
LOG_P8                                105       1643
 
SQL> 
 


 
--创建一个表在这个表空间上,用于做数据块的格式化:


SQL> create table for_fix(n number,c varchar2(4000)) nologging tablespace LOG_P8;
 
Table created.
 
SQL>
SQL>
SQL>
 
--填充满这个表:
SQL> alter table for_fix allocate extent(datafile '/dev/vg_mdb02/rdata_2g_050' size 1643m);
 
Table altered.
 
SQL>
SQL> insert into for_fix select rownum,rpad('dedwedew',3900) from dba_objects;
 
7285 rows created.
 
SQL> /
 
7285 rows created.
 
SQL> /
 
……
 
SQL>  insert into for_fix select * from for_fix where rownum<=1000000;
 
1000000 rows created.
 
Elapsed: 00:00:06.96
SQL> /
 
1000000 rows created.
 
Elapsed: 00:00:03.50
SQL> /
 
10000 rows created.
 
Elapsed: 00:00:14.03
……
 
SQL> insert into for_fix select * from for_fix where rownum<=50000;
 
50000 rows created.
 
Elapsed: 00:00:39.28
SQL>
SQL>
 
……
 
SQL> insert into for_fix select * from for_fix where rownum<=1;
 
1 row created.
 
Elapsed: 00:00:00.00
SQL> /
 
1 row created.
 
Elapsed: 00:00:00.00
SQL> /
 
1 row created.
 
Elapsed: 00:00:00.00
SQL> /
 
1 row created.
 
Elapsed: 00:00:00.00
SQL> /
 
1 row created.
 
Elapsed: 00:00:00.01
SQL> /
insert into for_fix select * from for_fix where rownum<=1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.FOR_FIX by 128 in tablespace LOG_P8
 
 
Elapsed: 00:00:00.00
SQL>
SQL>
SQL> commit;
 
Commit complete.
 
Elapsed: 00:00:00.07
SQL>
SQL>
 
--记住,这里一定要做checkpoint,将所有的数据刷新到数据文件,不然不能保证所有的坏块被格式化:


SQL> alter system checkpoint;
 
System altered.
 
Elapsed: 00:00:04.25
SQL> /
 
System altered.
 
Elapsed: 00:00:00.15
SQL> /
 
System altered.
 
Elapsed: 00:00:00.14


填充满这个表后,所以的块都被得到格式化,包括坏块也被格式化了。此时我们用dbv再次检查:

 

[oracle@ur_mdb01 /oracle$]

dbv file=/dev/vg_mdb02/rdata_2g_050 BLOCKSIZE=8192
 
DBVERIFY: Release 9.2.0.6.0 - Production on Mon Apr 20 13:30:43 2009
 
Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
 
DBVERIFY - Verification starting : FILE = /dev/vg_mdb02/rdata_2g_050
 
 
DBVERIFY - Verification complete
 
Total Pages Examined         : 262016
Total Pages Processed (Data) : 260715
Total Pages Failing   (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing   (Index): 0
Total Pages Processed (Other): 1181
Total Pages Processed (Seg)  : 0
Total Pages Failing   (Seg)  : 0
Total Pages Empty            : 120
Total Pages Marked Corrupt   : 0
Total Pages Influx           : 0
Highest block SCN            : 10816271785 (2.2226337193)
[oracle@ur_mdb01 /oracle$]


坏块已经处理掉了,测试rman备份正常。

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13165828/viewspace-611511/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/13165828/viewspace-611511/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值