select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
alter database commit to switchover to primary;
重新启动数据库open
shutdown immediate
startup
select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
OPEN PRIMARY
至此原主库切换至备库,原备库切换至主库了
3)应急切换
(注:模拟主库由于故障无法正常switchover,需要执行failover,强制备库->pridb并接管业务)
1.备库:
由于是failover,所以理解主库这时候已经无法正常使用,只需备库切换至pridb
停止应用恢复模式
alter database recover managed standby database finish;
转换standbydb为primary db
alter database commit to switchover to primary;
重启数据库,恢复正常业务
shutdown immediate
startup
select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
OPEN PRIMARY