Oracle基于备库最小SCN增量备份修复DG

在Oracle数据库日常运维中往往会碰到这种情况:DataGuard主库归档删了,备库由于缺少归档从而GAP报错,此时经常的做法是重新拉数据,如果数据量小还好,数据量TB级别了在加之网络带宽有限,这明显不是一个很好的解决方案,本文分享基于备库的最小SCN在主库做增量备份的方法修复DG。

  1. 备库查询最小SCN
SQL> select min(f.fhscn) from x$kcvfh f, v$datafile d where f.hxfil =d.file# and d.enabled != 'READ ONLY';

MIN(F.FHSCN)
----------------
16471785731987

这里的16471785731987就是备库的最小SCN。
2. 在主库基于最小SCN做增量备份

[oracle@ray01 shrman]$ vi shrman20200623.sh 

source /home/oracle/.bash_profile
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
rman target / log /shrman/shrman/shrman20200623.log <<EOF
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
allocate channel c5 type disk;
backup as compressed backupset INCREMENTAL FROM SCN 16471785731987 database format "/shrman/shrman/incre_%d_%T_%s";
release channel c1;
release channel c2;
release channel c3;
release channel c4;
release channel c5;
}

[oracle@ray01 shrman]$ nohup ./shrman20200623.sh &
  1. 将备份集从主库传输至备库
    由于本文中我采用的是NFS挂在,直接就备份在远端了,小伙伴们可以使用FTP、SCP等方式将备份集传输至备库上。
  2. 备库注册备份集
[oracle@raydg shrman]$ rman target /
RMAN> catalog start with '/backup/rman';
  1. 恢复备份集
RMAN> recover database noredo;
  1. 重新同步控制standby controlfile
[oracle@ray01 shrman]$ sqlplus / as sysdba
SQL> alter database create standby controlfile as '/shrman/shrman/dg.ctl';
  1. 传输standby controlfile至备库
  2. 重启数据库
  3. 开启MRP
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值