Reinstate Failed Primary Database using Flashback:-
Methods to Reinstate database using Flashback:-
1) Using DGMGRL
2) Using SQL*PLUS
1) Using DGMGRL:-
- Startup the Failed Primary Database in the Mount stage:
SQL> startup mount
- Issue the following command while connected to any database in the broker configuration, except the database that is to be reinstated:
DGMGRL> REINSTATE DATABASE PROD_DGP;
If the REINSTATE DATABASE fails to start the Failed Primary Database, then manually start the database in mount stage and reissue the reinstate command.
- Using SQL*PLUS:-
Step 1 Determine the Standby Became Primary SCN.
Step 2 Flashback the Failed Primary Database.
Step 3 Convert to physical standby database.
Step 4 Restart Redo Transport.
Step 5 Start Redo Apply.
Step 1) Determine the SCN at which the old standby database became the primary database:-
SQL> SELECT TO_CHAR(STANDBY_BECAME_PRIMARY_SCN) FROM V$DATABASE;
Step 2) Flashback the Failed Primary Database to SCN standby_became_primary_scn:-
SQL> SHUTDOWN IMMEDIATE;
SQL> startup mount
SQL> FLASHBACK DATABASE TO SCN <standby_became_primary_scn of step 1>;
Step 3) Convert the database to a physical standby database and Restart database in mount stage:-
SQL> ALTER DATABASE CONVERT TO PHYSICAL STANDBY;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
Step 4 Restart Redo Transport to the New Physical Standby Database:-
- If you have not set the remote archive destination on current primary then set remote archive destination:
SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_2 = ‘SERVICE=<service_name_of_failed_primary_database> VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=<db_unique_name>’ SCOPE=BOTH;
- Enable the destination
SQL>ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;
- Perform a log switch to ensure that standby database begins receiving redo data from the new primary database
SQL> ALTER SYSTEM SWITCH LOGFILE;
SQL> SELECT DEST_ID, STATUS, ERROR FROM V$ARCHIVE_DEST WHERE DEST_ID=2;
Step 5 Start Redo Apply.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;