dataGuard主备库角色切换

切换顺序:
先主库后备库

--查看主库可切换状态:

SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO STANDBY
--执行切换命令转换primary到physical standby:
SQL>alter database commit to switchover to physical standby;
如果查询到的可转换状态为SESSION ACTIVE,则切换命令为:
SQL>alter database commit to switchover to physical standby with session shutdown;
--关闭数据库并启动到mount:
SQL>shutdown immediate;
SQL>startup mount;
--再次查看主库的可转换状态:
SQL>select switchover_status from v$database;
此时可以看到已经变成了TO PRIMARY状态了,说明原主库已经转换为新备库了。
--查看备库可切换状态:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO  PRIMARY
--执行切换命转换physical standby到primary:
SQL>alter database commit to switchover to primary;
如果查询到的可转换状态为SESSION ACTIVE,则切换命令为:
SQL>alter database commit to switchover to primary with session shutdown;
--关闭数据库并启动到open:
SQL>shutdown immediate;
SQL>startup
--再次查看备库的可转换状态:
SQL>select switchover_status from v$database;
此时可以看到已经变成TO STANDBY状态了,说明原备库已经转换为新主库了。
--启用新备库的日志应用:
SQL>alter database recover managed standby database disconnect from session;
上一篇:XCode中调整字体大小


下一篇:万字长文深入理解java中的集合-附PDF下载