Friday, March 27, 2020

Oracle Data Guard - How to rebuild PRIMARY after a Failover

If the primary database is not available for a long duration or suffered a permanent failure, then we have to consider a failover (not switchover) to the standby database to make it as the new primary database. Later, we also have to rebuild the old primary database and make it the new standby database.

Assumptions : 

a) The FLASHBACK database feature is turned on.
b) Oracle database version is Oracle 12c R1 (12.1.0.2)

Note: The last full backup on primary server must be successful and available. This will help in having at least a traditional backup/restore alternative in case the failover to the standby database is not successful.

Failover

Run the below steps on the standby server 

a) alter database recover managed standby database cancel; (Must return "Database altered" message quickly.)
b) alter database recover managed standby database finish; (Must return "Database altered" message quickly.)
c) alter database activate standby database; (Must return "Database altered" message quickly.)

At this stage, the database role must be turned as PRIMARY

d) shutdown immediate;
e) startup;

f) select to_char(standby_became_primary_scn) from v$database;  (NOTE THIS SCN value)

Now, it is strongly recommended to take a full database backup.


Rebuild OLD primary database

Run the below steps on the old primary server (which had a permanent problem that made you to do the failover in the first place).


1) shutdown immediate; (If it is already in running status)
2) startup mount;
3) flashback database to SCN nnnnn (Replace nnnnn with the actual SCN value noted in #f above)

4)  alter database convert to physical standby;
5) alter database recover managed standby database disconnect from session; (This will start the managed recovery process - MRP0 in the background)

6) select database_role from v$database; (Must show PHYSICAL STANDBY)

7) select switchover_status from v$database; It can show either "SWITCHOVER PENDING" or "NOT ALLOWED". Both are valid values.

No comments:

Related Posts Plugin for WordPress, Blogger...