Graceful Switchover and Switchback activity in Dataguard !!!

Home »  ORACLE »  Graceful Switchover and Switchback activity in Dataguard !!!

In this article, we will see the steps of Graceful Switchover and Switchback activity in Dataguard.

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

 

• SWICTHOVER Activity

– Check whether Primary and Standby databases are in sync or not

On Primary database

SQL> select name, open_mode, database_role from v$database;
SQL> select thread#, max(sequence#) from v$archived_log where applied=’YES’ group by thread#;

On Standby database

SQL> select name, open_mode, database_role from v$database;
SQL> select thread#, max(sequence#) from v$archived_log where applied=’YES’ group by thread#;

 

– If Standby is in sync with Primary database then perform the Switchover

On Primary database

SQL> select switchover_status from v$database;
SQL> alter database commit to switchover to standby with session shutdown;
SQL> shutdown immediate;

On Standby database

SQL> select switchover_status from v$database;
SQL> alter database commit to switchover to primary with session shutdown;
SQL> shutdown immediate;

 

– Perform normal startup and check the status

On Standby database – New Primary database

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

On Primary Database – New Standby database

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

 

– Change the value of “log_archive_dest_state_2” parameter to defer and start recovery

On Primary Database – New Standby database

– Change the value of below parameter
SQL> alter system set log_archive_dest_state_2=’defer’;

– Start recovery on new standby database
SQL> recover managed standby database disconnect from session;

 

– Change the value of “log_archive_dest_state_2” parameter to enable and do log switches

On Standby database – New Primary database

– Change the value of below parameter
SQL> alter system set log_archive_dest_state_2=’enable’;

– Switch logfiles 4-5 times and check whether they are getting applied on new standby database
SQL> alter system switch logfile;
SQL> select thread#, max(sequence#) from v$archived_log where applied=’YES’ group by thread#;

On Primary Database – New Standby database

SQL> select thread#, max(sequence#) from v$archived_log where applied=’YES’ group by thread#;

If the archive log files are getting applied on standby database, this concludes our SWITCHOVER activity.

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

 

• SWICTHBACK Activity

– Convert the New Primary database back to Standby database

On Standby database – New Primary database

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

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

 

– Convert the New Sandby database back to Primary database

On Primary Database – New Standby database

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

SQL> alter database commit to switchover to primary with session shutdown;
SQL> shutdown immediate;

 

– Change the value of “log_archive_dest_state_2” parameter to “DEFER”

On Standby database

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

SQL> alter system set log_archive_dest_state_2=’defer’;

 

– Change the value of “log_archive_dest_state_2” parameter to “ENABLE”

On Primary Database

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

SQL> alter system set log_archive_dest_state_2=’enable’;

 

– Start recovery on standby database

SQL> recover managed standby database disconnect from session;

 

– Perform log switches on Primary database and check whether they are getting applied on standby database

On Primary Database

SQL> alter system switch logfile;
SQL> select thread#, max(sequence#) from v$archived_log where applied=’YES’ group by thread#;

On Standby database

SQL> select thread#, max(sequence#) from v$archived_log where applied=’YES’ group by thread#;

If the archive log files are getting applied on standby database, this concludes our SWITCHBACK activity.

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

Tags : ,, ,

One Comment so far:

  1. Palak kala says:

    It helped . Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *