ORACLE DATAGUARD SWITCHOVER 步骤
-
验证主库是否能执行角色转换到备库 原主库执行
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS ----------------- TO STANDBY 1 row selected
-
开始把物理主库改变为物理备库 在原主库执行。
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY; 或 SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY with session shutdown;
- Note
- 如果有活动的session可以使用 with session shutdown 选项,否则转换会遇到ORA-01093错误,也可以杀掉活动会话或等活动会话后进行转换.
-
关闭并重启主库(原主库执行)
SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP MOUNT;
-
验证备库是否能执行角色转换到主库(原备库执行)
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS ----------------- TO_PRIMARY 1 row selected
-
开始把物理备库转换成物理主库(原备库执行)
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
如果报ORA-16139: media recovery required,可能是由于未应用日志引起,可先执行 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
-
打开备库,然后关闭重启.(原备库执行)
SQL> ALTER DATABASE OPEN; SQL> SHUTDOWN IMMEDIATE; SQL> STARTUP;
-
验证是否转换成功(原备库执行)
SQL> ALTER SYSTEM SWITCH LOGFILE;
-
应用归档日志(原主库上执行)
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; --非实时应用日志,此为应用归档日志
-
===================
天行健,君子以自强不息
地势坤,君子以厚德载物
===================