Performing an Oracle Data Guard switchover - Amazon Relational Database Service

Performing an Oracle Data Guard switchover

In an Oracle Data Guard environment, a primary database supports one or more standby databases. You can perform a managed, switchover-based role transition from a primary database to a standby database.

Overview of Oracle Data Guard switchover

A switchover is a role reversal between a primary database and a standby database. During a switchover, the original primary database transitions to a standby role, while the original standby database transitions to the primary role.


            Switch over a standby instance to make it the primary instance

Amazon RDS supports a fully managed, switchover-based role transition for Oracle Database replicas. The replicas can reside in separate AWS Regions or in different Availability Zones (AZs) of a single Region. You can only initiate a switchover to a standby database that is mounted or open read-only.

Benefits of Oracle Data Guard switchover

Just as for RDS for Oracle read replicas, a managed switchover relies on Oracle Data Guard. The operation is designed to have zero data loss. Amazon RDS automates the following aspects of the switchover:

  • Reverses the roles of your primary database and specified standby database, putting the new standby database in the same state (mounted or read-only) as the original standby

  • Ensures data consistency

  • Maintains your replication configuration after the transition

  • Supports repeated reversals, allowing your new standby database to return to its original primary role

Supported Oracle Database versions

Oracle Data Guard switchover is supported for the following releases:

  • Oracle Database 19c

  • Oracle Database 12c Release 2 (12.2)

  • Oracle Database 12c Release 1 (12.1) using PSU 12.1.0.2.v10 or higher

AWS Region support

Oracle Data Guard switchover is available in the following AWS Regions:

  • Asia Pacific (Mumbai)

  • Asia Pacific (Osaka)

  • Asia Pacific (Seoul)

  • Asia Pacific (Singapore)

  • Asia Pacific (Sydney)

  • Asia Pacific (Tokyo)

  • Canada (Central)

  • Europe (Frankfurt)

  • Europe (Ireland)

  • Europe (London)

  • Europe (Paris)

  • Europe (Stockholm)

  • South America (São Paulo)

  • US East (N. Virginia)

  • US East (Ohio)

  • US West (N. California)

  • US West (Oregon)

Cost of Oracle Data Guard switchover

The Oracle Data Guard switchover feature doesn't incur additional costs. You need an Oracle Data Guard license to use read replicas in mounted mode, and an Oracle Active Data Guard license to use read replicas in read-only mode.

How Oracle Data Guard switchover works

Oracle Data Guard switchover is a fully managed operation. You initiate the switchover for a standby database by issuing the CLI command switchover-read-replica. Then Amazon RDS modifies the primary and standby roles in your replication configuration.

The original standby and original primary are the roles that exist before the switchover. The new standby and new primary are the roles that exist after the switchover. A bystander replica is a replica database that serves as a standby database in the Oracle Data Guard environment but is not switching roles.

Stages of the Oracle Data Guard switchover

To perform the switchover, Amazon RDS must take the following steps:

  1. Block new transactions on the original primary database. During the switchover, Amazon RDS interrupts replication for all databases in your Oracle Data Guard configuration. During the switchover, the original primary database can't process write requests.

  2. Ship unapplied transactions to the original standby database, and apply them.

  3. Restart the new standby database in read-only or mounted mode. The mode depends on the open state of the original standby database before the switchover.

  4. Open the new primary database in read/write mode.

After the Oracle Data Guard switchover

Amazon RDS switches the roles of the primary and standby database. You are responsible for reconnecting your application and performing any other desired configuration.

Success criteria

The Oracle Data Guard switchover is successful when the original standby database does the following:

  • Transitions to its role as new primary database

  • Completes its reconfiguration

To limit downtime, your new primary database becomes active as soon as possible. Because Amazon RDS configures bystander replicas asynchronously, these replicas might become active after the original primary database.

Connection to the new primary database

Amazon RDS won't propagate your current database connections to the new primary database after the switchover. After the Oracle Data Guard switchover completes, reconnect your application to the new primary database.

Configuration of the new primary database

To perform a switchover to the new primary database, Amazon RDS changes the mode of the original standby database to open. The change in role is the only change to the database. Amazon RDS doesn't set up features such as Multi-AZ replication.

If you perform a switchover to a cross-Region replica with different options, the new primary database keeps its own options. Amazon RDS won't migrate the options on the original primary database. If the original primary database had options such as SSL, NNE, OEM, and OEM_AGENT, Amazon RDS doesn't propagate them to the new primary database.

Preparing for the Oracle Data Guard switchover

Before initiating the Oracle Data Guard switchover, make sure that your replication environment meets the following requirements:

  • The original standby database is mounted or open read-only.

  • Automatic backups are enabled on the original standby database.

  • The original primary database and the original standby database are in an available state.

  • The original primary database and the original standby database have no pending maintenance actions.

  • The original standby database is in the replicating state.

  • You aren't attempting to initiate a switchover when either the primary database or standby database is currently in a switchover lifecycle. If a replica database is reconfiguring after a switchover, Amazon RDS prevents you from initiating another switchover.

    Note

    A bystander replica is a replica in the Oracle Data Guard configuration that isn't the target of the switchover. Bystander replicas can be in any state during the switchover.

  • The original standby database has a configuration that is as close as desired to the original primary database. Assume a scenario where the original primary and original standby databases have different options. After the switchover completes, Amazon RDS doesn't automatically reconfigure the new primary database to have the same options as the original primary database.

  • You configure your desired Multi-AZ deployment before initiating a switchover. Amazon RDS doesn't manage Multi-AZ as part of the switchover. The Multi-AZ deployment remains as it is.

    Assume that db_maz is the primary database in a Multi-AZ deployment, and db_saz is a Single-AZ replica. You initiate a switchover from db_maz to db_saz. Afterward, db_maz is a Multi-AZ replica database, and db_saz is a Single-AZ primary database. The new primary database is now unprotected by a Multi-AZ deployment.

  • In preparation for a cross-Region switchover, the primary database doesn't use the same option group as a DB instance outside of the replication configuration. For a cross-Region switchover to succeed, the current primary database and its read replicas must be the only DB instances to use the option group of the current primary database. Otherwise, Amazon RDS prevents the switchover.

Initiating the Oracle Data Guard switchover

You can switch over an RDS for Oracle read replica to the primary role, and the former primary DB instance to a replica role.

To switch over an Oracle read replica to the primary DB role

  1. Sign in to the AWS Management Console and open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the Amazon RDS console, choose Databases.

    The Databases pane appears. Each read replica shows Replica in the Role column.

  3. Choose the read replica that you want to switch over to the primary role.

  4. For Actions, choose Switch over replica.

  5. Choose I acknowledge. Then choose Switch over replica.

  6. On the Databases page, monitor the progress of the switchover.

    
                            Monitor the progress of the Oracle Data Guard switchover

    When the switchover completes, the role of the switchover target changes from Replica to Primary.

To switch over an Oracle replica to the primary DB role, use the AWS CLI switchover-read-replica command. The following examples make the Oracle replica named replica-to-be-made-primary into the new primary database.

Example

For Linux, macOS, or Unix:

aws rds switchover-read-replica \ --db-instance-identifier replica-to-be-made-primary

For Windows:

aws rds switchover-read-replica ^ --db-instance-identifier replica-to-be-made-primary

To switch over an Oracle replica to the primary DB role, call the Amazon RDS API SwitchoverReadReplica operation with the required parameter DBInstanceIdentifier. This parameter specifies the name of the Oracle replica that you want to assume the primary DB role.

Monitoring the Oracle Data Guard switchover

To check the status of your instances, use the AWS CLI command describe-db-instances. The following command checks the status of the DB instance orcl2. This database was a standby database before the switchover, but is the new primary database after the switchover.

aws rds describe-db-instances \ --db-instance-identifier orcl2

To confirm that the switchover completed successfully, query V$DATABASE.OPEN_MODE. Check that the value for the new primary database is READ WRITE.

SELECT OPEN_MODE FROM V$DATABASE;

To look for switchover-related events, use the AWS CLI command describe-events. The following example looks for events on the orcl2 instance.

aws rds describe-events \ --source-identifier orcl2 \ --source-type db-instance