主备库的切换主要在两种情况下切换,Switchover和Failover,这两种切换都需要手工执行完成。
一是Switchover(计划中的切换,不会丢失数据)
二是Failover(当主库出现故障的时候需要主备库切换角色)
1,Switchover的切换方法
主库端:
select switchover_status from v$database;
如果是to standby表可以正常切换.
直接执行alter database commit to switchover to physical standby;
否则执行: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;
备库端:
select switchover_status from v$database;
如果是to_primary表可以正常切换.
执行: alter database commit to switchover to primary;
否则执行: alter database commit to switchover to primary with session shutdown;
shutdown immediate;
startup;
2,Failover切换方法</