Tuesday, 28 January 2014

Steps to switch Primary to Standby


Step 1   Verify that the primary database can be switched to the standby role.
Query the SWITCHOVER_STATUS column of the V$DATABASE view on the primary database.For example:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
 -----------------
 TO STANDBY
 1 row selected
A value of TO STANDBY or SESSIONS ACTIVE indicates that the primary database can be switched to the standby role. If neither of these values is returned, a switchover is not possible because redo transport is either misconfigured or is not functioning properly.
Step 2   Initiate the switchover on the primary database.
Issue the following SQL statement on the primary database to switch it to the standby role:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH
 SESSION SHUTDOWN;
This statement converts the primary database into a physical standby database. The current control file 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.
Note:
The WITH SESSION SHUTDOWN clause can be omitted from the switchover statement if the query performed in the previous step returned a value of TO STANDBY.
Step 3   Shut down and then mount the former primary database.
SQL> SHUTDOWN ABORT;
SQL> STARTUP MOUNT;
At this point in the switchover process, the original primary database is a physical standby database
Step 4   Verify that the switchover target is ready to be switched to the primary role.
Query the SWITCHOVER_STATUS column of the V$DATABASE view on the standby database. For example:
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS
-----------------
TO_PRIMARY
1 row selected
A value of TO PRIMARY or SESSIONS ACTIVE indicates that the standby database is ready to be switched to the primary role. If neither of these values is returned, verify that Redo Apply is active and that redo transport is configured and working properly. Continue to query this column until the value returned is either TO PRIMARY or SESSIONS ACTIVE.
Step 5   Switch the target physical standby database role to the primary role.
Issue the following SQL statement on the target physical standby database:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY 
WITH SESSION SHUTDOWN;
Note:The WITH SESSION SHUTDOWN clause can be omitted from the switchover statement if the query performed in the previous step returned a value of TO PRIMARY.
Step 6   Open the new primary database.
SQL> ALTER DATABASE OPEN;
Step 7   Start Redo Apply on the new physical standby database.
For example:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY 
DATABASE DISCONNECT FROM SESSION;
 
Now enjoy with New Primary database.... 

No comments:

Post a Comment