Friday, October 9, 2020

Oracle 12c-Step by Step Manual Switchover Data Guard

 Switchover:

          It is reversal of role between a standby database and a primary database. The primary database assumes role of standby database and the standby database assumes role of primary database after the switchover. There is no data loss in a switchover. This is generally a planned activity.

Step 1:

 ON Primary

 Select switchover_status from v$database..

 Step 2 :

 Check that there is no active users connected to the databases.

 Select  distinct ousers,username from v$session

 Step 3:

 Switch the current online redo log file on primary database and verify that it has been applied.

 SQL>alter system switch logfile

 Step  4 :

 Connect with primary database and initiate the switchover.

 SQL>alter database commit to switchover to physical standby;

 Now, the primary database is converted into standby database.The controlfile is backed up to the current SQL session trace file before the switchover. This makes it possible to reconstruct a current control file,if necessary.

 If we try to perform a switchover when other instances are running then we will get ORA-01105 as follows :

SQL>alter database commit to switchover to physical standby with Session shutdown;

 The above statement first terminates all active sessions by closing the primary database. Then any non-archived redo log files are transmitted and applied to standby database. Apart from that an end-of-redo marker is added to the header of the last log file that was archived.A backup of current control file is created and the current control file is converted into a standby control file.

 Step  5 : 

Shut down and restart the  primary instance(RED).

SQL>Shut immediate; 

SQL> Startup mount;

Step  6 : 

Verify the switchover status in the v$database view.

After we change the primary database to the physical standby role and the switchover notification is received by the standby databases in the configuration, we should verify if the switchover notification was processed by the target standby database by querying the "  column of the v$database fixed view on the target standby database.


On Primary Database(prim)

SQL> select name,open_mode,db_unique_name,switchover_status from v$database.


NAME      OPEN_MODE       DB_UNIQUE_NAME         SWITCHOVER_STATUS
------       -----------          --------------------         ----------------------
PRIM     MOUNTED                prim                    TO PRIMARY

On Old Standby Database(PRIM)
SQL> select name,open_mode,db_unique_name,switchover_status from v$database.


Important Notes :

The switchover_status column of v$database can have the following values:

Not Allowed:-Either this is a standby database and the primary database has not been switched first, or this is a primary database and there are no standby databases
Session Active:- Indicates that there are active SQL sessions attached to the primary or standby database that need to be disconnected before the switchover operation is permitted
Switchover Pending:- This is a standby database and the primary database switchover request has been received but not processed.
Switchover Latent:- The switchover was in pending mode, but did not complete and went back to the primary database
To Primary:- This is a standby database, with no active sessions, that is allowed to switch over to a primary database
To Standby:- This is a primary database, with no active sessions, that is allowed to switch over to a standby database
Recovery Needed:- This is a standby database that has not received the switchover request


No comments:

Post a Comment

ASM

Rename Asm DiskGroup Name On Oracle 12c

  Step1:Startup asm with created asm pfile. startup pfile=$ORACLE_HOME/dbs/init+ASM.ora; Step2:Dismount all disks.  alter diskgroup all dism...