Oracle 11g DG手工switchover切换标准化流程

环境:RHEL 6.5 + Oracle GI 11.2.0.4 + Oracle DB 11.2.0.4

Primary RAC(2 nodes) + Standby RAC(2 nodes)

Oracle DG切换类型有两种:switchover和failover。对于switchover而言,是计划内的由DBA主动去执行的操作,所以它的操作步骤一定是可以形成标准化流程的。

本文就在我的实验环境下做一次基本的标准化switchover流程:

准备工作

切换前准备:最好可以先关闭主备库RAC的其他节点

我这里是分别关闭主备库的第二个节点:

PRIMARY NODE2'Instance
[grid@jyrac2 ~]$ srvctl stop instance -d jyzhao -i jyzhao2 STANDBY NODE2'Instance
[grid@jystdrac2 ~]$ srvctl stop instance -d mynas -i jyzhao2

当然也可以SQLplus操作关闭其他节点的实例.

注:如果不关闭,正常切换时也会自动被关闭。只是为了防止某些环境有其他问题,手工先关闭其他实例可以方便排查。

1.主库切换为备库

**1.主库切换为备库:**

ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN;

观察主库alert日志:

Sun Aug 13 09:54:53 2017
alter database commit to switchover to standby with session shutdown
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY [Process Id: 13741] (jyzhao1)
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
Waiting for all FAL entries to be archived...
All FAL entries have been archived.
Waiting for potential Physical Standby switchover target to become synchronized...
Active, synchronized Physical Standby switchover target has been identified
Sun Aug 13 09:54:56 2017
Errors in file /opt/app/oracle/diag/rdbms/jyzhao/jyzhao1/trace/jyzhao1_j000_29834.trc:
ORA-12012: error on auto execute of job 3
ORA-16456: switchover to standby in progress or completed
Switchover End-Of-Redo Log thread 1 sequence 182 has been fixed
Switchover: Primary highest seen SCN set to 0x0.0x456df2
ARCH: Noswitch archival of thread 1, sequence 182
ARCH: End-Of-Redo Branch archival of thread 1 sequence 182
ARCH: LGWR is actively archiving destination LOG_ARCHIVE_DEST_2
ARCH: Standby redo logfile selected for thread 1 sequence 182 for destination LOG_ARCHIVE_DEST_2
Archived Log entry 411 added for thread 1 sequence 182 ID 0x958da9ee dest 1:
ARCH: Archiving is disabled due to current logfile archival
Primary will check for some target standby to have received alls redo
Final check for a synchronized target standby. Check will be made once.
Sun Aug 13 09:54:59 2017
Process (ospid 4297) is suspended due to switchover to physical standby operation.
LOG_ARCHIVE_DEST_2 is a potential Physical Standby switchover target
Active, synchronized target has been identified
Target has also received all redo
Backup controlfile written to trace file /opt/app/oracle/diag/rdbms/jyzhao/jyzhao1/trace/jyzhao1_ora_13741.trc
Clearing standby activation ID 2509089262 (0x958da9ee)
The primary database controlfile was created using the
'MAXLOGFILES 192' clause.
There is space for up to 188 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl5.f' SIZE 52428800;
Archivelog for thread 1 sequence 182 required for standby recovery
Switchover: Primary controlfile converted to standby controlfile succesfully.
Switchover: Complete - Database shutdown required
USER (ospid: 13741): terminating the instance
Sun Aug 13 09:55:00 2017
ORA-1092 : opitsk aborting process
Instance terminated by USER, pid = 13741
Completed: alter database commit to switchover to standby with session shutdown
Shutting down instance (abort)
License high water mark = 11
Sun Aug 13 09:55:01 2017
Instance shutdown complete

主要注意到正常应该有“End-Of-Redo Branch archival”字样,并且最终成功切换到standby,最后数据库是关闭的。

2.备库切换为主库

操作之前,可以看alert日志,也可以使用SQL查询是否可以切换:
```
select OPEN_MODE, DATABASE_ROLE, SWITCHOVER_STATUS, FORCE_LOGGING, DATAGUARD_BROKER, GUARD_STATUS from v$database;
```

**2.备库切换为主库: **

ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;

如果因为活动会话无法关闭可以考虑加上with session shutdown选项。

查看备库alert日志:

Sun Aug 13 09:58:30 2017
alter database commit to switchover to primary
ALTER DATABASE SWITCHOVER TO PRIMARY (jyzhao1)
Maximum wait for role transition is 15 minutes.
Switchover: Media recovery is still active
Role Change: Canceling MRP - no more redo to apply
Sun Aug 13 09:58:31 2017
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /opt/app/oracle/diag/rdbms/mynas/jyzhao1/trace/jyzhao1_mrp0_7745.trc:
ORA-16037: user requested cancel of managed recovery operation
Sun Aug 13 09:58:31 2017
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
MRP0: Background Media Recovery process shutdown (jyzhao1)
Role Change: Canceled MRP
All dispatchers and shared servers shutdown
CLOSE: killing server sessions.
CLOSE: all sessions shutdown successfully.
Sun Aug 13 09:58:34 2017
SMON: disabling cache recovery
Backup controlfile written to trace file /opt/app/oracle/diag/rdbms/mynas/jyzhao1/trace/jyzhao1_ora_7669.trc
SwitchOver after complete recovery through change 4550130
Online log +DATA/mynas/onlinelog/group_1.266.951608731: Thread 1 Group 1 was previously cleared
Online log +FRA/mynas/onlinelog/group_1.257.951608737: Thread 1 Group 1 was previously cleared
Online log +DATA/mynas/onlinelog/group_2.267.951608745: Thread 1 Group 2 was previously cleared
Online log +FRA/mynas/onlinelog/group_2.258.951608751: Thread 1 Group 2 was previously cleared
Online log +DATA/mynas/onlinelog/group_3.268.951608757: Thread 2 Group 3 was previously cleared
Online log +FRA/mynas/onlinelog/group_3.259.951608763: Thread 2 Group 3 was previously cleared
Online log +DATA/mynas/onlinelog/group_4.269.951608769: Thread 2 Group 4 was previously cleared
Online log +FRA/mynas/onlinelog/group_4.260.951608775: Thread 2 Group 4 was previously cleared
Standby became primary SCN: 4550128
AUDIT_TRAIL initialization parameter is changed back to its original value as specified in the parameter file.
Switchover: Complete - Database mounted as primary
Completed: alter database commit to switchover to primary
Sun Aug 13 09:59:07 2017
ARC1: Becoming the 'no SRL' ARCH

最后注意到备库成功切换到主库,启动到mount状态。

3.新主库open,新备库启动并开启MRP

上面已经完成了切换,这一步只是把新主库open,新备库启动并开启MRP:

--NEW PRIMARY:
ALTER DATABASE OPEN; --NEW STANDBY:
STARTUP
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

4.确定同步正常,启动其他节点

确定同步正常,启动其他节点:

PRIMARY NODE2'Instance
[grid@jyrac2 ~]$ srvctl start instance -d jyzhao -i jyzhao2 STANDBY NODE2'Instance
[grid@jystdrac2 ~]$ srvctl start instance -d mynas -i jyzhao2

至此,完成Oracle 11g标准化switchover切换操作。

我这里发现一个小问题,就是切换后发现无法实时同步,最终发现是备库的配置还是ARCH:

log_archive_dest_2                   string      SERVICE=jyzhao ARCH VALID_FOR=
(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=jyzhao

修改备库的配置,去掉ARCH,也就是使用LGWR传输即可:

alter SYSTEM SET log_archive_dest_2 = 'SERVICE=jyzhao VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jyzhao' sid='*' SCOPE=BOTH;

关于使用这两种方式传输日志的区别可参考《ARCH和LGWR进程同步DG日志的区别》。

Oracle 11g DG手工switchover切换标准化流程的更多相关文章

  1. 【DATAGUARD】物理dg的switchover切换(五)

    [DATAGUARD]物理dg的switchover切换(五) 一.1  BLOG文档结构图 一.2  前言部分 一.2.1  导读 各位技术爱好者,看完本文后,你可以掌握如下的技能,也可以学到一些其 ...

  2. 【Oracle】DG中 Switchover 主、备切换

    操作系统:OEL 5.6 数据库版本:Oracle11gR2  11.2.0.4.0 Switchover切换要求主库和备库在数据同步情况下进行,是主备之间的正常切换,主要用于日常维护.灾备演练等.切 ...

  3. RHEL6.4 + Oracle 11g DG测试环境快速搭建参考

    环境现状: 两台虚拟主机A和B: 1. A机器已安装ASM存储的Oracle 11g 实例      参考:http://www.cnblogs.com/jyzhao/p/4332410.html 2 ...

  4. Oracle 11g DG配置简明版

    环境: 主库A机:在线生产环境,RHEL 6.4 + Oracle 11.2.0.3 备库B机:新增备机,RHEL 6.4 需求: 对生产环境最小影响前提下配置DG备库. 目录: 一.B机安装相同版本 ...

  5. Oracle 11g AMM与ASMM切换

    现在的Oracle正在往智能化方向发展.如果我们现在找一些8i/9i时代的Oracle书籍,怎么样配置合适的数据库各内存池大小是非常重要的话题.但是进入10g之后,自动内存池调节成为一个重要Oracl ...

  6. DG中switchover切换操作

    问题描述:我们配置DG的目的就是为了在主库出现故障时,备库能够提供服务,保证业务的正常运行,switchover是用户有计划的进行停机切换,能够保证不丢失数据,我记录一下我进行switchover中的 ...

  7. DG的Switchover切换

    用户可以使用角色管理服务,进行主.备库的计划中的角色切换,这个叫switchover,或者是非计划中的角色切换,叫failover. 目的:实现主库(orcl)和从库(standby)的切换 主库参数 ...

  8. oracle 11g physical standby switchover

    简介 SWITCHOVERS主要是在计划停机维护时用来降低DOWNTIME,如硬件维护.操作系统升级或是数据库rolling upgrade, 也可用来进行特殊情况下的数据库迁移. SWITCHOVE ...

  9. oracle 11g dbms_workload_repository手工管理AWR快照,基线

    1.修改快照设置[sql] view plain copysys@ORCL> select * from dba_hist_wr_control; DBID SNAP_INTERVAL RETE ...

随机推荐

  1. vue 基础-->进阶 教程(3):组件嵌套、组件之间的通信、路由机制

    前面的nodejs教程并没有停止更新,因为node项目需要用vue来实现界面部分,所以先插入一个vue教程,以免不会的同学不能很好的完成项目. 本教程,将从零开始,教给大家vue的基础.高级操作.组件 ...

  2. windows上将代码上传到Github

    Repository name: 仓库名称 Description(可选): 仓库描述介绍 Public, Private : 仓库权限(公开共享,私有或指定合作者) Initialize this ...

  3. scrollMenu,一款可滚动的菜单插件 兼容pc和移动端

    这个菜单 有两种样式  , 也可以通过animate.css加不同的动画效果!滚动的方式也有两种   一种为通用的overflow,另外一种是better-scroll的滚动效果 在线链接地址  ht ...

  4. ASP.NET Core MVC 控制器创建与依赖注入

    本文翻译自<Controller activation and dependency injection in ASP.NET Core MVC>,由于水平有限,故无法保证翻译完全准确,欢 ...

  5. 使用C#创建Windows服务

    本文属于原创,转载请注明出处,谢谢! 一.开发环境 操作系统:Windows 10 X64 开发环境:VS2015 编程语言:C# .NET版本:.NET Framework 4.0 目标平台:X86 ...

  6. 【SqlServer系列】开启Sqlserver远程访问

    1   概述 已发布[SqlServer系列]文章如下: [SqlServer系列]SQLSERVER安装教程 [SqlServer系列]数据库三大范式 [SqlServer系列]表单查询 [SqlS ...

  7. 【一步一步】Spring 源码环境搭建

    平时项目中基本上都会用到spring,但是源码还没有深入的了解过.趁这段时间稍微空闲点,开始研究下spring 源码.下面是spring 源码的环境搭建. 主要分为如下步骤: ①安装jdk,gradl ...

  8. 操作系统,银行家算法模拟实现(Windows 环境 C++)

    计算机操作系统课设需要,写了两个下午的银行家算法(陷在bug里出不来耽误了很多时间),参考计算机操作系统(汤子瀛) 实现过程中不涉及难度较大的算法,仅根据银行家算法的思想和步骤进行实现.以下为详细步骤 ...

  9. 【JAVASCRIPT】React学习- 杂七杂八

    摘要 记录 React 学习中的小细节 setState setState 有一定的时间延迟,如果需要保证 setState 之后执行某些动作,可以采用以下方法 this.setState({ vis ...

  10. Redis作为消息队列服务场景应用案例(入队和出队)

    http://www.cnblogs.com/leo_wl/p/3831349.html