oracle dataguard failover 功能測試

背景知識:

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應該放在單獨的節點纔會方便測試。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章