Oracle通过SCN做增量备份修复DG

本文介绍了一种基于系统更改号(SCN)的Oracle数据库Guard(DG)恢复方法,通过查询主库和备库SCN信息,进行增量备份,传输文件,恢复控制文件和数据库,实现快速同步和异常恢复。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  DG由于网络原因或者bug原因经常不同步,有时隔得时间久了,就会丢失归档日志,或者长时间的归档恢复较慢,有一种可以基于scn的方式来恢复DG库,使用基于scn的增量备份来恢复standby库可以节省大量时间,或者进行dg异常的重新同步。

  1,查询主库和备库的scn,redo号等信息,选取合适的scn号进行主库的备份

--查询DG端最低的scn,以下查询结果应该相同
 select to_char(current_scn) scn from v$database;
 select min(fhscn) from x$kcvfh;

 select distinct to_char(checkpoint_change#) from v$datafile_header order by 1; 

--以归档日志查询相关scn
 select THREAD#,min(sequence#) from v$archived_log where applied='NO' group by THREAD#;  
 select THREAD#,max(sequence#) from v$archived_log where applied='NO' group by THREAD#; 

 SELECT thread#,SEQUENCE#,to_char(FIRST_CHANGE#) fc,to_char(NEXT_CHANGE#) nc FROM v$archived_log WHERE SEQUENCE# = 32995 ORDER BY 1,2; 

  2,主库端基于scn的增量备份

RMAN> BACKUP INCREMENTAL FROM SCN <SCN from previous step> 
DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY'
--or
  backup device type disk incremental from scn 11125946510 database format'/home/oracle/db_incre%U.bbk'; 
--or
run {
allocate channel t1 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t2 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t3 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t4 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t5 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t6 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t7 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
allocate channel t8 type 'sbt_tape' parms 'ENV=(NB_ORA_CLIENT=bossb1)';
backup incremental from scn 12844051683640 database format 'forstandby_%u' tag 'forstandby';
backup current controlfile for standby format 'forstandbyctrl.bck' tag 'forstandby_cnt'; 
  release channel t1;
  release channel t2;
  release channel t3;
  release channel t4;
  release channel t5;
  release channel t6;
  release channel t7;
  release channel t8;
}

 ALTER DATABASE CREATE standby controlfile AS '/home/oracle/standby.ctl';  

  3,传输文件到dg端,rman catalog start with

  4,恢复控制文件,恢复数据库

RMAN>restore controlfile from'/data/oracle/backup/restore/standby.ctl';    
--mount database
RMAN> RECOVER DATABASE NOREDO;

  5,启动同步进程,检查同步状态等。

转载于:https://www.cnblogs.com/ocp-100/p/10711726.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值