Primary and Standby library switching is mainly in two cases, switchover and failover, both of which need to be done manually.
One is switchover (planned switchover, no loss of data)
The second is failover (the main repository switch role is required when the main library fails)
Switching method of 1,switchover
Main Library side:
Select Switchover_status from V$database;
If the to standby table can be switched normally.
Execute ALTER DATABASE commit to switchover to physical standby directly;
Otherwise execute: ALTER DATABASE commit to switchover to physical standby with session shutdown;
Shutdown immediate;
Startup Nomount;
ALTER DATABASE mount standby database;
ALTER DATABASE recover managed standby database disconnect from session;
Prepare the library side:
Select Switchover_status from V$database;
If the To_primary table can be switched normally.
Execution: ALTER DATABASE commit to switchover to primary;
Otherwise execute: ALTER DATABASE commit to switchover to primary with session shutdown;
Shutdown immediate;
Startup
2,failover Switching method
(1) Determine that the primary database does have a serious hardware failure or other cause the primary database cannot be started.
(2) Check if there is a archive redo log on the physical standby database gaps
Sql>select thread#, low_sequence#, high_sequence# from V$archive_gap;
(3) Eliminate archive redo log gaps
Archive redo logs that are not uploaded to the physical standby database are uploaded to the physical standby database from the primary database or from other backup locations and registered to the controlfile of the physical standby database.
sql> ALTER DATABASE REGISTER physical LOGFILE ' archive redo log file name ';
Repeat the 2,3 step until the V$archive_gap view has no record.
(4) Initiating failover operations on the physical standby database
SQL > ALTER database RECOVER MANAGED STANDBY database FINISH Force;
(5) Transforming the physical standby database into a primary role
Sql> ALTER DATABASE COMMIT to switchover to PRIMARY;
(6) Restart the new primary database
Sql> SHUTDOWN IMMEDIATE;
Sql> STARTUP;
(7) Make a full backup of the new primary database.
Oracle Dataguard Switching method for master and standby libraries