ORA-19566 maxcorrupt参数详解

ORA-19566 maxcorrupt参数详解

问题现象

RMAN> backup datafile 5 format ‘/home/oracle/zhuo.bak’;

Starting backup at 02-NOV-20
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 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=00005 name=/u01/app/oracle/oradata/ZHUO/datafile/o1_mf_zhuo_gxdcfr5s_.dbf
channel ORA_DISK_1: starting piece 1 at 02-NOV-20
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/02/2020 11:27:35
ORA-19566: exceeded limit of 0 corrupt blocks for file /u01/app/oracle/oradata/ZHUO/datafile/o1_mf_zhuo_gxdcfr5s_.dbf

有时候,当datafile上面有坏块的时候,备份就会产生报错。
此时,解决的方法有2种:1、修好此坏块;2、备份时设置参数。
坏块的修复参考另一篇文章,此处讨论此参数

参数解释

maxcorrupt:允许坏块的数量(默认为0),可以对数据文件进行备份。

concept:Sets a limit on the number of previously undetected block corruptions that the database permits in a specified data file or group of data files. The default limit is zero, meaning that RMAN tolerates no corrupt blocks.
The SET MAXCORRUPT command specifies the total number of physical and logical corruptions permitted in a data file during a backup job. If the sum of physical and logical corruptions detected for a data file is no more than its MAXCORRUPT setting, then the BACKUP command completes. If more than MAXCORRUPT corrupt blocks exist, then RMAN terminates without creating output files.

Whether or not the MAXCORRUPT limit is exceeded, RMAN populates the V$DATABASE_BLOCK_CORRUPTION view with any corrupt block ranges that it finds. However, a backup or restore job is terminated after MAXCORRUPT+1 corrupt blocks are found, so in this case RMAN only records MAXCORRUPT+1 corruptions. Any block corruptions beyond the point at which the backup job terminated are not recorded.

Note: If you specify CHECK LOGICAL, then the MAXCORRUPT limit applies to the sum of logical and physical corruptions detected. Otherwise, MAXCORRUPT only applies to the number of physical block corruptions.

语法:
1

实验验证

  1. 设置maxcorrupt参数进行备份

在执行RUN脚本时指定maxcorrupt即可

RMAN> run{ 
2> set maxcorrupt for datafile 5 to 1;
3> backup datafile 5 format '/home/oracle/zhuo.bak';
4> }

executing command: SET MAX CORRUPT

Starting backup at 02-NOV-20
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/ZHUO/datafile/o1_mf_zhuo_gxdcfr5s_.dbf
channel ORA_DISK_1: starting piece 1 at 02-NOV-20
channel ORA_DISK_1: finished piece 1 at 02-NOV-20
piece handle=/home/oracle/zhuo.bak tag=TAG20201102T113134 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-NOV-20

备份成功。
[oracle@oracle11g ~]$ dbv file=zhuo.bak
。。。。。。。
DBVERIFY - Verification complete

Total Pages Examined : 1307
Total Pages Processed (Data) : 0
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 1
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 0
Total Pages Marked Corrupt : 1306
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 764631 (0.764631)
不知道为啥。这里的坏块这么多。但是可以验证的是,此时的备份文件中已经包含坏块了。

  1. 用含有坏块的备份集恢复数据库

可以在测试下恢复的情况。
session 1:

[oracle@oracle11g ~]$ cd /u01/app/oracle/oradata/ZHUO/datafile/
[oracle@oracle11g datafile]$ rm -rf o1_mf_zhuo_gxdcfr5s_.dbf 

session 2:

RMAN> restore datafile 5;

Starting restore at 02-NOV-20
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ZHUO/datafile/o1_mf_zhuo_gxdcfr5s_.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/zhuo.bak
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 11/02/2020 15:54:01
ORA-19870: error while restoring backup piece /home/oracle/zhuo.bak
ORA-19573: cannot obtain exclusive enqueue for datafile 5

session 3:

SQL> alter database datafile 5 offline;

Database altered.

session 2:

RMAN> restore datafile 5;

Starting restore at 02-NOV-20
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/ZHUO/datafile/o1_mf_zhuo_gxdcfr5s_.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/zhuo.bak
channel ORA_DISK_1: piece handle=/home/oracle/zhuo.bak tag=TAG20201102T155032
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
Finished restore at 02-NOV-20

RMAN> recover datafile 5;

Starting recover at 02-NOV-20
using channel ORA_DISK_1

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

Finished recover at 02-NOV-20

session 3:

SQL> alter database datafile 5 online;

Database altered.

session 1:
[oracle@oracle11g datafile]$ dbv file=o1_mf_zhuo_hszgslxh_.dbf

DBVERIFY: Release 11.2.0.4.0 - Production on Mon Nov 2 15:55:18 2020

Copyright © 1982, 2011, Oracle and/or its affiliates. All rights reserved.

DBVERIFY - Verification starting : FILE = /u01/app/oracle/oradata/ZHUO/datafile/o1_mf_zhuo_hszgslxh_.dbf

DBV-00200: Block, DBA 20971672, already marked corruptalready表示恢复出来已经标记为坏块了。
csc(0x0000.000ba236) higher than block scn(0x0000.00000000)
Page 152 failed with check code 6054

DBVERIFY - Verification complete

Total Pages Examined : 655360
Total Pages Processed (Data) : 1145
Total Pages Failing (Data) : 1
Total Pages Processed (Index): 0
Total Pages Failing (Index): 0
Total Pages Processed (Other): 654107
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 108
Total Pages Marked Corrupt : 1
Total Pages Influx : 0
Total Pages Encrypted : 0
Highest block SCN : 762479 (0.762479)
当在rman备份的时候,设置maxcorrput参数,oracle会自动标记识别到的坏块。所以备份完成后的备份集里边肯定是含有坏块的。此时,用含有坏块的备份集还原数据库,oracle也会自动的将此块标记为坏块。总之,标记为坏块的块,在备份和还原的时候,就一直会被标记为坏块
3. 再次进行备份

RMAN> backup datafile 5 format '/home/oracle/zhuo1.bak';

Starting backup at 02-NOV-20
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/ZHUO/datafile/o1_mf_zhuo_hszgslxh_.dbf
channel ORA_DISK_1: starting piece 1 at 02-NOV-20
channel ORA_DISK_1: finished piece 1 at 02-NOV-20
piece handle=/home/oracle/zhuo1.bak tag=TAG20201102T160149 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 02-NOV-20

上次备份发现的坏块,rman此时会忽略,就不用再设置参数了。

总结:
RMAN备份时,只要发现了新的坏块,就会立刻停止备份,如果发现的是上次备份时已经发现的坏块,则RMAN会继续备份。 我们可以设置 maxcorrupt 参数来通知RMAN , 发现坏块个数超过指定的数量时才停止备份。
语法:
RMAN > run {
set maxcorrupt for datafile 5,7,8,9 to 10 ;
backup database ;
}
表示当在5,7,8,9号文件中的坏块超过10个时就停止备份,其他文件碰到新坏块就停止备份。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值