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.

Oracle database 8i to 12c R1 upgrade

This blog post provides the overall approach to upgrade from Oracle 8i (specifically 8.1.7.4) to Oracle 12c R1 (specifically 12.1.0.2)

Is your current version 8.1.7.4 (8i R3) ?

If so, this is the approach. You have to perform two upgrades. The first one is called an intermediate upgrade.

We recommend you to use dbua tool (database upgrade assistant GUI tool) instead of export and import tools.

1) Oracle 8.1.7.4 (8i R3) to Oracle 10.2.0.5

Do you have access to Oracle support https://support.oracle.com ?

If so, request them to provide you Oracle 10.2.0.1 software (base edition) through a service request.  Install this 10.2.0.1 base software - Then download 8202632 which is the patch number for patchset 10.2.0.5 and apply to the 10.2.0.1 installed folder to bring it up to 10.2.0.5


Now do a direct upgrade from Oracle 8.1.7.4 to 10.2.0.5

https://docs.oracle.com/cd/B19306_01/server.102/b14238.pdf 


2) In a separate path, install Oracle 12.1.0.2

Then upgrade the 10.2.0.5 upgraded database to Oracle 12.1.0.2.

https://docs.oracle.com/database/121/UPGRD/E41397-13.pdf