Performing a Data Guard switchover is crucial in database administration, ensuring system availability and maintaining data integrity. In this tutorial, we will guide you through the process of executing a manual switchover in Oracle 19c Data Guard. The switchover operation allows the primary database to transition to a standby role, and the standby database to take over as the primary. This operation is essential for planned maintenance and ensures no data loss. We will cover the necessary steps, including preparation, execution, and verification of the switchover process.
Preparing for a Data Guard Switchover
Before initiating a Data Guard switchover, it is crucial to prepare the primary and standby databases to ensure a smooth transition.
Ensure Compatibility and Version Consistency
Both the primary and standby databases must be running the same version of Oracle RDBMS. Verify the alert logs and ensure there are no errors.
SELECT * FROM v$database_block_corruption;
SELECT * FROM v$nonlogged_block;
These queries help identify and address any block corruptions before proceeding with the switchover.
Configure Standby Redo Logs
Ensure to properly configure standby redo log files on the primary database. This setup is essential for the standby database to take over the primary role seamlessly.
SELECT * FROM v$logfile WHERE TYPE = 'STANDBY';
Preset Database Properties
Set database properties related to redo transport and apply services. This includes LogXptMode
, NetTimeout
, StandbyArchiveLocation
, and RedoRoutes
.
ALTER SYSTEM SET log_archive_dest_2='service=standby_db';
These configurations ensure that the redo logs are transported and applied correctly during the switchover process.
Executing the Data Guard Switchover Process
The actual switchover process involves several critical steps to transition the roles of the primary and standby databases.
Initiate the Switchover
Start the switchover by using either Oracle Cloud Control or the Data Guard command line interface (DGMGRL).
ALTER DATABASE SWITCHOVER TO 'standby_db';
This command initiates the role transition process.
Verify the State and Status
Ensure that the primary and target standby databases are in the correct states. The primary should be in TRANSPORT-ON
and the standby in APPLY-ON
.
SELECT database_role, switchover_status FROM v$database;
Convert Roles
The broker will convert the original primary database to a standby role and the target standby to the primary role.
Restart and Apply Redo Logs
If the switchover involves a physical standby, the broker restarts the new standby database and begins applying redo logs.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
Open the New Primary
The new primary database should be opened in read/write mode.
ALTER DATABASE OPEN;
Post-Switchover Verification
After the Data Guard switchover, it is essential to verify that all databases are functioning correctly in their new roles.
Check Archive Log Application
Verify that archive logs are being transferred and applied correctly.
SELECT max(sequence#), thread# FROM v$archived_log WHERE applied='YES' GROUP BY thread#;
This query ensures that the logs are being applied without any gaps.
Verify Database Roles
Confirm the new roles of the databases.
SELECT database_role FROM v$database;
In addition to these steps, monitor the alert logs for any errors related to redo transport and apply processes. Make sure there are no I/O or connection issues.
Conclusion
Performing a Data Guard switchover is a critical operation that ensures the continuity and availability of your database systems. By following this tutorial, we have outlined the necessary steps to prepare, execute, and verify the switchover process. Ensuring compatibility, configuring standby redo logs, and setting up database properties are crucial preparatory steps. During the switchover, initiating the command, verifying states, and converting roles are key actions. Post-switchover verification ensures that the new primary and standby databases function correctly, maintaining data integrity and availability.
See more on Oracle’s website!
Be Oracle Dataguard Certified Professional, this world is full of opportunities for qualified DBAs!