使用rman备份做Data Guard

联系:手机/微信(+86 17813235971) QQ(107644445)

标题:使用rman备份做Data Guard

作者:惜分飞©版权所有[未经本人同意,不得以任何形式转载,否则有进一步追究法律责任的权利.]

前两天公司的一套oracle dg因为维护人员的疏忽到值出现gap,无法恢复,只能重做,因为该库每天都有rman的增量备份,所以选择最近的一次全部进行重做dg
1、主库
ALTER DATABASE CREATE STANDBY CONTROLFILE AS ‘/tmp/control01.ctl’;
alter system archive log current;
2、修改pfile文件(因为我是重做,所以不需要做)
11g data guard(PHYSICAL STANDBY)配置
3、拷贝控制文件/rman文件到备库的相同位置
备份全备的内容(/opt/ORBS/data /tmp/control01.ctl)
4、复制数据库做dg
启动到nomount状态
rman target sys/srtsysdb@zjch_Action auxiliary /
duplicate target database for standby dorecover nofilenamecheck;
出现以下错误
RMAN-06025: no backup of log thread 1 seq 675 lowscn 1096519 found to restore
RMAN-06025: no backup of log thread 1 seq 674 lowscn 1095666 found to restore
RMAN-06025: no backup of log thread 1 seq 673 lowscn 1095663 found to restore
RMAN-06025: no backup of log thread 1 seq 672 lowscn 1095656 found to restore
RMAN-06025: no backup of log thread 1 seq 671 lowscn 1095081 found to restore
RMAN-06025: no backup of log thread 1 seq 670 lowscn 1092545 found to restore
RMAN-06025: no backup of log thread 1 seq 669 lowscn 1090351 found to restore
RMAN-06025: no backup of log thread 1 seq 668 lowscn 1088837 found to restore
RMAN-06025: no backup of log thread 1 seq 667 lowscn 1088834 found to restore
RMAN-06025: no backup of log thread 1 seq 666 lowscn 1088721 found to restore
原因:因为控制文件和备份文件中有时间间隔,所以rman要恢复,但是归档日志没有传输过来,所以不能恢复。
–到主库的归档目录查看这些日志是否存在
ls -l(如果存在,下面的操作恢复日志的操作可以忽略)
–查看这些日志是否存在
list backup of archivelog from sequence 666 until sequence 675;
–如果存在rman备份中,使用rman进行恢复
restore archivelog from sequence 666 until sequence 675;
如果存在相关联机日志就不需要添加
–添加redo log
alter database add logfile group 1 (‘/opt/oracle/oradata/zjch/redo01.log’) size 50m;
alter database add logfile group 2 (‘/opt/oracle/oradata/zjch/redo02.log’) size 50m;
alter database add logfile group 3 (‘/opt/oracle/oradata/zjch/redo03.log’) size 50m;
–添加sandby log
ALTER DATABASE ADD STANDBY LOGFILE (‘/opt/oracle/oradata/zjch/std_redo04.log’) SIZE 50M reuse;
ALTER DATABASE ADD STANDBY LOGFILE (‘/opt/oracle/oradata/zjch/std_redo05.log’) SIZE 50M reuse;
ALTER DATABASE ADD STANDBY LOGFILE (‘/opt/oracle/oradata/zjch/std_redo06.log’) SIZE 50M reuse;
ALTER DATABASE ADD STANDBY LOGFILE (‘/opt/oracle/oradata/zjch/std_redo07.log’) SIZE 50M reuse;
5、开启日志应用
–开启实时应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
–开启应用(根据配置和需求)
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
到这一步会如果主机端有所需的归档日志,会自动传输过来,并进行恢复,不用人工干预。
–查看alter文件,查询日志传输是否正常
–查看日志是否传输完成
select thread#, low_sequence#, high_sequence# from v$archive_gap;
–主库切换日志
alter system switch logfile;
–查询最大sequence
select max(sequence#) from v$archived_log;
–备库查看alert文件
tail -100 alert.log
Media Recovery Log /opt/oracle/oradata/zjch/archive/stdarch/1_46544_681145105.dbf
Media Recovery Log /opt/oracle/oradata/zjch/archive/stdarch/1_46545_681145105.dbf 有类似内容
–查询最大sequence
select max(sequence#) from v$archived_log;
–主库建立一个测试表
create table SCOTT.t_test(id number,name varchar2(10));
insert into SCOTT.t_test values(1,’aaaa’);
commit;
alter system switch logfile;
–查询最大sequence
select max(sequence#) from v$archived_log;
–备库检查
–查询最大sequence
select max(sequence#) from v$archived_log;
–取消日志应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
–只读模式打开数据库
alter database open read only;
–查询刚刚建的表和插入数据是否通报不成功
select * from SCOTT.t_test;
–重启备库,设置为日志应用模式
shutdown immediate;
startup mount;
–开启实时应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
–开启应用(根据配置和需求)
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
–主库删除测试表
drop table SCOTT.t_test;

One thought on “使用rman备份做Data Guard

  1. 请问如果第三步中,主库和备库中的位置不一样该怎么做呢?

发表评论

邮箱地址不会被公开。 必填项已用*标注

2 × 3 =