1>验证主库能够切换到备用角色。
SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS -------------------- TO STANDBY
2>在主库上面开始切换
alter database commit to switchover to physical standby with session shutdown ;
备库的alertlog中会收到一条
Identified End-Of-Redo (switchover) for thread 1 sequence 30 at SCN 0x0.126064类似的消息,
说明主库开始做角色转换,并且没有丢失数据。
startup mount ;
3> 验证转换目标已经准备好转换为主库角色
SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS -------------------- TO PRIMARY
这里查询出来的值不为TO_PRIMARY即有点问题。
4> 转换目标逻辑备用库角色为主库角色。
sql> alter database commit to switchover to primary with session shutdown; SWITCHOVER_STATUS -------------------- TO PRIMARY Database altered.
5>打开新的主库
sql> ALTER DATABASE OPEN;