Prerequisite:
1.Dataguard of primary database is down due to power failure or other disaster
2.Primary can be flashbacked on(alter database flashback on; need restart instance)
two parameters are related to flashback:
DB_RECOVERY_FILE_DEST(db_recovery_file_dest_size) and db_flashback_retention_target(default value:1440 minute)
(1)Failover:
standby side
1.stop redo apply
alter database recover managed standby database cancel;
2.finish applying all received redo data:
alter database recover managed standby database finish force;
select database_role from v$database;
3.switchover standby to primary
alter database commit to switchover to primary with session shutdown;
4.open new primary database
alter database open
5.get the scn from new primary where old primary failed over
select to_char(standby_became_primary_scn) from v$database;
TO_CHAR(STANDBY_BECAME_PRIMARY_SCN)
----------------------------------------
7490727
(2)flashback old primary database
1.mount old primary database
startup mount;
2.flashback to the scn where it failed over
flashback database to scn 7490727;
3.switch old primary database to standby
alter database convert to physical standby;
4.restart new standby database
shutdown immediate
startup
5.start redo apply
alter database recover managed standby database disconnect from session;
6.check primary status and test new dataguard
select OPEN_MODE,DATABASE_ROLE,SWITCHOVER_STATUS from v$database;
OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS
-------------------- ---------------- --------------------
READ ONLY WITH APPLY PHYSICAL STANDBY SWITCHOVER PENDING