Planned Switchover

An Oracle database operates in one of two roles: primary or standby. Data Guard helps you change the role of a database using either a switchover or a failover:

  • A switchover is a role reversal between the primary database and one of its standby databases. A switchover guarantees no data loss and is typically done for planned maintenance of the primary system. During a switchover, the primary database transitions to a standby role, and the standby database transitions to the primary role.
  • A failover is done when the primary database (all instances of an Oracle RAC primary database) fails or has become unreachable and one of the standby databases is transitioned to take over the primary role. Failover may or may not result in data loss depending on the protection mode in effect at the time of the failover.

Switch the Primary Database From On-Premises to OCI

When you have a planned activity, such as maintenance, you can make the database in Oracle Cloud Infrastructure (OCI) the primary database with zero data loss. A switchover is a planned event that's initiated on the on-premises database and completed on the database instance in the cloud.

  1. Log into a DGMGRL session on the on-premises database with a sys user name and password.
    DGMRGL> connect
  2. On the on-premises database, validate that the standby database is ready for switchover and failover.
    In this example, the primary database is db1 and the standby database (StandbyDatabaseOCIInstance) is DB1_phx3g7.
    DGMGRL> validate database DB1_phx3g7
    The output will look similar to the following:
    Database Role:     Physical standby database
      Primary Database:  db1
    
      Ready for Switchover:  Yes
      Ready for Failover:    Yes (Primary Running)
    
      Managed by Clusterware:
        db1       :  YES             
        db1_phx3g7:  YES   
              
    Standby Apply-Related Information:
        Apply State:      Running
        Apply Lag:        17 minutes 6 seconds (computed 42 seconds ago)
        Apply Delay:      0 minutes
      Current Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status       
                  (db1)                   (db1_phx3g7)                         
        1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1_phx3g7
        2         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 2 on db1_phx3g7
      Future Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status       
                  (db1_phx3g7)            (db1)                                
        1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1
        2         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 2 on db1
  3. Validate the primary database.
    DGMGRL> validate database 'DB1';
    The output will look similar to the following:
    Database Role:    Primary database
      Ready for Switchover:  Yes
      Managed by Clusterware:
        db1:  YES    
  4. Validate the standby database.
    DGMGRL> validate database 'DB1_phx3g7';
    The output will look similar to the following:
    
    Database Role:     Physical standby database  
    Primary Database:  db1  
    Ready for Switchover:  Yes  
    Ready for Failover:    Yes (Primary Running)  
    Managed by Clusterware:
        db1       :  YES                
        db1_phx3g7:  YES              
    Standby Apply-Related Information:
        Apply State:      Running
        Apply Lag:        32 minutes 12 seconds (computed 40 seconds ago)
        Apply Delay:      0 minutes  
    Current Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status
                  (db1)                   (db1_phx3g7)
         1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1_phx3g7
        2         2                       0                       Insufficient SRLs     
        Warning: standby redo logs not configured for thread 2 on db1_phx3g7
    
    Future Log File Groups Configuration:
        Thread #  Online Redo Log Groups  Standby Redo Log Groups Status       
                  (db1_phx3g7)            (db1)                                
        1         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 1 on db1
        2         2                       0                       Insufficient SRLs
        Warning: standby redo logs not configured for thread 2 on db1
  5. On the on-premises (primary) database, execute the command to switchover to the standby database.
    DGMGRL> switchover to db1_phx3g7;
    The output will look similar to the following:
    Performing switchover NOW, please wait...
    Operation requires a connection to database "db1_phx3g7"
    Connecting ...
    Connected to "DB1_phx3g7"
    Connected as SYSDBA.
    New primary database "db1_phx3g7" is opening...
    Oracle Clusterware is restarting database "db1" ...
    Connected to "db1"
    Connected to "db1"
    Switchover succeeded, new primary is "db1_phx3g7"
  6. On the on-premises database, display the configuration status.
    DGMGRL> show configuration
    The output will look similar to the following:
    Configuration - onpremexadr
    
      Protection Mode: MaxPerformance
      Members:
      db1_phx3g7 - Primary database
          db1        - Physical standby database 
    
    Warning: ORA-16809: multiple warnings detected for the memberFast-Start
            Failover:  Disabled
    Configuration Status:
    WARNING   (status updated 35 seconds ago)
  7. On the primary on-premises Oracle Exadata Database Machine, select open mode.
    SQL> select open_mode from v$database;
    The output will look similar to the following:
    OPEN_MODE
    -------------------- 
    MOUNTED
  8. On the Oracle Database Exadata Cloud Service database in the cloud, confirm that the database is READ WRITE.
    SQL> select open_mode from v$database;
    The output will look similar to the following:
    OPEN_MODE
    -------------------- 
    READ WRITE
The database on Oracle Database Exadata Cloud Service in the cloud is the primary database.

Switch the Primary Database Back From OCI to On-Premises

After making the database instance in Oracle Cloud Infrastructure (OCI) the primary database, use the Oracle Data Guard command-line interface (DGMGRL) on the OCI database instance inOracle Database Exadata Cloud Service to switch back and make your on-premises database your primary database again.

  1. Switchover from the database instance in OCI to the on-premises database.
    DGMGRL> switchover to db1;
    The output will look similar to the following:
    Performing switchover NOW, please wait...
    Operation requires a connection to database "db1"
    New primary database "db1" is opening...
    Oracle Clusterware is restarting database "db1_phx3g7" ...
    Connected to "DB1_phx3g7"
    Connected to "DB1_phx3g7"
    Switchover succeeded, new primary is "db1"
  2. On the on-premises Oracle Exadata Database Machine, connect and review the configuration.
    DGMGRL> show configuration;
    The output will look similar to the following:
    Configuration - onpremexadr
    
      Protection Mode: MaxPerformance
      Members:
      db1        - Primary database
      Warning: ORA-16809: multiple warnings detected for the member
        db1_phx3g7 - Physical standby database 
          Error: ORA-12650: No common encryption or data integrity algorithm
    Fast-Start Failover:  Disabled
    Configuration Status:
    ERROR   (status updated 899 seconds ago)
  3. On the Oracle Database Exadata Cloud Service database in the cloud, create a test disaster recovery table.
    SQL> create table testdr (a number , b number);
    Table created.
    SQL> desc testdr;
     Name                                        Null?    Type
     ----------------------------------------- -------- ----------------------------
     A                                          NUMBER
     B                                          NUMBER
  4. Exit SQL.
    SQL> exit
  5. On the primary on-premises Oracle Exadata Database Machine, log in as sysdba and view the testdr table.
    $ sqlplus / as sysdba
    SQL> desc testdr;
    
     Name                                        Null?    Type
     ----------------------------------------- -------- ----------------------------
     A                                          NUMBER
     B                                          NUMBER
  6. On the primary on-premises Oracle Exadata Database Machine, display and review the configuration.
    DGMGRL> show configuration;
    The output will look similar to the following:
    Configuration - onpremexadr
    
      Protection Mode: MaxPerformance
      Members:
    db1        - Primary database
        db1_phx3g7 - Physical standby database 
          Warning: ORA-16809: multiple warnings detected for the member
    Fast-Start Failover:  Disabled
    Configuration Status:
    WARNING   (status updated 36 seconds ago)

You can switch the primary database back and forth between the on-premises database and the Oracle Database Exadata Cloud Service (OCI) database instance.