ORACLE DATAGUARD SWITCHOVER 步骤

  1. 验证主库是否能执行角色转换到备库 原主库执行

    SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
    SWITCHOVER_STATUS
    -----------------
    TO STANDBY
    1 row selected
    
  2. 开始把物理主库改变为物理备库 在原主库执行。

    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错误,也可以杀掉活动会话或等活动会话后进行转换.
  3. 关闭并重启主库(原主库执行)

    SQL> SHUTDOWN IMMEDIATE;
    SQL> STARTUP MOUNT;
    
  4. 验证备库是否能执行角色转换到主库(原备库执行)

    SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
    SWITCHOVER_STATUS
    -----------------
    TO_PRIMARY
    1 row selected
    
  5. 开始把物理备库转换成物理主库(原备库执行)

    SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
    

    如果报ORA-16139: media recovery required,可能是由于未应用日志引起,可先执行 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

  6. 打开备库,然后关闭重启.(原备库执行)

    SQL> ALTER DATABASE OPEN;
    SQL> SHUTDOWN IMMEDIATE;
    SQL> STARTUP;
    
    1. 验证是否转换成功(原备库执行)

      SQL> ALTER SYSTEM SWITCH LOGFILE;
      
    2. 应用归档日志(原主库上执行)

      ALTER  DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION; --非实时应用日志,此为应用归档日志
posted @ 2019-04-01 21:26  halberd.lee  阅读(374)  评论(0编辑  收藏  举报