Unplanned Failovers

A failover is an unplanned event that assumes the primary database is lost. The standby database is converted to a primary database immediately after all available redo data from the primary is applied.

Recover From an Unplanned Failover

A failover is an unplanned event or outage, which might include data loss. After a failover, the original primary database must be reinstated as a physical standby. Reinstating the original primary database is easier when you have flashback database and Oracle Data Guard Broker.

In this example, ORCLCDB is the name of the on-premises database and orclcdb_iad1s3 is the name of the database instance in the cloud. Step 3 in this example shuts down the primary on-premises database to imitate an unplanned outage.
  1. Log into a DGMGRL session on the on-premises primary database as the sys user and password.
    DGMRGL> connect
  2. Display the configuration for the on-premises database.
    DGMGRL> show configuration;
    The output should look similar to the following:
    Configuration - onpremdr
    
      Protection Mode: MaxPerformance
      Members:
      orclcdb        - Primary database
        orclcdb_iad1s3 - Physical standby database 
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    SUCCESS(status updated 32 seconds ago)
  3. Connect to the primary database instance and perform a shutdown to imitate an unplanned outage.
    bash-4.2$ sqlplus / as sysdba
    SQL> shutdown abort;
    The output should look similar to the following:
    ORACLE instance shut down.
  4. Display the configuration for the standby database instance in Oracle Cloud Infrastructure (OCI).
    DGMGRL> show configuration;
    The output should look similar to the following:
    Configuration - onpremdr
      Protection Mode: MaxPerformance
      Members:
      orclcdb        - Primary database
        Error: ORA-1034: ORACLE not available
    
        orclcdb_iad1s3 - Physical standby database 
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    ERROR   (status updated 0 seconds ago)
  5. Initiate the failover.
    DGMGRL> > failover to ORCLCDB_iad1s3;
    The output should look similar to the following:
    Performing failover NOW, please wait...
    Failover succeeded, new primary is "orclcdb_iad1s3"
  6. Display the configuration for the database instance in Oracle Cloud Infrastructure (OCI).
    DGMGRL> show configuration;
    The output should look similar to the following:
    Configuration - onpremdr
    
      Protection Mode: MaxPerformance
      Members:
      orclcdb_iad1s3 - Primary database
        orclcdb        - Physical standby database (disabled)
          ORA-16661: the standby database needs to be reinstated
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    SUCCESS   (status updated 48 seconds ago)
  7. Reinstate the original on-premises primary database (ORCLCDB in this example).
    A reinstate makes the old, deactivated primary the standby database, allowing it to receive redo data from the new primary (the activated standby database).

    If you want to bring the original primary database, as the primary database instance (which was failover), then execute the startup mount on one instance of the original primary before reinstating.

    SQL> startup mount;
  8. On the database instance in the cloud (orclcdb_iad1s3 in this example), use the reinstate database command to reinstate the original on-premises primary database.
    DGMGRL> reinstate database ORCLCDB;
    The output should look similar to the following:
    Reinstating database
            "orclcdb", please wait...Reinstatement of database
            "orclcdb" succeeded
  9. Display the configuration for the standby database instance in Oracle Cloud Infrastructure (OCI).
    DGMGRL> show configuration;
    The output should look similar to the following:
    Configuration - onpremdr
    
      Protection Mode: MaxPerformance
      Members:
      orclcdb_iad1s3 - Primary database
        orclcdb        - Physical standby database 
    
    Fast-Start Failover:  Disabled
    
    Configuration Status:
    SUCCESS   (status updated 47 seconds ago