I will explain you to perform Switchover in Oracle Dataguard in this article.
Before reading this article, I recommend that you read the article about Data Guard configuration and architecture with following links.
As I mentioned in my above posts, Dataguard is Oracle’s Disaster Recovery solution.You can open dataguard in case of a disaster and make the database available as soon as possible.
You can perform switchover between production database and dataguard, in case of any disaster or any maintenance (ram, disk exchange etc) on the server on the Production side.
This operation we call Switchover changes the modes between Primary (Production) and Standby (Disaster or Dataguard). So the primary database will be the Standby database after this switchover, while the Standby database will be Primary database.
The steps to be performed step by step on the Production and Standby side of the switchover process are as follows. MehmetSalih server is the Production database server, and Deveci Server is Standby server in the example.
Steps on Production
Manual logfile switch is done before Switchover on Primary like following.
[oracle@MehmetSalih ~]$ sqlplus / as sysdba SQL> alter system switch logfile; System altered. SQL> select switchover_status,database_role from v$database; SWITCHOVER_STATUS DATABASE_ROLE -------------------- ---------------- TO STANDBY PRIMARY
In this step, we perform switchover operation and our Primary database will be Physical Standby.
SQL> alter database commit to switchover to physical standby with session shutdown; Database altered. SQL> shutdown immediate; ORA-01092: ORACLE instance terminated. Disconnection forced SQL> startup nomount ORACLE instance started. Total System Global Area 534462464 bytes Fixed Size 2230072 bytes Variable Size 171968712 bytes Database Buffers 352321536 bytes Redo Buffers 7942144 bytes SQL>
Mount the Old Primary Database in this step as Standby
SQL> alter database mount standby database; Database altered. SQL> alter system set log_archive_dest_state_2=defer; System altered.
Steps On Dataguard
In this step, we perform switchover operation on Standby and our Standby database will be Production.
[oracle@Deveci ~]$ sqlplus / as sysdba SQL> select switchover_status,database_role from v$database; SQL> alter database commit to switchover to primary with session shutdown; Database altered. SQL> shutdown immediate; SQL> startup ORACLE instance started. Total System Global Area 534462464 bytes Fixed Size 2230072 bytes Variable Size 163580104 bytes Database Buffers 360710144 bytes Redo Buffers 7942144 bytes Database mounted. Database opened.
Now the MRP process on the new Standby side ( Old Production ) is run as follows.
SQL> alter database recover managed standby database using current logfile disconnect; Database altered. SQL>
Now Switchover operation is completed. You can do same steps to reverse them.