Thursday, November 21, 2013

Oracle Data Guard : Switchover/Failover

The following notes describe the switchover and failover commands for Oracle 11g. They are probably the same for previous versions.

I have named the servers A and B in order to maintain consistency where the words Primary and Standby are changeable during the process.do have Data Guard Broker, these instructions are unnecessary. Just connect to the broker on either server and issue the failover to… or switchover to…. commands and you’re away.

 

Of course always bear in mind that switchover is reversible, failover isn’t. Once you’ve failed over, you must rebuild the original primary as a standby andthen switch over to it.

 

Switchover to Standby

=====================

 

--On the test instances, I was able to switchover in less than 30 seconds.

 

 

On the Primary (A)

 

    alter database commit to switchover to standby;

 

Once complete, on Standby (B)

 

    alter database commit to switchover to primary;

                alter database open;

               

On Primary (A) - which has been aborted by the process

 

    shutdown immediate

                conn / as sysdba

                startup mount

                alter database recover managed standby database disconnect;

 

On both

 

                select controlfile_type from v$database;

-- (Current is the Primary)

               

DataGuard Failover

==================

 

Make sure which is the Standby database.

 

    select controlfile_type from v$database;

  

On the Standby, assuming you've lost the primary.

 

    alter database recover managed standby database cancel;

    alter database recover managed standby database finish;

 

Now issue the switchover command and then open the database

 

    alter database commit to switchover to primary with session shutdown;

    alter database open;

  

This leaves us with a single database instance running.

You might also need to set log_archive_dest_2_state to DEFER if the original primary server isn’t there otherwise you might get timeout delays when the instance tries to write the redo logs/archived redo log to it.

 

HappyJohn.

No comments:

Post a Comment