包含以下三部分内容,都可以实现物理备库临时读写以及再恢复为physical standby:
-
flashback database闪回physical standby
-
activate standby database
-
snapshot standby
1. 在physical standby闪回恢复主库误操作数据
只要Flashback dest空间跟归档在,可以任意闪回。
1.1 查询当前primary SCN
SYS@honor1 > select to_char(current_scn) from v$database; TO_CHAR(CURRENT_SCN) ---------------------------------------- 17031266
1.2 primary创建测试表
HR@honor1 > create table test_flashback parallel as select * from user_objects; HR@honor1 > insert into test_flashback parallel select * from user_objects; HR@honor1 > commit;
1.3 备库查询测试表,闪回到创建该表前
SYS@honordg > desc hr.test_flashback; # 检查,备库已经同步该表 SYS@honordg > alter database recover managed standby database cancel; SYS@honordg > shutdown immediate; SYS@honordg > startup mount; SYS@honordg > flashback database to scn 17031266; Flashback complete. 21:03:11 SYS@honordg > alter database open read only; Database altered. HR@honordg > desc test_flashback; # 可以看到已经闪回到创建该表前。 ERROR: ORA-04043: object test_flashback does not exist
1.4 恢复physical standby
# 检查备库当前状态
SYS@honordg > select GUARD_STATUS,OPEN_MODE,STANDBY_BECAME_PRIMARY_SCN,SWITCHOVER_STATUS,DATABASE_ROLE from v$database; GUARD_S OPEN_MODE STANDBY_BECAME_PRIMARY_SCN SWITCHOVER_STATUS DATABASE_ROLE ------- -------------------- ---------------------------------------- -------------------- ---------------- NONE READ ONLY 0 NOT ALLOWED PHYSICAL STANDBY SYS@honordg > select to_char(current_scn) from v$database; TO_CHAR(CURRENT_SCN) ---------------------------------------- 17031266
# 直接开启恢复,备库即可利用归档
SYS@honordg > alter database recover managed standby database disconnect from session; Database altered.
1.5 通过alert详解闪回以及恢复physical standby过程
(1)可以看到physical standby已经恢复sequence 914日志
Archived Log entry 39 added for thread 1 sequence 914 rlc 984508005 ID 0x150ac660 dest 2: RFS[2]: No standby redo logfiles created RFS[2]: Opened log for thread 1 sequence 915 dbid 353046371 branch 984508005 Tue Jun 09 20:30:02 2020 Media Recovery Log +DGFRA/honordg/archivelog/2020_06_09/thread_1_seq_914.493.1042661953 RFS[1]: Opened log for thread 1 sequence 915 dbid 353046371 branch 984508005 RFS[2]: Assigned to RFS process 14109 RFS[2]: No standby redo logfiles created Archived Log entry 40 added for thread 1 sequen