In this tutorial, we will learn the switchover steps in Oracle Data Guard, which is called the manual switchover method.
In Oracle Data Guard, there are three types of switchover we can perform, listed below:
- Manual Switchover
- Switchover using DG Broker
Manual Data Guard switchover steps: In Data Guard, we have a minimum of two servers, Primary and Standby. Just follow the steps below carefully:
Data Guard Environment
Primary Side:
Database Name: OCP
Platform OS: Linux 8
Database Version: 19c
Database Role: Primary
Standby Side:
Database Name: OCPDR
Platform OS: Linux 8
Database Version: 19c
Database Role: Physical Standby
Prechecks before switchover
In Oracle Data Guard, we have to verify the database role and switchover status and check that both databases are in sync.
Step 1: Check Database role and switchover status
The below command will help us identify the database's current role and switchover status.
SQL> select name,open_mode,database_role,switchover_status from v$database;
Note: The switchover status should show "TO STANDBY" on the primary side. If the status is not showing "TO STANDBY" then you have to sync your standby with the primary first.
Step 2: Verify the archives’ applied status
SQL> SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY sequence#;
OR
SQL> select thread#,max(sequence#) from v$log_history group by thread#;
Verify that your primary Database is ready for the switchover:
The below command helps to verify whether the primary database is ready for the switchover or not. If the below command gives any error, then solve it; otherwise, go ahead with the switchover.
In my case, it doesn't give any error.
SQL> alter database switchover to OCPDR verify;
Database altered.
Step 3: Switchover to the Primary Database
If everything goes fine, then run the below command to switchover the Primary database to the standby database.
SQL> alter database commit to switchover to standby;
After switchover, let's shutdown the Database and start it as a physical standby:
SQL> shu immediate
SQL> startup mount standby database;
Check the database role after switchover
SQL> select name,open_mode,database_role,switchover_status from v$database;
Action on standby
After completing the switchover steps on Primary, now perform the steps below on the Standby side also.
Step 4: Switchover from standby to primary
The below command helps us convert our standby database into a primary database.
SQL>alter database commit to switchover to primary;
SQL> alter database open;
Check the current status on standby.
SQL> select name,open_mode,database_role,switchover_status from v$database;
Step 5: Start MRP after switchover
Once the switchover is completed then start the MRP process on the standby.
SQL> alter database recover managed standby database disconnect from session;
I hope you enjoyed this article. If yes, please write your feelings in the comment box.