Oracle DataGuard switchover

2013/07/11

Tag.Data Guard,primary,standby,switchover

切换前primary site和standby site状态检查

  • Primary site.

    1. 确认primary site和standby site没有出现日志裂隙(log file gap)

       SQL> select status,gap_status from v$archive_dest_status where dest_id=2;
      
       STATUS    GAP_STATUS
      --------- ------------------------
      VALID NO GAP
    2. 确认primary可以转换成standby角色

       SQL> select switchover_status from v$database;
      
       SWITCHOVER_STATUS
      --------------------
      TO STANDBY

      --注意:

      switchover_status应为to standby/session active/not allowed

      a. to standby 表示可以转换

      b. session active 表示还有活动的session,通过v$session确认活动会话

      c. not allowed 表示不能转换

    3. 查看当前会话数

       SQL> select count(*) from v$session where username is not null;
      
         COUNT(*)
      ----------
      1
    4. 查看primary其他信息

       SQL> select open_mode,protection_mode,protection_level,switchover_status from v$database;
      
       OPEN_MODE            PROTECTION_MODE      PROTECTION_LEVEL     SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      READ WRITE MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE TO STANDBY
  • Standby site.

    1. 查看standby site端switchover状态

       SQL> select switchover_status,database_role from v$database;
      
       SWITCHOVER_STATUS    DATABASE_ROLE
      -------------------- ----------------
      NOT ALLOWED PHYSICAL STANDBY
    2. 确认standby site没有日志应用延迟

       SQL> select delay_mins from v$archive_dest where dest_id=2;
      
       DELAY_MINS
      ----------
      0

      如果有延迟设置.在standby site禁用延迟

       alter database recover managed standby database nodelay;
    3. 查看standby其他信息

       SQL> select open_mode,protection_mode,protection_level,switchover_status from v$database;
      
       OPEN_MODE            PROTECTION_MODE      PROTECTION_LEVEL     SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      READ ONLY WITH APPLY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE NOT ALLOWED
  • 切换

    --注意:

    现将primary将为standby,再将standby升为priamry

    1. primary切到standby

       SQL> select database_role from v$database;
      
       DATABASE_ROLE
      ----------------
      PRIMARY SQL> select open_mode,protection_mode,protection_level,switchover_status from v$database; OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      READ WRITE MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE TO STANDBY SQL> alter database commit to switchover to physical standby; Database altered.

      ========================================

       SQL> shutdown immediate;
      ORA-01092: ORACLE instance terminated. Disconnection forced
      SQL> shutdown immediate;
      ORA-24324: service handle not initialized
      ORA-01041: internal error. hostdef extension doesn't exist
      SQL> select open_mode from v$database;
      ERROR:
      ORA-03114: not connected to ORACLE SQL> exit
      Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
      With the Partitioning, OLAP, Data Mining and Real Application Testing options

      ========================================

       [oracle@TENCENT64 /u]$ sqlplus / as sysdba
      
       SQL*Plus: Release 11.2.0.2.0 Production on Thu Jul 11 19:57:50 2013
      
       Copyright (c) 1982, 2010, Oracle.  All rights reserved.
      
       Connected to an idle instance.
      SQL>

      =========================================

       SQL> startup nomount;
      ORACLE instance started. Total System Global Area 1603411968 bytes
      Fixed Size 2226912 bytes
      Variable Size 503317792 bytes
      Database Buffers 1090519040 bytes
      Redo Buffers 7348224 bytes SQL> alter database mount standby database; Database altered. SQL> alter database recover managed standby database disconnect from session; Database altered. SQL> select database_role from v$database; DATABASE_ROLE
      ----------------
      PHYSICAL STANDBY SQL> select open_mode,protection_mode,protection_level,switchover_status from v$database; OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      MOUNTED MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE TO PRIMARY

      观察alert日志可以发现primary已经成功切换成Physical Standby database

       Thu Jul 11 19:58:56 2013
      Successful mount of redo thread 1, with mount id 3458571643
      Physical Standby Database mounted.
    2. standby切到primary

       SQL> select database_role from v$database;
      
       DATABASE_ROLE
      ----------------
      PHYSICAL STANDBY SQL> select open_mode,protection_mode,protection_level,switchover_status from v$database; OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      READ ONLY WITH APPLY MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE TO PRIMARY SQL> alter database commit to switchover to primary; Database altered. SQL> shutdown immediate;
      ORA-01109: database not open Database dismounted.
      ORACLE instance shut down. SQL> startup;
      ORACLE instance started. Total System Global Area 1603411968 bytes
      Fixed Size 2226912 bytes
      Variable Size 486540576 bytes
      Database Buffers 1107296256 bytes
      Redo Buffers 7348224 bytes
      Database mounted.
      Database opened. SQL> select database_role from v$database; DATABASE_ROLE
      ----------------
      PRIMARY SQL> select open_mode,protection_mode,protection_level,switchover_status from v$database; OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      READ WRITE MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE RESOLVABLE GAP SQL> / OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
      -------------------- -------------------- -------------------- --------------------
      READ WRITE MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE TO STANDBY

      观察alert日志可以发现standby已经成功切换成Primary

       Standby became primary SCN: 1362898
      Switchover: Complete - Database mounted as primary
      Completed: alter database commit to switchover to primary

    最后,修改primary site和standby site的tnsnames.ora

--END--

[Oracle] DataGuard switchover的更多相关文章

  1. 4.1 ORACLE DATAGUARD SWITCHOVER 步骤

    验证主库是否能执行角色转换到备库 原主库执行 SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE; SWITCHOVER_STATUS --------- ...

  2. Oracle Dataguard之switchover

    Oracle Dataguard的角色转换包含两类:Switchover和Failover.Switchover指主备之间角色转换,主库降为备库,备库升级为主库.而failover则是指主库出现问题时 ...

  3. Oracle DataGuard主备切换(switchover)

    Oracle DataGuard主备切换可以使用传统的手动命令切换,也可以使用dgmgr切换,本文记录手动切换. (一)将主库切换为物理备库 STEP1:查看主库状态 SQL> SELECT O ...

  4. Oracle Dataguard之failover

    Oracle Dataguard中,角色转换包含两类:Switchover和Failover.上文<Oracle Dataguard之switchover>中,我们已经谈过了switcho ...

  5. Oracle Dataguard之物理standby的基本配置

    尽管网上有很多Oracle Dataguard的配置教程,但不难发现,很多采用的是rman duplicate这种方法,尽管此种方法较为简便.但在某种程度上,却也误导了初学者,虽说也能配置成功,但只知 ...

  6. Oracle dataguard 正常切换和应急切换

    oracle dataguard提供异地容灾方案,能有效的防止单点故障和提供高可用技术,这里介绍dataguard正常主备切换和应急切换(应急切换模拟主库出现问题无法还原,备库脱离dataguard接 ...

  7. oracle dataguard主从切换

    前言: 众所周知DataGuard一般的切换分成两种,一种是系统正常的情况下的切换这种方式为:switchover是无损切换,不会丢失数据:另外一种方式属于灾难情况下的切换,这种情况下一般主库已经启动 ...

  8. Oracle dataguard failover 实战

    Oracle dataguard  failover 实战 操作步骤 备库: SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINIS ...

  9. Oracle Dataguard故障转移(failover)操作

    注意:故障转移会破坏DG的主从关系,使其变为互不相关的2个数据库,谨慎使用. (一)故障转移操作流程图 (二)故障转移操作流程 备注:以下操作步骤与上面流程图步骤一一对应 STEP1:刷新所有未发送到 ...

随机推荐

  1. 遗传算法 | Java版GA_TSP(我的第一个Java程序)

    嗯哼,第一次写博客,准确说是第一次通过文字的方式记录自己的工作,闲话少叙,技术汪的博客就该直奔技术主题(关于排版问题,会在不断写博客的过程中慢慢学习,先将就着用吧,重在技术嘛~~~). 遗传算法(Ge ...

  2. Hive 表数据的存储和压缩格式

    SerDe * 按行存储 * 按列存储 file_format: : | SEQUENCEFILE 序列化(行存储) | TEXTFILE 文本格式(行存储)- (Default, depending ...

  3. 7.Mongodb安全性流程

    1.安全性流程 2.超级管理员 为了更安全的访问mongodb,需要访问者提供用户名和密码,于是需要在mongodb中创建用户 采用了角色-用户-数据库的安全管理方式 常用系统角色如下: root:只 ...

  4. mybatis异常:There is no getter for property named 'xxx' in 'xxx'

    在使用mybatis查询的时候出现了下面的异常: org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  5. 常用doc 命令

    开始-->运行 regedit 进入注册表补充些: 1. gpedit.msc-----组策略 2. sndrec32-------录音机 3. Nslookup-------IP地址侦测器 4 ...

  6. USACO Section1.3 Prime Cryptarithm 解题报告

    crypt1解题报告 —— icedream61 博客园(转载请注明出处)--------------------------------------------------------------- ...

  7. Ajax异步与JavaScript的一些初浅认识

    向服务器请求数据的技术 有以下五种常用技术用于向服务器请求数据 XMLHttpRequest(XHR) Dynamic script tag insertion(动态脚本标签插入) iframes C ...

  8. Spring+SpringMVC+MyBatis+Redis框架学习笔记

    在Java互联网中,以Spring+Spring MVC+MyBatis (SSM) 作为主流框架. SSM+Redis的结构图 在这种框架系统中: Spring IoC 承担了一个资源管理.整合.即 ...

  9. KMP与循环节相关题目

    HDU 3746 Cyclic Nacklace ( KMP求最小循环节 ) len - nextval[len]即为最小循环节长度. #include <cstdio> #include ...

  10. hadoop +streaming 排序总结

    参考http://blog.csdn.net/baidu_zhongce/article/details/49210787 hadoop用于对key的排序和分桶的设置选项比较多,在公司中主要以KeyF ...