Physical Standby Switchover A switchover is a role reversal between the primary database and one of its standby databases. A switchover operation guarantees no data loss. This is typically done for planned maintenance of the primary system. During a switchover, the primary database transitions to a standby role and the standby database transitions to the primary role. The transition occurs without having to re-create either database. By contrast, a failover is an irreversible transition of a standby database to the primary role. This is only done in the event of a catastrophic failure of the primary database. Before starting a switchover operation: 1.Verify that both the primary and standby init.ora support role transition. Oracle recommends that you maintain a single init.ora for both the primary and the standby. standby. Each init.ora should have all the parameters that are needed to support either the standby or primary primary role. An example of the primary init.ora follows: ### Primary database primary role parameterr ### LOG_ARCHIVE_DEST_1='LOCATION=/database/oracle/920DG/pr LOG_ARCHIVE_DES T_1='LOCATION=/database/oracle/920DG/primar imar y/arch' LOG_ARCHIVE_DEST_2='SERVICE=920DG_hasunclu2' LOG_ARCHIVE_DEST_STATE_1=ENABLE LOG_ARCHIVE_DEST_STATE_2=ENABLE LOG_ARCHIVE_FORMAT=%d_%t_%s.arc ### Primary database standby role parameters ### FAL_SERVER=920DG_hasunclu2 FAL_CLIENT=920DG_hasunclu1 DB_FILE_NAME_CONVERT=('/standby','/primary') LOG_FILE_NAME_CONVERT=('/standby','/primary') STANDBY_AR ST ANDBY_ARCHIVE_DEST=/dat CHIVE_DEST=/database/oracle/920DG/arch abase/oracle/920DG/arch STANDBY_FILE_MANAGEMENT=AUTO An example of a standby init.ora follows: ### Standby database standby role parameters ### FAL_SERVER=920DG_hasunclu1
### Standby database primary role parameters ### LOG_ARCHIVE_DEST_2='SERVICE=920DG_hasunclu1' LOG_ARCHIVE_DEST_STATE_2=DEFER
With the initialization parameters on both the primary and standby databases set as described above, the only parameter parameter that needs to change after a role transition is the LOG_ARCHIVE_DEST_STATE_2 parameter. Change this parameter to ENABLED on the database that assumes the primary role. 2.Verify that there is network connectivity between the primary and standby locations. 3.Each location in the Data Guard configuration should have connectivity through Oracle Net to the primary database and to all associated standby databases. 4.Verify that there are no active users connected to the databases. 5.Verify that all but one primary instance and one standby instance in a Real Application Clusters configuration are shut down. 6.For a Real Application Clusters database, only one primary instance and one standby instance can perform the switchover operation. Shut down all other instances before the switchover operation. 7.
For switchover operations involving a , the primary database instance is open and the
standby database instance is mounted. 8. The standby database that you plan to transition to the primary role must be mounted before you begin the switchover switch over operation. operati on. Ideally, Ideally, the physical standby database will also be actively recovering archived redo logs when the database roles are switched. If the physical standby database is open for read-only access, the switchover operation still will take place, but will require additional time. 9.For switchover operations involving a l , both the primary and standby database instances are open. 10.Place the standby database that will become the new primary database in ARCHIVELOG mode. 11.Remove any redo data application delay in effect on the standby database.
Steps to perform switchover with Physical Standby databases Verify that it is possible to perform a switchover operation. On the primary query quer y the switchover_status column of v$database to verify that switchover to standby is possible.
SWITCHOVER_STATUS
TO STANDBY
In order to perform a switchover all sessions to the database need to be disconnected. In version 901 this was a manual process. In version 9.2.0 this process has been automated automated with the with session shutdown clause that has been added to the alter database commit to switchover command. If SWITCHOVER_S SWITCHOVER_STATUS TATUS returns SESSIONS ACTIVE then you should either disconnect all sessions manually manually or when performing performing step 2 you should append the with session shutdown clause. For example:
> Note that the clause also works with the switchover to primary command. The column of can have the following values: NOT ALLOWED - Either this is a standby database and the primary database has not been switched first, first, or this is a primary database and there are no standby databases. SESSIONS ACTIVE - Indicates that there are active SQL sessions attached to the primary or standby database
that need to be disconnected disconnected before before the operation is permitted.
switchover
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 database.
allowed to to switch over to a pr primary imary
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.
During normal operations it is acceptable to see the following values for SWITCHOVER_STATUS on the primary to be SESSIONS ACTIVE or TO STANDBY. During normal operations on the standby it is acceptable to see the values of NOT ALLOWED or SESSIONS ACTIVE. Convert the primary database to the new standby:
Database altered. . Shutdown the former primary and mount as a standby database: ORA-01507 ORA-01507: database databas e not mounted down.
ORACLE instance shut
startup nomount ORACLE instance started. Defer the remote archive destination on the old primary: >alter system set log_archive_dest_state_2=defer; Verify that the physical standby can be converted to the new primary: > select switchover_status from v$database; SWITCHOVER_STATUS SWITCHOVER PENDING Note that if the status returns SESSIONS ACTIVE then you should append the with session shutdown shutdown clause to to the command in step 6. Convert the physical standby to the new primary: > Database altered. If you are on verion 9.0.1 then you should first cancel managed recovery prior to issuing the above command. If you are on 9.2.0 and have started managed recovery with the "through all switchover" clause then you should also cancel managed recovery before before issuing the above command. . Shutdown and startup the new primary: > s ORA-01507: database not mounted ORACLE instance shut down. > ORACLE instance started. Database mounted. Database opened. Enable remote archiving on the new primary to the new
standby: >alter system set log_archive_dest_state_2=enable; Start managed recover on the new standby database: > recover managed standby database disconnect; Media recovery complete.