Oracle Data Guard 主备切换
Oracle Dataguard的角色转换包含两类:Switchover和Failover。Switchover指主备之间角色转换,主库降为备库,备库升级为主库。而failover则是指主库出现问题时,备库切换为主库。
下面为官方定义:
Switchover
Allows the primary database to switch roles with one of its standby databases.There is no data loss during a switchover.After a switchover,each database continues to participate in the Data Guard configuration with its new role.
Failover
Changes a standby database to the primary role in response to a primary database failure.If the primary database was not operating in either maximum protection mode or maximum availability mode before the failure,some data loss may occur.If Flashback Database is enabled on the primary database,it can be reinstated as a standby for the new primary database once the reason for the failure is corrected.
switchover
过程演示
在主库:
select name,DATABASE_ROLE from v$database;
检查归档日志有没有中断:
select status, GAP_STATUS from v$archive_dest_status where dest_id=2;
查询切换前主库的状态,状态为TO STANDBY,主库才可以切换到备库: