Dataguard switchover and failover in Oracle

Dataguard Switch-over and fail over steps

 
A switch-over allows the primary database to switch roles with its standby database. There is no data loss during a switch-over.
You can switch back to the original Primary database later by performing another switch over.
 
In case of primary database failure, you will need to perform failover to transition the standby database to the primary role. After a failover, the original primary database can no longer participate in the Data Guard configuration. So if the original Primary database is still accessible, you should always consider a switchover first.
 
This document only talks about switchover involving physical standby database. In this example, the original primary data is called PRIM and the original standby database is called STAN.
 
Verify Before Switch-over:
 
1. Verify the primary database instance is open.

SQL> Select Database_role from v$Database;
It will return “PRIMARY”,
 
2. Verify the standby database instance is mounted.

SQL> Select Database_role from v$Database;
It will return “PHYSICAL STANDBY”,

3. Verify there are no active users connected to the databases.
 
4. Make sure the last redo data transmitted from the Primary database was applied on the standby database. Issue the following commands on Primary database and Standby database to find out:

SQL>select sequence#, applied from v$archvied_log;

Perform SWITCH LOGFILE if necessary.

In order to apply redo data to the standby database as soon as it is received, use Real-time apply.
 
Switchover Steps

1. Initiate the switchover on the primary database PRIM:

SQL>connect /@PRIM as sysdba
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

2. After step 1 finishes, Switch the original physical standby db STAN to primary role;

Open another prompt and connect to SQLPLUS:
SQL>connect /@STAN as sysdba
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

3. Immediately after issuing command in step 2, shut down and restart the former primary instance PRIM:

SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP MOUNT;

4. After step 3 completes, you can open the new Primary database STAN:

SQL>ALTER DATABASE OPEN;

STAN is now transitioned to the primary database role.Now your PHYSICAL STANDBY Database has become PRIMARY. To verify this change, again query the Database_role column of V$DATABASE. Now it will return “PRIMARY”.

SQL> Select Database_role from v$Database;

5. On the new primary database STAN, perform a SWITCH LOGFILE to start sending redo data to the standby database PRIM.

SQL>ALTER SYSTEM SWITCH LOGFILE;

 
Steps for FAILOVER the Dataguard environment
 
1. Initiate the failover on the standby database STAN:

SQL>connect /@STAN as sysdba
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

2. Immediately after issuing command in step 2, shut down and restart the standby instance STAN:

SQL>SHUTDOWN IMMEDIATE;
SQL>STARTUP;

STAN is now transitioned to the primary database role.Now your PHYSICAL STANDBY Database has become PRIMARY. To verify this change, again query the Database_role column of V$DATABASE. Now it will return “PRIMARY”.
SQL> Select Database_role from v$Database;
 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s