Thursday, June 2, 2016

Role Transitions-Swithover and Failover

A database operates in one of the following mutually exclusive roles: primary or standby. Data Guard enables you to change these roles dynamically by issuing the SQL statements or by using either of the Data Guard broker's interfaces. Oracle Data Guard supports the following role ransitions:

Switchover:


-- Allows the primary database to switch roles with one of its standby databases.

-- There is no data loss during a switchover.

-- After a switchover, each database continues to participate in the Data Guard configuration with its new role.

-- A switchover is typically used to reduce primary database downtime during planned outages, such as operating system or hardware upgrades, or rolling upgrades of the Oracle database software and
patch sets.

-- A switchover takes place in two phases.

-- In the first phase, the existing primary database undergoes a transition to a standby role.

-- In the second phase, a standby database undergoes a transition to the primary role.

-- Figure shows Data Guard configuration before the roles of the databases are switched. The primary database is in PIRME, and the standby database is in STAND.



--  Figure shows the Data Guard environment after a switchover took place. The original standby database STAND became the new primary database. The original primary database PRIME is now the standby database.


Practical steps to switchover between Primary and Standby databases:


Primary DB Server:

sql>archive log list

sql>alter system switch logfile;

sql>/

sql>/

sql>archive log list


Standby DB Server:


$ps -ef | grep mrp


( MRP should be in Enable mode. If not, Use below statmenet )


sql>recover managed standby database using current logfile disconnect from session;

sql>select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;

sql>archive log list


Primary DB Server:


sql>select name, open_mdoe, protection_mode, database_role, switchover_status from v$database;

sql>alter database commit to switchover to standby;

sql> shut immediate

sql>startup nomount

sql>alter database mount standby database;

sql>select name, open_mdoe, protection_mode, database_role, switchover_status from v$database;


Standby DB Server:

sql>select name, open_mdoe, protection_mode, database_role, switchover_status from v$database;

sql>alter database commit to switchover to primary;

sql> shut immediate

sql>startup

sql>select name, open_mdoe, protection_mode, database_role, switchover_status from v$database;


-- Now Swichover done. The original Primary DB ( PRIME ) and Standby DB ( STAND ) are interchanged.

-- Now Primary is STAND and Standby is PRIME.

-- So, Check the primary and standby databases properly working or not.



Standby DB Server ( PRIME ):


sql>archive log list

sql>select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;



Primary DB Server ( STAND ):


sql>archive log list

sql>alter system switch log file;

sql>/

sql>/

sql>archive log list


Standby DB Server ( PRIME ):


sql>archive log list

sql>select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;

sql>recover managed standby database using current logfile disconnect from session;

sql>archive log list

sql>select sequence#, first_time, next_time, applied from v$archived_log order by sequence#;


-- Again Invoke the logswitch from Primary and then check log sequence number from standby using above sql statements whether the logs are applied or not.

-- Now do again the swichover process for Practice purpose...



Failover:


-- Changes a standby database to the primary role in response to a primary database failure.

-- If the primary database was not operating in either maximum protection mode or maximum availability mode before the failure, some data loss may occur.

-- If Flashback Database is enabled on the primary database, it can be reinstated as a standby for the new primary database once the reason for the failure is corrected.

-- A failover is typically used only when the primary database becomes unavailable, and there is no
possibility of restoring it to service within a reasonable period of time.

-- The specific actions performed during a failover vary based on whether a logical or a physical standby database is involved in the failover,

-- the state of the Data Guard configuration at the time of the failover, and on the specific SQL statements used to initiate the failover.




Practical steps to Failover ( Activate Standby as Primary ):


Primary DB Server ( PRIME ):

$cd /u01/app/oracle/oradata/prime

$ls

$mv Control01.ctl  Control01bkp.ctl

$ls

$export ORACLE_SID=prime

$sqlplus / as sysdba

ora-205 error ==>> primary db failed to open

sql>shut abort


Standby DB Server ( STAND ):


sql>recover managed standby database finish;

( or )

sql>recover managed standby database cancel;



sql>alter database commit to switchover to primary;

sql>alter database open;

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



( OR )



sql>alter database activate standby database;

sql>shut immediate

sql>startup

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



sql>select * from scott.emp;


-- If  Flashback database is already in enable mode on Primary database, It is possible to restore and recover the Primary database and then operated as Standby database.






No comments:

Post a Comment