Wednesday 18 September 2013

Failover from Primary to Physical Standby Database

Failover from Primary to Physical Standby Database


#########Failover to Physical Standby Database#########

–In Standby–
SELECT thread#, low_sequence#, high_sequence#
FROM v$archive_gap;

If possible, copy all of the identified missing archived redo log files to the target standby
database from the primary database and register them. Execute the following command to
register the redo log files:

ALTER DATABASE REGISTER PHYSICAL LOGFILE ‘filespec1′;

–Perform this step for each thread. Repeat step until all gaps are resolved.

SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#)
OVER (PARTITION BY thread#) AS LAST
FROM V$ARCHIVED_LOG;

/*Copy to the target standby database any available primary database archived redo log files
that contain sequence numbers higher than the highest sequence number that is available on
the target standby database. Then register those redo log files by issuing the following SQL
statement:*/

ALTER DATABASE REGISTER PHYSICAL LOGFILE ‘filespec1′;

–Perform this step for each thread. Repeat step until all gaps are resolved.

–Execute the following SQL statement to initiate the failover:

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;

–Transition the physical standby database to the primary databaserole by issuing the following SQL statement

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

/*After issuing this SQL statement, you can no longer use this database as a standby database.
Any subsequent redo that is received from the original primary database cannot be applied.
During the failover process, the standby redo log files are automatically archived and
recovered on all other standby databases that are derived from the original primary database
if the standby destinations are correctly defined on the new primary database*/

–in New Primary Database
ALTER DATABASE OPEN;

....Cheer....

No comments:

Post a Comment