Let us understand today whole switchover the scenario in Oracle Data Guard. I have written many articles of Oracle Data Guard that explains the architecture of Oracle Data Guard, Benefits of having Data Guard as your DR solution, different methods of creating Data Guard.

Today, we will see How your database works before switchover after switchover, Preparing for the switchover and we will actually perform switchover task.

There main two database roles in Oracle Data Guard :

      1. Primary Database
      2. Standby Database

These two roles are mutually exclusive. The primary role works actively with all the connections coming from an end user. While Standby role is only connected with Primary Database. Whatever works happening on primary database will come on standby in form of redo data.

MRP or LSP process of Standby database will apply those redo in Standby database.

Before SwitchOver :

As we can see in above diagram AHD_DB is a primary database, redo logs are copied to MUM_DB through oracle net and applied to MUM_DB. Users can access MUM_DB for read-only access.

This scenario before Switch Over took place. AHD_DB is located in Ahmedabad having a role of Primary Database and MUM_DB is located in Mumbai having a role of a standby database.

After SwitchOver  :

We can see in above Diagram role of AHD_DB and MUM_DB have been changed.MUM_DB has become primary database and AHD_DB which was Standby database before has become Primary Database now.

This is how switchover works.

Preparing for SwitchOver :

Before performing switch over there are few things that we need to consider.

1. Network Connection exists between Primary Database and all available standby database.

2. State of Primary Database is TRANSPORT-ON and state of Standby database is APPLY-ON.

3. Standby database log_archive destinations are properly set for Primary Role.

4. Standby redo log files [SRLs] are configured on the primary database.

Performing SwitchOver :

Step 1: On Primary database check switchover_status

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE

It is shown sessions active then use alter database commit to switchover to standby command with session shutdown clause.

Step 2: Change the switchover status

SQL> alter database commit to switchover to standby with session shutdown;

Database altered.

Step 3: Go to standby database check open mode and role of the database.

SQL> select name,open_mode,database_role from v$database;

NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
MYTEST MOUNTED PHYSICAL STANDBY

Step 4: Check switchover_status from a v$database.

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
TO PRIMARY

Step 5: Perform the following command to switch over standby role to a primary database.

SQL> alter database commit to switchover to primary;

Database altered.

Step 6: Now check database role on a newly become primary database.

SQL> select name,open_mode,database_role from v$database;

NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
MYTEST MOUNTED PRIMARY

We can see here database role is now primary. Database open mode is mount so the open database is in read-write mode using the following command.

SQL> alter database open;

Database altered.

check open-mode of a database.

SQL> select name,open_mode,database_role from v$database;

NAME OPEN_MODE DATABASE_ROLE
--------- -------------------- ----------------
MYTEST READ WRITE PRIMARY

Step 7: On newly created Standby [old primary] apply recovery

SQL> recover managed standby database disconnect from session;
Media recovery complete.

Stay tuned for More articles on Oracle DataGuard

Thank you for giving your valuable time to read the above information.

If you want to be updated with all our articles send us the Invitation or Follow us:

Telegram Channel: https://t.me/helporacle

Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/

Joel Perez’s LinkedIn: Joel Perez’s Profile

LinkedIn Group: Oracle Cloud DBAAS

Facebook Page: OracleHelp

About The Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.