-
目前情况,DG正常
-
模拟事件发生
2.1 停止备库的recover
SYS@stddb> alter database recover managed standby database cancel;
2.2 主库,做操作,切换日志
SYS@prod> conn hr/hr
Connected.
HR@prod> update e set salary=salary+1;
107 rows updated.
HR@prod> commit;
Commit complete.
HR@prod> conn / as sysdba
Connected.
SYS@prod> alter system switch logfile;
System altered.
重复上述行为,多切换几次
2.3 查看主库的日志状态
SYS@prod> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/arch/pridb
Oldest online log sequence 129
Next log sequence to archive 131
Current log sequence 131
2.4 查看备库日志状态
SYS@stddb> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/arch/stddb
Oldest online log sequence 129
Next log sequence to archive 0
Current log sequence 131
SYS@stddb> select sequence#,applied from v$archived_log where applied=‘NO’;
SEQUENCE# APPLIED
123 NO
124 NO
125 NO
126 NO
127 NO
128 NO
129 NO
130 NO
8 rows selected.
2.5 删除主库的127号归档日志
[oracle@vm01 pridb]$ rm -f 1_127_1018101739.dbf
RMAN> crosscheck archivelog all;
RMAN> delete expired archivelog all;
2.6 删除备库的127号归档日志
[oracle@vm02 stddb]$ rm -f 1_127_1018101739.dbf
RMAN> crosscheck archivelog all;
RMAN> delete expired archivelog all;
- 启动备库的recover动作
SYS@stddb> alter database recover managed standby database disconnect;
SYS@stddb> select process,status,sequence# from v$managed_standby;
PROCESS STATUS SEQUENCE#
ARCH CLOSING 129
ARCH CLOSING 130
ARCH CONNECTED 0
ARCH CLOSING 128
RFS IDLE 0
RFS IDLE 0
RFS IDLE 131
RFS IDLE 0
MRP0 WAIT_FOR_GAP 127
9 rows selected.
- 备库停止recover
SYS@stddb> alter database recover managed standby database cancel;
- 查看主库的对应断档log的scn信息
SYS@prod> select sequence#,first_change# from v$archived_log where sequence#=127;
SEQUENCE# FIRST_CHANGE#
127 1550291
127 1550291
- 在主库从1550291开始,进行增量备份
RMAN> backup incremental from scn 1550291 database format ‘/home/oracle/backup/lost_arc_%U’;
- 将增量备份传输到备库
[oracle@vm01 backup]$ scp lost_arc_0* 172.16.0.247:/home/oracle/backup
- 备库重新启动到mount
SYS@stddb> shutdown abort;
SYS@stddb> startup mount;
- 恢复增量备份
[oracle@vm02 stddb]$ rman target /
RMAN> catalog backuppiece ‘/home/oracle/backup/lost_arc_0eubn2v0_1_1’;
RMAN> catalog backuppiece ‘/home/oracle/backup/lost_arc_0fubn2vg_1_1’;
RMAN> recover database noredo;
- 主库重新生成一个控制文件传输给备库
SYS@prod> alter database create standby controlfile as ‘/home/oracle/backup/std_con01.ctl’;
[oracle@vm01 backup]$ scp std_con01.ctl 172.16.0.247:/home/oracle/backup
- 备库重新恢复控制文件
RMAN> shutdown immediate;
RMAN> startup nomount;
RMAN> restore controlfile from ‘/home/oracle/backup/std_con01.ctl’;
RMAN> shutdown immediate;
Oracle instance shut down
RMAN> startup;
- 重新启动adg
SYS@stddb> alter database recover managed standby database cancel;
SYS@stddb> alter database recover managed standby database using current logfile disconnect;
SYS@stddb> select name,open_mode from v$database;
NAME OPEN_MODE
PROD READ ONLY WITH APPLY