zoukankan      html  css  js  c++  java
  • 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 的命令会关闭所有的实例
  • 相关阅读:
    二项分布和多项分布
    TF-IDF学习笔记(二)
    TF-IDF学习笔记(一)
    jieba中文分词
    爬虫利器3:Xpath语法与lxml库
    Python爬虫利器1:Requests库的用法
    Python爬虫实战一之爬取糗事百科段子
    Python中的逻辑运算符
    Python:闭包函数与装饰器
    Python:函数名称空间与作用域:
  • 原文地址:https://www.cnblogs.com/binliubiao/p/15148538.html
Copyright © 2011-2022 走看看