Switchover & Failover

http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/role_management.htm#i1026464
http://www.dbasupport.com/forums/showthread.php?p=256729

SQL> COLUMN NAME FORMAT A18
SQL> COLUMN VALUE FORMAT A16
SQL> COLUMN TIME_COMPUTED FORMAT A24
SQL> SELECT * FROM V$DATAGUARD_STATS;
NAME               VALUE             TIME_COMPUTED
------------------ ----------------  ------------------------
apply finish time  +00 00:00:02.4    15-MAY-2005 10:32:49
       second(1)
       interval
apply lag          +00 0:00:04       15-MAY-2005 10:32:49
       second(0)
       interval
transport lag      +00 00:00:00      15-MAY-2005 10:32:49
       second(0)
       interval
Step 1 On the current primary database
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS 
 ----------------- 
 TO STANDBY 

Step 2 On the current primary database
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN;

Step 3 Shut down the former primary instance
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;

Step 4 on the target standby database
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; 
SWITCHOVER_STATUS 
----------------- 
TO_PRIMARY 

Step 5 on the target standby database
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

If the physical standby database has not been opened in read-only mode since the last time it was started, issue the SQL ALTER DATABASE OPEN statement to open the new primary database:

Step 6 on the target standby database
SQL> ALTER DATABASE OPEN;
Then, go to step 7.

If the physical standby database has been opened in read-only mode since the last time it was started, you must shut down the target standby database and restart it:

SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;

Step 7   If necessary, restart log apply services on the standby databases.
 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Step 8   Begin sending redo data to the standby databases.
SQL> ALTER SYSTEM SWITCH LOGFILE;
ORACLE DG文档中有
SQL>  select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
SWITCHOVER LATENT

1.        Connect to the new standby database (old primary), and issue the following statement to convert it back to the primary role:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
If this statement is successful, then shut down (if necessary) and restart the database. Once restarted, the database will be running in the primary database role, and you do not need to perform any more steps.
If this statement is unsuccessful, then continue with Step 3.
2.        When the switchover to change the role from primary to physical standby was initiated, a trace file was written in the log directory. This trace file contains the SQL statements required to re-create the original primary control file. Locate the trace file and extract the SQL statements into a temporary file. Execute the temporary file from SQL*Plus. This will revert the new standby database back to the primary role.
3.        Shut down the original physical standby database.
4.        Create a new standby control file. This is necessary to resynchronize the primary database and physical standby database. Copy the physical standby control file to the original physical standby system. Section 3.2.2 describes how to create a physical standby control file.
5.        Restart the original physical standby instance.If this procedure is successful and archive gap management is enabled, the FAL processes will start and re-archive any missing archived redo log files to the physical standby database. Force a log switch on the primary database and examine the alert logs on both the primary database and physical standby database to ensure the archived redo log file sequence numbers are correct.See Section 5.8 for information about archive gap management and Appendix G for information about locating the trace files.
6.        Try the switchover again. At this point, the Data Guard configuration has been rolled back to its initial state,and you can try the switchover operation again (after correcting any problems that might have led to the initial unsuccessful switchover).
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License