Thursday, March 20, 2025

Oracle DGMGRL Swithover & Switchback steps

 To perform a switchover and switchback using Oracle Data Guard with dgmgrl (Data Guard Manager command-line interface), you typically use the following steps. These steps assume you have already configured Oracle Data Guard and are familiar with the concepts of Primary and Standby databases.

1. Switchover from Primary to Standby Database

A switchover is a planned role reversal between the Primary and Standby databases. This process allows the Standby database to become the new Primary and vice versa.

Steps for Switchover:

  1. Log in to Data Guard Manager (DGMGRL): Open a command-line terminal on the Primary database machine and log into the Data Guard Manager using dgmgrl.

    dgmgrl
    
  2. Connect to the Data Guard Configuration: Connect to your Data Guard configuration.

    DGMGRL> connect sys/password@primary
    

    Replace sys/password with the appropriate credentials and the correct TNS name for your primary database.

  3. Check the Data Guard Status: Before proceeding, it's good practice to check the status of the Data Guard configuration.

    DGMGRL> show configuration;
    

    Verify that the configuration is in sync and there are no issues.

  4. Perform the Switchover: Execute the switchover command to initiate the role reversal.

    DGMGRL> switchover to standby;
    

    Replace standby with the correct name of the standby database if needed.

    This command will:

    • Automatically stop Redo Apply on the Standby.
    • Start Redo Apply on the new Primary.
    • Synchronize the new Primary with the old Standby.
    • If necessary, restart the Oracle instances to complete the switchover.

    After the switchover completes, the old Primary will be the new Standby, and the old Standby will be the new Primary.

  5. Verify the Switchover: Check that the switchover was successful by viewing the configuration status.

    DGMGRL> show configuration;
    

    Ensure that the roles have been reversed correctly.


2. Switchback from Standby to Primary Database

Switching back is simply performing a reverse of the original switchover process, where the Primary database becomes the Standby again.

Steps for Switchback:

  1. Log in to Data Guard Manager (DGMGRL): Open a terminal on the current Primary (which was previously the Standby) and log into the Data Guard Manager using dgmgrl.

    dgmgrl
    
  2. Connect to the Data Guard Configuration: Connect to the Data Guard configuration.

    DGMGRL> connect sys/password@primary
    
  3. Check the Data Guard Status: Check the current status to ensure everything is running smoothly.

    DGMGRL> show configuration;
    
  4. Perform the Switchback: Execute the switchover command again, but this time switch back to the original Primary (which is now the Standby).

    DGMGRL> switchover to primary;
    

    This command will:

    • Reverse the roles of the Primary and Standby databases once again.
    • Stop Redo Apply on the current Standby and resume it on the new Standby.
    • Synchronize the databases.
  5. Verify the Switchback: Check the Data Guard configuration to verify the new roles.

    DGMGRL> show configuration;
    

Things to Consider:

  • Synchronization: Ensure that the database logs are synchronized before performing any switchover. You can use the show database verbose command to check the synchronization status.

  • Redundancy and Backup: Always ensure you have current backups of the databases before performing a switchover or switchback, as these operations can potentially cause downtime.

  • Log Archives: If you have the possibility of switching back during the switchover process, verify that all the archive logs have been applied correctly.

  • Data Guard Broker: If you're using Data Guard Broker, these operations can be performed automatically without manual intervention using DGMGRL commands.


By following these steps, you can successfully perform a switchover and switchback operation with Oracle Data Guard using dgmgrl. Always perform these operations during planned maintenance windows to minimize downtime.

For a comprehensive and official reference on performing switchover and switchback operations in Oracle Data Guard using dgmgrl, I recommend checking Oracle's official documentation:

  • Oracle Data Guard Concepts and Administration Guide: This is the most authoritative source for Data Guard operations, including switchover and switchback procedures.

You can find the relevant documentation here: Oracle Data Guard Concepts and Administration

You can specifically refer to the following sections for detailed steps on switchover and switchback:

  • Chapter 5: Switchover and Failover Procedures (for steps on switchover and switchback)
  • Chapter 10: Data Guard Command-Line Interface (DGMGRL) (for DGMGRL command usage)

Oracle Data Guard Broker, 19c