Manual Failover
In a manual failover, you convert a standby database to a primary database because the original primary database failed and there is no possibility of recovering the primary database in a timely manner.
There may or may not be data loss depending upon whether your primary and target standby databases were synchronized at the time of the primary database failure. The word manual is used to contrast this type of failover with a fast-start failover (described in Fast-Start Failover).
Note:
You can perform a manual failover even if fast-start failover is enabled. See Performing Manual Role Changes When Fast-Start Failover Is Enabled for more information.
The following sections describe how to perform manual failovers:
Complete and Immediate Manual Failovers
You can use Cloud Control or DGMGRL, to perform either a complete (recommended) or an immediate failover.
-
A complete failover is the recommended and default failover option. It automatically recovers the maximum amount of redo data for the protection mode the configuration is operating in. A complete failover also attempts to avoid disabling any standby databases that were not the target of the failover, so that they may continue serving as standby databases to the new primary database.
Whether or not standby databases that were not the target of failover (bystander standby databases) are disabled depends upon how much redo data they have applied relative to the failover target and the standby type of the failover target:
-
If the failover target is a physical or snapshot standby database, the original primary database must be reinstated or re-created in order to be a standby database for the new primary database. In addition, some standby databases may be disabled by the broker during the failover if the broker detects that they have applied redo beyond where the new primary database had applied. Any standby database that was disabled by the broker must be reinstated or re-created, as described in Reenabling Disabled Databases After a Role Change, before it can be a standby database for the new primary database.
Note that if failover was performed on a snapshot standby database, the old primary must be either reinstated or re-created as a physical standby database.
-
If the failover target is a logical standby database, the original primary database and all physical and snapshot standby databases in the configuration will be disabled. The primary database can be reinstated if it had flashback database enabled. The physical and snapshot standby databases will have to be re-created from a copy of the new primary database. See Reenabling Disabled Databases After a Role Change for more information.
If the primary database can be mounted, it may be possible to flush any unsent redo data from the primary database to the target standby database using the
ALTER SYSTEM FLUSH REDOSQL statement. If this operation is successful, a zero data loss failover may be possible even if the primary database is not in a zero data loss protection mode. See Oracle Data Guard Concepts and Administration for more information on using theALTER SYSTEM FLUSH REDOstatement.During a complete failover, the broker performs the failover steps described in How the Broker Performs a Complete Failover Operation.
-
-
An immediate failover is the fastest type of failover. However, no additional data is applied on the standby database once you invoke the failover. Another consequence of immediate failover is that all other databases in the configuration are disabled and must be reinstated or re-created before they can serve as standby databases for the new primary database. Reenabling Disabled Databases After a Role Change describes how to do this. During an immediate failover, the broker performs the failover steps described in How the Broker Performs an Immediate Failover Operation.
Note:
Always try to perform a complete failover first unless redo apply has stopped at the failover target due to an
ORA-752orORA-600[3020]error. If one of these errors has occurred, follow the guidelines in "Resolving ORA-752 or ORA-600 [3020] During Standby Recovery" in My Oracle Support Note 1265884.1 before proceeding. This support note is available athttps://support.oracle.com.An immediate failover should only be performed when a complete failover is unsuccessful or in the error cases just noted. A complete failover can occur without any data loss, depending on the destination attributes of redo transport services, but an immediate failover usually results in some data loss.
Performing a Manual Failover Operation
Before beginning a failover, first determine that there is no possibility of recovering the primary database in a timely manner, and ensure that the primary database is shut down.
If the database is managed by Oracle Clusterware, broker does not open any pluggable databases (PDBs) on any of the instances. Instead, when broker notifies the Oracle Clusterware agent that the failover completed, the Oracle Clusterware agent opens PDBs on particular instances based on the service configuration.
The steps in this section describe the tasks involved to perform a manual failover. Depending on the failover and the types of standby databases involved, some of the databases may need to be reinstated or re-created.
Performing a Manual Failover Task 1: Determine Which of the Available Standby Databases is the Best Target for the Failover
These are the guidelines for choosing a target standby database.
Performing a Manual Failover Task 2: Start the Failover
Use Cloud Control or DGMGRL to perform either a complete (recommended) or an immediate failover.
Manual Failover Using Cloud Control:
On the Oracle Data Guard Overview page in Cloud Control, select the standby database that you want to change to the primary role and click Failover. Then, on the Failover Confirmation page, click Yes to invoke the default Complete failover option.
Manual Failover Using DGMGRL:
Connect to the target standby database and issue the FAILOVER command to perform a failover, specifying the name of the standby database that you want to become the primary database:
DGMGRL> FAILOVER TO database-name;
Specify the optional IMMEDIATE clause to perform an immediate failover if any of the following conditions are true:
-
An
ORA-752error has occurred at the standby database -
An
ORA-600[3020]error has occurred at the standby database and Oracle support has determined that it was caused by a lost write at the primary database -
A complete failover is not possible
DGMGRL> FAILOVER TO database-name IMMEDIATE;
See Also:
If you are performing a complete failover, then all accumulated redo data is applied before the database role is changed to primary. If you are performing an immediate failover, then the database role is changed to primary without applying any accumulated redo data.
If the target is a snapshot standby database, the broker first converts the database to a physical standby database.
No instances are shutdown when doing a failover, if the target standby database is either a physical or logical standby. If the target standby database is a snapshot standby database, all of its instances must be restarted to the mount mode before performing failover. Both Cloud Control and the DGMGRL CLI will do this automatically as part of failover.
Performing a Manual Failover Task 3: Reset the Protection Mode
This list describes how the overall Oracle Data Guard protection mode is handled after a manual failover (complete or immediate).
-
If the protection mode was at maximum protection, it is reset to maximum performance. You can upgrade the protection mode later, if necessary, as described in Setting the Protection Mode for Your Configuration.
-
If the protection mode was at maximum availability or maximum performance, it remains unchanged.
Note:
If you perform a manual failover when fast-start failover is enabled:
-
The failover can only be performed to the current target standby database.
-
The broker preserves the protection mode that was in effect prior to the failover, unless the protection mode was max protection. In this case the broker sets the protection mode to maximum availability and will later upgrade the protection mode maximum protection mode when a synchronized physical standby database is available.
Performing a Manual Failover Task 4: Re-establish a Disaster-Recovery Configuration
To maintain a viable disaster-recovery solution in the event of another disaster, you may need to perform additional steps.
-
Reinstate the original primary database to act as a standby database in the new configuration.
Caution:
Do not attempt to reinstate the old primary database if an
ORA-752orORA-600[3020]error has occurred at the failover target. Instead, the old primary database must be re-created as a standby from a backup of the new primary using the procedure described in How to Re-create and Reenable a Disabled Database. -
Reinstate or re-create standby databases in the configuration that were disabled by the broker.
After a complete failover finishes, any bystander standby database that is not viable as a standby for the new primary database will be disabled by the broker. This can happen for either of the following reasons:
-
A bystander standby database has applied more redo data than the new primary database itself had applied when it was a standby database. The standby database must be re-created or reinstated before it can serve as a standby for the new primary database.
-
The failover was to a logical standby database. The broker disables all of the physical and snapshot standby databases in the configuration. They must be re-created from a copy of the new primary database before they can serve as a standby to the new primary database.
-
How the Broker Performs a Complete Failover Operation
These are the actions the broker performs after you start a complete failover.
-
Waits for the target standby database to finish applying any unapplied redo data before stopping Redo Apply (if the target is a physical standby database) or SQL Apply (if the target is a logical standby database).
If the target is a snapshot standby database, the broker first converts the database back to a physical standby and then starts Redo Apply to apply all the accumulated redo before completing the failover and opening the database as a primary database.
-
Transitions the target standby database into the primary database role, as follows:
-
Changes the role of the database from standby to primary.
-
Opens the new primary database in read/write mode.
-
Determines whether or not any standby databases that did not participate in the failover operation have applied redo data beyond the new primary database, and thus need to be disabled.
If a bystander standby database is not disabled by the broker during this failover, it will remain in the state it was in before the failover. For example, if a physical standby database was in the
APPLY-OFFstate, it will remain in theAPPLY-OFFstate.By default, the broker always determines whether bystander standby databases will be viable standby databases for the new primary when performing a complete failover. If you want the broker to skip this viability check of bystander standby databases during a complete failover, thus decreasing the overall failover time, set the
BystandersFollowRoleChangeconfiguration property toNONE.When this property is set to
NONE, the broker will disable all bystander standby databases without checking whether they have applied more redo data than the new primary database. You will have to reinstate or re-create (see Reenabling Disabled Databases After a Role Change) the standby databases after failover has completed. TheSHOW CONFIGURATIONcommand will show you which databases can be reinstated and which databases must be re-created. Use theSHOW CONFIGURATION BystandersFollowRoleChangecommand to see the value of this property. The default value isALL.This property also affects whether the broker skips viability checks of bystander standby databases when a fast-start failover occurs.
-
Starts redo transport services to begin transmitting redo data to all bystander standby databases that were not disabled.
Note:
Bystander standby databases may be disabled by the broker during the failover, and they must be reinstated or re-created before they can serve as standby databases to the new primary database. Oracle recommends configuring Flashback Database on every database so that if failover occurs to a physical standby database, you can more easily reinstate any disabled standby databases. If failover occurs to a logical standby database, all physical and snapshot standby databases will be disabled by the broker. In this case, Flashback Database cannot be used to reinstate databases. They must be re-created from a copy of the new primary database. Logical standby databases that are disabled during failover can be reinstated.
-
-
Directs Oracle Clusterware to restart all instances that may have been shut down prior to the failover if the failover target database is an Oracle RAC physical or snapshot standby database.
The broker allows the failover to proceed as long as there are no errors for the standby database that you selected to participate in the failover. Errors occurring for any other configuration members will not impede the switchover. If you initiated a complete failover and it fails, you might need to use immediate failover.
Complete Failovers in Configurations Using Far Sync Instances
It is possible to manually perform a completer failover to a standby database that receives redo data from a far sync instance. To failover, connect to the standby database and use the DGMGRL FAILOVER TO db-unique-name command. Any unsent redo data residing on the far sync instance is transmitted to the target physical standby prior to converting the physical standby into a primary database.
Complete Failovers in Configurations Using Cascaded Standbys
In a complete failover, it is also possible to failover to a standby database (terminal standby) that gets redo from another standby database (cascader). In such a case, no attempt is made to transmit any unsent redo from the cascader to the terminal standby.
How the Broker Performs an Immediate Failover Operation
To start an immediate failover, use the DGMGRL FAILOVER TO database-name IMMEDIATE command.
Once an immediate failover is started, the broker:
-
Stops Redo Apply or SQL Apply on the standby database immediately, without waiting until all available redo data has been applied. This may result in data loss.
-
Transitions the target standby database into the primary role, opens the new primary database in read/write mode, and starts redo transport services.
After an immediate failover completes, all the standby databases in the configuration, regardless of their type, are disabled. They may be reinstated if Flashback Database is enabled on those databases. Otherwise, they must be re-created from a copy of the new primary database.
The broker allows a complete failover to proceed as long as there are no errors present on the standby database that you selected to participate in the failover.
The broker allows an immediate failover to proceed even if there are errors present on the standby database that you selected to participate in the failover.
Immediate Failovers in Configurations Using Far Sync Instances
It is possible to manually perform an immediate failover to a standby database that receives redo data from a far sync instance. In this case, no attempt is made to transmit any unsent redo from the far sync instance to the target physical standby prior to converting the physical standby into a primary database.
Immediate Failovers in Configurations Using Cascaded Standbys
In an immediate failover, it is also possible to failover to a standby database (terminal standby) that gets redo from another standby database (cascader). In such a case, no attempt is made to transmit any unsent redo from the cascader to the terminal standby.
Reenabling Disabled Databases After a Role Change
To restore your original disaster-recovery solution after switchover to a logical standby database or after failover to any standby database, you may need to perform additional steps.
Databases that have been disabled after a role transition are not removed from the broker configuration, but they are no longer managed by the broker.
To reenable broker management of these databases, you must reinstate or re-create the databases using one of the following procedures:
-
If a database can be reinstated, the database will show the following status:
ORA-16661: The standby database must be reinstated
Reinstate the database using the DGMGRL
REINSTATE DATABASEcommand or the reinstate option in Cloud Control, as described in How to Reinstate a Database. The broker automatically reenables the database as part of reinstating it. -
If a database must be re-created from a copy of the new primary database, it will have the following status:
ORA-16795: The standby database needs to be re-created
Re-create the standby database from a copy of the primary database and then reenable it, as described in How to Re-create and Reenable a Disabled Database.
Note:
Any database that was disabled while multiple role changes were performed cannot be reinstated. You must re-create the database manually from a copy of the current primary database and then reenable the database in the broker configuration.
Whether you reinstate or re-create a database depends on whether you performed a switchover or failover, on the type of standby database that was the target of the operation, and on whether or not there are sufficient flashback logs. Note that role changes to logical standby databases always result in physical standby database bystanders being disabled. They cannot be reinstated. They must be re-created from a copy of the new primary database.
The following sections describe how to reinstate or reenable a database.
How to Reinstate a Database
You can use the broker's reinstate capability to make a failed primary database a viable standby database for the new primary.
This can be done regardless of whether the failover was done to a physical, logical, or snapshot standby database.
You can also reinstate bystander standby databases that were disabled during a failover operation.
If the database is managed by Oracle Clusterware, broker does not open any pluggable databases (PDBs) on any of the instances. Instead, when broker notifies the Oracle Clusterware agent that the failover completed, the Oracle Clusterware agent opens PDBs on particular instances based on the service configuration.
For the REINSTATE command to succeed, Flashback Database must have
been enabled on the database prior to the failover and there must be sufficient
flashback logs on that database. In addition, the database to be reinstated and the new
primary database must have network connectivity.
To reinstate a database:
-
Restart the database to the mounted state
-
Connect to the new primary database
-
Use Cloud Control or DGMGRL to reinstate the database
The broker reinstates a failed primary database as a standby database of the same type (physical or logical standby database) as the old standby database. The only exception to this is failovers to snapshot standby databases. In such cases, the failed primary database is reinstated as a physical standby database.
The broker reinstates bystander standby databases that were disabled during a failover as standby databases to the new primary database.
Reinstatement Using Cloud Control
On the Oracle Data Guard Overview page, click Database must be reinstated. This brings up the General Properties page that provides a Reinstate button. After you click the Reinstate button, Cloud Control begins reinstating the database.
When the process is complete, the database will be enabled as a standby database to the new primary database, and Cloud Control displays the Oracle Data Guard Overview page.
Reinstatement Using DGMGRL
Issue the following command while connected to any database in the broker configuration, except the database that is to be reinstated:
DGMGRL> REINSTATE DATABASE db_unique_name;
The newly reinstated standby database will begin serving as a standby database to the
new primary database. If reinstatement of a database fails, its status
changes to ORA-16795: The standby database needs to be
re-created. You must then re-create it from a copy of the
new primary database and reenable it as described in How to Re-create and Reenable a Disabled
Database.
How to Re-create and Reenable a Disabled Database
If you re-create the old primary database, it must be created as the standby type of the old standby database.
For example, if the old standby was a physical or snapshot standby, then the old primary must be re-created as a physical standby.
After the database has been re-created, enable broker management of the re-created standby database by using the DGMGRL ENABLE DATABASE command.
If you performed a failover or switchover that requires you to re-create the failed primary database or standby databases that were disabled during the role transition, then follow the procedures in the Oracle Data Guard Concepts and Administration chapter, "Creating a Physical Standby Database" and also the Oracle Data Guard Concepts and Administration chapter, "Creating a Logical Standby Database."