oracle dataguard failover 功能测试

本文通过实操演示了Oracle数据库中Fast-Start Failover的功能。当主数据库以非正常方式关闭时,该功能会自动将备用数据库切换为主数据库。文章详细记录了使用shutdown abort命令触发切换的过程,并展示了相关日志文件的变化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景知识:

fast-start
failover(FSFO)功能是当primary数据库Crash后,它会自动地快速执行切换standby数据库为primary数据库操作。
那么什么时候会触发fast-start failover呢? 当数据库以正常模式(shutdown
immediate/normal/transactional)关闭时,系统不会触发fast-start failover。
使用非正常关闭方式shutdown abort关闭primary时会触发fast-start failover。
这里引入一个新的进程observer,observer是用来监控primary数据库是否可用的,当主库不可用时,会执行快速切换standby数据库为primary数据库。

模仿主节点的故障

数据库版本:11.2.0.4

[oracle@oraprimary ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Sun Sep 10 06:31:55 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown abort;
ORACLE instance shut down.
查看drorcl.log日志
[oracle@oradg trace]$ tail -f drcorcl.log 


FAILOVER TO orcl_dg
Beginning failover to database orcl_dg
Notifying Oracle Clusterware to teardown database for FAILOVER
09/10/2017 06:32:36
Notifying DMON of db close
DMON: Old primary "orcl_prd" needs reinstatement
09/10/2017 06:32:37
Protection mode set to MAXIMUM AVAILABILITY
Deferring associated archivelog destinations of sites permanently disabled due to Failover
Notifying Oracle Clusterware to buildup primary database after FAILOVER
Posting DB_DOWN alert ...
        ... with reason Data Guard Fast-Start Failover - Primary Disconnected
Command FAILOVER TO orcl_dg completed
09/10/2017 06:32:48
Data Guard Broker Status Summary:
  Type                        Name                             Severity  Status
  Configuration               dg                                Warning  ORA-16608
  Primary Database            orcl_dg                           Warning  ORA-16817
  Physical Standby Database   orcl_prd                            Error  ORA-16661

查看observer的日志

DGMGRL> start observer
Observer started

06:32:34.70  Sunday, September 10, 2017
Initiating Fast-Start Failover to database "orcl_dg"...
Performing failover NOW, please wait...
Failover succeeded, new primary is "orcl_dg"
06:32:37.77  Sunday, September 10, 2017

可以看到自动 failover 已经触发

DGMGRL> show configuration

Configuration - dg

  Protection Mode: MaxAvailability
  Databases:
    orcl_dg  - Primary database
      Warning: ORA-16817: unsynchronized fast-start failover configuration

    orcl_prd - (*) Physical standby database (disabled)
      ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: ENABLED

Configuration Status:
WARNING

DGMGRL> 

**因为这里我们只有一主一备,所以数据库报错了!
我们将刚才shutdown abort 的节点给起来**

观察后台的日志 drcorcl.log

Database orcl_prd can be reinstated
09/10/2017 06:35:51
Successfully completed reinstatement of database 0x01001000; removing ReinstateContextArray property
09/10/2017 06:35:53
Command REINSTATE DATABASE orcl_prd completed
EDIT DATABASE orcl_prd SET PROPERTY ActualApplyInstance = orcl
Apply Instance for database orcl_prd is orcl
Command EDIT DATABASE orcl_prd SET PROPERTY ActualApplyInstance = orcl completed

observer 打印的日志

06:34:58.98  Sunday, September 10, 2017
Initiating reinstatement for database "orcl_prd"...
Reinstating database "orcl_prd", please wait...
Operation requires shutdown of instance "orcl" on database "orcl_prd"
Shutting down instance "orcl"...
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "orcl" on database "orcl_prd"
Starting instance "orcl"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "orcl_prd" ...
Reinstatement of database "orcl_prd" succeeded
06:35:53.24  Sunday, September 10, 2017

最后的结果:

DGMGRL> show configuration;

Configuration - dg

  Protection Mode: MaxAvailability
  Databases:
    orcl_dg  - Primary database
    orcl_prd - (*) Physical standby database

Fast-Start Failover: ENABLED

Configuration Status:
SUCCESS

起来之后,数据库自动将刚才的主库设置成了备库,两个库体的角色交换了。看来,dataguard broker应该放在单独的节点才会方便测试。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值