`

Data Guard Broker系列之六:Fast-Start Failover

 
阅读更多

Fast-Start Failover

基本概念

Fast-Start Failover是建立在broker基础上的一个快速故障转换的机制,通过fast-start failover可以自动检测primary的故障,然后自动的failover到预先指定的standby上面,这样可以最大化的减少故障时间,提高数 据库的可用性。


结构

Fast-Start Failover是在broker的基础上再增加了一个单独的observer,用来监控primary和standby数据库的状态,一旦primary不可用,observer就会自动的切换到指定的standby上面。


准备工作

  1. 确保broker配置为运行在Max Availability模式。
  2. 在primary和standby机器上都启用flashback database,这个在reinstate failed的数据库的时候要用。
  3. 在运行observer的机器上安装DGMGRL工具,用于启动observer。
  4. 配置tnsname.ora文件,保证observer能正常的连接到primary和standby数据库上面。

配置及启用Fast-Start Failover

在满足上面的条件之后在经过下面少许的配置就可以启用Fast-Start Failover了。

    1. 配置每个数据库Failover的目标,这一步是决定当数据库出问题之后会自动failover到那个standby。
-- 配置torcla failover的目标
edit database torcla set property 'FastStartFailoverTarget'='torclb';
-- 配置torclb failover的目标
edit database torclb set property'FastStartFailoverTarget'='torcla';
    1. 设定FastStartFailoverThreshold值,这个设置是决定了primary坏了多长时间之后会执行自动的failover操作,这里我们设置的是30s。
EDIT CONFIGURATION SET PROPERTY FastStartFailoverThreshold = 30;
    1. 启用Fast-Start Failover。
DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.
    1. 启动observer。
oracle@orainst[torcla]:~
$
dgmgrl sys/12345@torcla.mycompany
DGMGRLforLinux: Version10.2.0.2.0 - Production
 
Copyright(c)2000, 2005, Oracle. All rights reserved.
 
Welcome to DGMGRL, type"help" for information.
Connected.
DGMGRL> start observer;
observer started
    1. 现在可以看看我们环境的状态了。
DGMGRL> show configuration verbose
 
Configuration
 
Name:                FSF
 
Enabled:             YES
 
ProtectionMode:     MaxAvailability
 
Fast-Start Failover: ENABLED
 
Databases:
    
torcla - Primary database
    
torclb - Physical standby database
          -
Fast-Start Failover target
 
Fast-Start Failover
 
Threshold: 30 seconds
 
observerorainst.desktop.mycompany.com
 
Currentstatusfor"FSF":
SUCCESS

Fast-Start Failover的管理

Fast-Start Failover的工作过程

在启用了fast-start failover和observer之后,broker会来监控primary和standby数据库的状态,一旦primary数据库出现故障,observer会根据一定的程序来执行自动的failover操作。

  1. 当发生下列情形是observer会尝试启动failover操作
    • observer和primary数据库之间连接出现故障时
    • 当primary数据库故障或者是RAC环境中所有instance都故障时
    • 执行SHUTDOWN ABORT之后,特别注意正常的SHUTDOWN操作(NORMAL,IMMEDIATE,TRANSACTIONAL)不会引发failover操作
    • 数据库文件OFFLINE

      除了最后一个数据库文件OFFLINE的情形,其他的情况下observer都会尝试在FastStartFailoverThreshold制定的时间之内重新连接数据库,如果还是无法连接之后才会执行自动failover操作。

  2. 在FastStartFailoverThreshold指定的时间内重新连接数据库,在RAC环境中会尝试连接其他的instance。
  3. 尝试时间结束后,observer将确定目标standby可用。下面的这些情形会导致failover失败
    • fast-start failover没有启用
    • observer无法连接到standby数据库
    • standby与observer中记录的状态不一致
    • observer在primary fail的时候正好没有运行,再次启动之后只能找到一个standby
    • 目标standby没有和primary完成同步
    • 目标standby是逻辑standby时,在V$DATABASE中显示LOADING DICTIONARY时
    • 目标standby还能和primary正常通讯时
    • 在V$DATABASE的列FS_FAILOVER_STATUS中显示了其他无法进行failover操作时
    • 有手工failover正在进行时
  4. 执行failover操作,使目标standby变成新的primary。
  5. reinstate之前失败的primary

下面来个实际的failover例子.

先看看当前的primary,确定是torcla

DGMGRL> show configuration
 
Configuration
 
Name:                FSF
 
Enabled:             YES
 
ProtectionMode:     MaxAvailability
 
Fast-StartFailover: ENABLED
 
Databases:
    
torcla - Primary database
    
torclb - Physical standby database
          -
Fast-Start Failovertarget
 
Current status for "FSF":
SUCCESS

然后登录到torcla上,执行一个SHUTDOWN ABORT命令

SYS@torcla> shutdown abort
ORACLE instance shutdown.

然后在observer里面我们可以看到自动failover了

DGMGRL> start observer;
observer started
 
06:08:24.47  Tuesday, September01, 2009
Initiating fast-start failover to database "torclb"...
Performing failover NOW, pleasewait...
Failover succeeded, new primary is "torclb"
06:08:33.49  Tuesday, September 01, 2009

再看此时的状态,primary已经换成torclb了,不过此时torcla是不可用的

DGMGRL> show configuration
Configuration
 
Name:                FSF
 
Enabled:             YES
 
ProtectionMode:     MaxAvailability
 
Fast-Start Failover: ENABLED
 
Databases:
    
torcla - Physical standby database(disabled)
          -
Fast-Start Failovertarget
    
torclb - Primary database

Current status for "FSF":
Warning: ORA-16608: one or more databases have warnings

再将torcla启动到mount,接着就能看到observer会自动的reinstate torcla

DGMGRL> start observer;
observer started
 
06:11:13.45  Tuesday, September 01, 2009
Initiating reinstatement for database "torcla"...
Reinstating database "torcla", please wait...
Operation requires shutdown of instance "torcla" on database "torcla"
Shutting down instance "torcla"...
ORA-01109: database not open
 
Database dismounted.
ORACLE instance shutdown.
Operation requires startup of instance "torcla" on database "torcla"
Starting instance "torcla"...
ORACLE instance started.
Database mounted.
Continuing to reinstate database "torcla" ...
Reinstatement of database "torcla" succeeded
06:12:20.07  Tuesday, September01, 2009

查看Fast-Start Failover状态

通过SHOW CONFIGURATION VERBOSE命令可以查看Fast-Start Failover的基本运行状态

DGMGRL> SHOW CONFIGURATION VERBOSE
 
Configuration
 
Name:                FSF
 
Enabled:             YES
 
ProtectionMode:     MaxAvailability
 
Fast-Start Failover: ENABLED
 
Databases:
    
torcla - Primary database
    
torclb - Physical standby database
          -
Fast-Start Failover target
 
Fast-Start Failover
 
Threshold: 30 seconds
 
observerorainst.desktop.mycompany.com
 
Currentstatusfor"FSF":
SUCCESS

要查看Fast-Start Failover更多的信息就要查看V$DATABASE视图中的相关的列了。

FS_FAILOVER_STATUS
这个列显示了Fast-Start Failover的状态,通过查看这个列我们可以知道数据库时处于什么状态之中,详细的状态信息在这里
FS_FAILOVER_CURRENT_TARGET
当前数据库的failover的目标数据库
FS_FAILOVER_THRESHOLD
执行自动failover的时间超时值
FS_FAILOVER_observer_PRESENT
是否启动了observer,通过查看这个列我们可以知道是否有observer在监控着这个数据库
FS_FAILOVER_observer_HOST
监控此数据库的observer所在的位置
SYS@torclb> col FS_FAILOVER_STATUS for a25
SYS@torclb> col FS_FAILOVER_CURRENT_TARGET for a10
SYS@torclb> col FS_FAILOVER_THRESHOLD for 999
SYS@torclb> col FS_FAILOVER_observer_PRESENT for a4
SYS@torclb> col FS_FAILOVER_observer_HOST for a30
SYS@torclb> select FS_FAILOVER_STATUS,FS_FAILOVER_CURRENT_TARGET,
FS_FAILOVER_THRESHOLD,FS_FAILOVER_observer_PRESENT,
FS_FAILOVER_observer_HOST fromv$database;
 
FS_FAILOVER_STATUS        FS_FAILOVER_CURRENT_TARGET FS_FAILOVER_THRESHOLD  FS_FAILOVER_observer_PRESENT FS_FAILOVER_observer_HOST
-----------------------
-- ---------- --------------------- ---- ------------------------------
SYNCHRONIZED              torclb                         30 YES  orainst.desktop.mycompany.com

禁用Fast-Start Failover

禁用Fast-Start Failover的命令为

DISABLE FAST_START FAILOVER  [FORCE]

加上FORCE之后将会强行在执行DISABLE命令的数据库以及这个数据库可连通的其他数据库上面上禁用Fast-Start Failover,而其他无法连接上的数据库将保持原来的状态;不加FROCE时如果有那个数据库暂时无法连接的话那么DISABLE操作将会失败。所以 在当primary和standby数据库的网络连接良好的情况下要使用不带FORCE的命令。

通常需要使用FORCE的情形

  • 当因为网络问题造成primary无法和observer及那些已完成同步的standby通讯时,primary将会停止工作,如果 primary的恢复时间可期,且想要primary继续工作的话就需要使用FORCE选项暂时在primary上禁用fast-start failover,不过之前一定要检查看数据库有没有自动failover。
  • 当primary和standby没有完成同步的时候想要手工的执行failover的命令,在fast-start failover启用的时候是无法执行的,这时候也需要使用FORCE选项强行禁用fast-start failover。
  • 在fast-start failover失败之后还想将数据库failover到其他可用的standby上时也需要先使用FORCE强制禁用fast-start failover然后在手工进行failover操作。
  • 如果确定有问题的primary可以很快的恢复,此时不想让fast-start failover自动failover,也可以使用FORCE选项强行禁用fast-start failover。

Observer管理

启用observer的操作很简单,使用DGMGRL连接到数据库,然后执行START OBSERVER命令就行了。

要启动observer的话必须使用SYS连接到DGMGRL,同一时间只能启动一个observer,如果尝试启动多个observer将会收到这样的消息

ORA-16647: could not start more than one observer

要停止一个observer的话只需要用DGMGRL连接到数据库,然后执行STOP OBSERVER命令就行了。

要确定一个数据库是否在observer的监视中必须要去查看V$DATABASE视图中的 FS_FAILOVER_OBSERVER_PRESENT和FS_FAILOVER_OBSERVER_HOST。只有当 FS_FAILOVER_OBSERVER_PRESENT为YES的时候才说明这个数据库时处于observer的监控之中。

同时数据库是否有observer监视这个信息我们也可以从DGMGRL中查看到

DGMGRL> show database torcla statusreport
STATUSREPORT
      
INSTANCE_NAME   SEVERITY ERROR_TEXT
                   *     
ERRORORA-16820: Fast-Start Failover observer is no longer observing this database

在启动observer的时候,observer会自动的在当前目录中生成一个默认名字为fsfo.dat的二进制文件,这个文件里面保存了 fast-start failover的配置信息,同时也包含了到primary和standby的连接方式。也可以在启动observer的时候使用FILE参数指定配置文 件的位置,命令如下

START OBSERVER [FILE=<observer configuration file>];

参考至:http://www.dbabeta.com/2009/learn-data-guard-broker_fast-start-failover.html

如有错误,欢迎指正

邮箱:czmcj@163.com

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics