• Oracle-switchover转换DG角色


    switchover 切换过程

    primary库进行switchover切换

    运行切换条件检查(12.1+)

    ALTER DATABASE SWITCHOVER TO <standby db_unique_name> VERIFY;
    

    检查主库状态信息

    主库switchover_status显示 "TO STANDBY",即表示主库此时可以切换为备库

    set lines 168 pages 99
    col name for a18
    col db_unique_name for a18
    col open_mode for a24
    col log_mode for a12
    col database_role for a20
    col host_name for a20
    col flashback_on for a16
    col switchover_status for a28
    
    select name,db_unique_name,open_mode,log_mode,database_role,(select HOST_NAME from v$instance) HOST_NAME,flashback_on,switchover_status from v$database;
    

    手动运行switchover切换

    -- alter database commit to switchover to physical standby with session shutdown; 
       alter database commit to switchover to standby with session shutdown;
    

    此时,数据库关闭

    启动数据库

    startup;
    

    检查数据库状态

    set lines 168 pages 99
    col name for a18
    col db_unique_name for a18
    col open_mode for a24
    col log_mode for a12
    col database_role for a20
    col host_name for a20
    col flashback_on for a16
    col switchover_status for a28
    
    select name,db_unique_name,open_mode,log_mode,database_role,(select HOST_NAME from v$instance) HOST_NAME,flashback_on,switchover_status from v$database;
    

    此时,数据库以PHYSICAL STANDBY角色运行

    standby库进行switchover切换

    检查当前数据库信息

    set lines 168 pages 99
    col name for a18
    col db_unique_name for a18
    col open_mode for a24
    col log_mode for a12
    col database_role for a20
    col host_name for a20
    col flashback_on for a16
    col switchover_status for a28
    
    select name,db_unique_name,open_mode,log_mode,database_role,(select HOST_NAME from v$instance) HOST_NAME,flashback_on,switchover_status from v$database;
    

    确认SWITCHOVER_STATUS 状态为:TO PRIMARY

    手动执行切换

     alter database commit to switchover to primary with session shutdown;
    

    检查数据库状态信息

    set lines 168 pages 99
    col name for a18
    col db_unique_name for a18
    col open_mode for a24
    col log_mode for a12
    col database_role for a20
    col host_name for a20
    col flashback_on for a16
    col switchover_status for a28
    
    select name,db_unique_name,open_mode,log_mode,database_role,(select HOST_NAME from v$instance) HOST_NAME,flashback_on,switchover_status from v$database;
    

    打开数据库

    alter database open;
    

    新备库(即原主库)开始日志应用

     alter database recover managed standby database using current logfile disconnect from session;
    

    检查DG状态

    SELECT CLIENT_PROCESS, PROCESS, THREAD#, SEQUENCE#, STATUS 
    FROM V$MANAGED_STANDBY 
    WHERE CLIENT_PROCESS='LGWR' OR PROCESS='MRP0';
    

    注意事项

    • alter database commit to switchover to physical standby with session shutdown; 等待数据库挂掉(only shutdown abort)后再启动到mount
    • 在 RAC 环境不需要关闭其他的实例,执行 Switchover 的命令会关闭所有的实例
  • 相关阅读:
    Masonry介绍与使用实践:快速上手Autolayout
    iOS:实现图片的无限轮播(二)---之使用第三方库SDCycleScrollView
    FMDB的使用方法
    ViewController的生命周期分析和使用
    使用Xcode7的Instruments检测解决iOS内存泄露
    IOS比较常用的第三方组件及应用源代码(持续更新中)
    SDWebImage的简单使用
    ant编译tomcat-web项目
    git命令记录
    zabbix问题恢复正常,但是图表中还是显示故障存在
  • 原文地址:https://www.cnblogs.com/binliubiao/p/15148538.html
Copyright © 2020-2023  润新知