如果数据库开启了闪回功能,可以通过闪回数据库功能快速恢复DG环境。不过利用闪回数据库技术进行DG恢复会有部分数据丢失风风险!(亲测)
模拟故障之前先对主备库开启闪回功能,环境为oracle19c 单实例DG数据库启动到mount状态执行:alter database flashback on;alter database open;---(主备库)。
然后 正式模拟:
1、主库
shutdown abort
2、备库检查状态
select name,open_mode,database_role,switchover_status from v$database;
3、备库关闭日志应用
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
4、备库切换成新主库
ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
5、查询数据库新主库状态
select name,open_mode,database_role,switchover_status from v$database;
6、打开新主库并查询scn号
alter database open;
SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) std_scn FROM V$DATABASE;
7、原主库(新备库)启动到mount恢复到新主库查询到的scn节点
startup mount
flashback database to scn 3112752;
8、原主库切换成新备库并启动到mount
alter database convert to physical standby;
shutdown immediate
startup mount
9、新备库开启日志应用
alter database recover managed standby database using current logfile disconnect from session;
10、查询新主库发现有GAP
select thread#, low_sequence#, high_sequence# from v$archive_gap;
select name,open_mode,database_role,switchover_status from v$database;
11、新主库启动到mount把日志刷入新备库
startup mount
alter system flush redo to dg1;
12、打开新主库
alter database open;
select name,open_mode,database_role,switchover_status from v$database;
over 分享结束~