zoukankan      html  css  js  c++  java
  • Oracle DataGuard主备切换(switchover)

    Oracle DataGuard主备切换可以使用传统的手动命令切换,也可以使用dgmgr切换,本文记录手动切换。

    (一)将主库切换为物理备库

    STEP1:查看主库状态

    SQL>  SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE;
    
    OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    FOR DATAGUAR GUARD_S
    -------------------- ---------------- -------------------- --- -------- -------
    READ WRITE           PRIMARY          SESSIONS ACTIVE      YES DISABLED NONE

    注意:需要检查SWITCHOVER_STATUS参数,如果值为"SESSION ACTIVE"或者"TO STANDBY", 则主数据库角色可以切换为备库角色。


    STEP2:将其切换到备库,切换后,数据库会关闭

    SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [WITH SESSION SHUTDOWN];

    注意:如果上一步的SWITCH_STATUS参数值为"TO STANDBY",则 WITH SESSION SHUTDOWN 可以省略。

     

    STEP3:启动到mount状态

    SQL> SHUTDOWN ABORT
    SQL> STARTUP MOUNT

    注意:11.2.0.4版本及其以上版本不需要执行"SHUTDOWN ABORT",因为数据库已经在STEP2命令中关闭了。

    (二) 将备库切换成主库并启动到open
    STEP1:查看备库状态

    SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE;
    
    OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    FOR DATAGUAR GUARD_S
    -------------------- ---------------- -------------------- --- -------- -------
    READ ONLY WITH APPLY PHYSICAL STANDBY TO PRIMARY           YES DISABLED NONE

    注意:需要检查SWITCH_STATUS参数,如果值为"SESSION ACTIVE"或"TO PRIMARY",则备库可以切换为主库。


    STEP2: 切换到主库

    SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY [WITH SESSION SHUTDOWN];

    注意:如果上一步的SWITCH_STATUS参数值为"TO PRIMARY",则 WITH SESSION SHUTDOWN 可以省略。


    STEP3: 此时数据库为mount状态,需打开数据库

    SQL> SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE;
    
    OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    FOR DATAGUAR GUARD_S
    -------------------- ---------------- -------------------- --- -------- -------
    MOUNTED              PRIMARY          NOT ALLOWED          YES DISABLED NONE
    
    SQL> ALTER DATABASE OPEN ;
    
    Database altered.
    
    SQL>  SELECT OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS FROM V$DATABASE;
    
    OPEN_MODE            DATABASE_ROLE    SWITCHOVER_STATUS    FOR DATAGUAR GUARD_S
    -------------------- ---------------- -------------------- --- -------- -------
    READ WRITE           PRIMARY          TO STANDBY           YES DISABLED NONE


    (三)新的备库开启日志应用

    SQL> ALTER DATABASE OPEN;
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

    【完】

    相关文档:
    1.Oracle DataGuard主备切换(switchover)
    2.Oracle Dataguard故障转移(failover)操作
    3.Oracle DataGuard故障转移(failover)后使用RMAN还原失败的主库

  • 相关阅读:
    C# 函数参数object sender, EventArgs e
    Winform中利用委托实现窗体之间的传值
    Web前端学习笔记——Canvas
    js 删除 按钮所在的行
    box-sizing
    前端中关于HTML标签的属性for的理解
    apply和call的用法总结
    target 确定元素是谁??
    css3过渡和动画
    处理两端极限值的小技巧
  • 原文地址:https://www.cnblogs.com/lijiaman/p/13335406.html
Copyright © 2011-2022 走看看