天天看點

11GR DATAGRUAD環境BROKER配置Fast-Start Failover

 FAST-START failover 就是在當主資料庫出現故障時,能快速與可靠的把standby切換成主資料庫,在整個過程中不需要人來幹預。fast-start failover隻能通過dgmgrl與Enterprise Managerg來配置。

  隻有maximum availability mode or maximum performance mode才能啟用fast-start failover模式。在maximum availability模式下面,在切換時可以保證無資料丢失,在maximum performance mode下面,會有資料丢失,丢失多少資料由 <code>FastStartFailoverLagLimit這個參數來配置。</code>

<code> 隻要observer程序啟動過,我們就不需要人為的</code>幹預。當observer與指定的備資料庫與主資料庫失去連接配接的時間超過<code>FastStartFailoverThreshold後,observer就會啟動fast-start failover 到備資料庫。如果配置了<code>FastStartFailoverPmyShutdown為true,此時原來的主資料庫将會自動的shutdown。如果配置<code>FastStartFailoverAutoReinstate為true,當failover完成後,啟動資料庫時,會自動的執行<code>Reinstate database,把原來的主資料庫變成備庫,并與新主庫進行同步。 </code></code></code></code>

<code>  fast-start failover包含3個過程</code>,如下圖:

<a target="_blank" href="http://blog.51cto.com/attachment/201209/102721516.gif"></a>

測試開始:

   環境:OS REDHAT 5.6 X86_64 ,DB 11.2.0.2

1,DG環境的搭建。

見11GR2 搭建活動的實體DG/DATAGRUAD (READ ONLY模式)

<a href="http://luoping.blog.51cto.com/534596/983952" target="_blank">http://luoping.blog.51cto.com/534596/983952</a>

2,broker的配置

3,配置保護模式與日志傳遞方式

之前已經說了FAST-START FAILOVER隻 maximum availability mode與maximum performance mode

下面我們看一下每一種保護模式對應的日志傳遞方式。

<a target="_blank" href="http://blog.51cto.com/attachment/201209/103432292.png"></a>

3.1修改保護模式:

[oracle@test admin]$ dgmgrl 

DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production 

Copyright (c) 2000, 2009, Oracle. All rights reserved. 

Welcome to DGMGRL, type "help" for information. 

DGMGRL&gt; connect sys/oracle@htz  

Connected. 

#通過help檢視指令的幫忙。 

DGMGRL&gt; help edit 

Edits a configuration, database, or instance 

Syntax: 

  EDIT CONFIGURATION SET PROTECTION MODE AS  

    {MaxProtection|MaxAvailability|MaxPerformance}; 

  EDIT CONFIGURATION SET PROPERTY &lt;property name&gt; = &lt;value&gt;; 

  EDIT DATABASE &lt;database name&gt; SET PROPERTY &lt;property name&gt; = &lt;value&gt;; 

  EDIT DATABASE &lt;database name&gt; RENAME TO &lt;new database name&gt;; 

  EDIT DATABASE &lt;database name&gt; SET STATE = &lt;state&gt; 

    [WITH APPLY INSTANCE = &lt;instance name&gt;]; 

  EDIT INSTANCE &lt;instance name&gt; [ON DATABASE &lt;database name&gt;] 

    SET AUTO PFILE [ = {&lt;initialization file path&gt;|OFF} ]; 

    SET PROPERTY &lt;property name&gt; = &lt;value&gt;; 

  EDIT INSTANCE * ON DATABASE &lt;database name&gt; 

DGMGRL&gt; edit configuration set protection mode as maxavilability; 

Syntax error before or at "maxavilability" 

DGMGRL&gt; show configuration; 

Configuration - htz 

#最大可用的保護模式 

  Protection Mode: MaxAvailability 

  Databases: 

    htzb - Primary database 

    htz  - Physical standby database 

Fast-Start Failover: DISABLED 

Configuration Status: 

SUCCESS 

3.2 修改日志傳遞方式

DGMGRL&gt; edit database htz set property logxptmode=sync; 

Property "logxptmode" updated 

DGMGRL&gt; edit database htzb set property logxptmode=sync; 

DGMGRL&gt; show database htz logxptmode 

  LogXptMode = 'sync' 

DGMGRL&gt; show database htzb logxptmode 

  LogXptMode = 'sync 

4 配置資料庫的flashback

4.1 主庫上面

SQL&gt; select open_mode,database_role,log_mode,flashback_on from v$database; 

OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON 

-------------------- ---------------- ------------ ------------------ 

READ WRITE           PRIMARY          ARCHIVELOG   NO 

#配置flashback 

SQL&gt; alter database flashback on; 

Database altered. 

READ WRITE           PRIMARY          ARCHIVELOG   YES 

#flashback的配置目錄與大小 

SQL&gt; show parameter recovery 

NAME                                 TYPE        VALUE 

------------------------------------ ----------- ------------------------------ 

db_recovery_file_dest                string      /u01/app/oracle/fast_recovery_ 

                                                 area 

db_recovery_file_dest_size           big integer 4032M 

4.2 備庫上面

READ ONLY WITH APPLY PHYSICAL STANDBY ARCHIVELOG   NO 

SQL&gt; recover managed standby database cancel; 

Media recovery complete. 

SQL&gt; recover managed standby database using current logfile disconnect; 

READ ONLY WITH APPLY PHYSICAL STANDBY ARCHIVELOG   YES 

5 配置observer伺服器

5.1 配置tnsnames.ora檔案。

[oracle@test admin]$ cat tnsnames.ora 

HTZB = 

  (DESCRIPTION = 

    (ADDRESS_LIST = 

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.31)(PORT = 1521)) 

    ) 

    (CONNECT_DATA = 

      (SERVER = dedicate) 

      (SERVICE_NAME = htzb) 

  ) 

HTZ = 

      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.30)(PORT = 1521)) 

      (SERVICE_NAME = htz) 

5.2 啟動observer程序

[oracle@test admin]$ dgmgrl sys/oracle@htz "start observer" 

Observer started 

6 配置fast-start failover

DGMGRL&gt; edit database htz set property FastStartFailoverTarget=htzb; 

Property "faststartfailovertarget" updated 

DGMGRL&gt; edit database htzb set property  FastStartFailoverTarget=htz; 

于fst-start failove相關的其它幾個參數:

<code>FastStartFailoverPmyShutdown</code>

<code>FastStartFailoverLagLimit</code>

<code>FastStartFailoverAutoReinstate</code>

<code>ObserverConnectIdentifier</code>

<code>這裡我們都使用預設值;</code>我們來看一下這些值的預設值;

DGMGRL&gt; show configuration verbose; 

    htz  - (*) Physical standby database 

  (*) Fast-Start Failover target 

  Properties: 

    FastStartFailoverThreshold      = '30' 

    OperationTimeout                = '30' 

    FastStartFailoverLagLimit       = '30' 

    CommunicationTimeout            = '180' 

    FastStartFailoverAutoReinstate  = 'TRUE' 

    FastStartFailoverPmyShutdown    = 'TRUE' 

    BystandersFollowRoleChange      = 'ALL' 

Fast-Start Failover: DISABLE

  Threshold:        30 seconds 

  Target:           htz 

  Observer:         test 

  Lag Limit:        30 seconds (not in use) 

  Shutdown Primary: TRUE 

  Auto-reinstate:   TRUE 

<code>7 啟用fast-start failover</code>

DGMGRL&gt; show configuration 

DGMGRL&gt; enable fast_start failover 

Enabled. 

DGMGRL&gt;  

8.測試FAST-START FAILOVER是否生效

Fast-Start Failover: ENABLED 

#原主庫直接shutdown abort; 

SQL&gt; shutdown abort; 

ORACLE instance shut down. 

SQL&gt;  

#observer程序的日志 

19:03:03.93 Friday, September 07, 2012

Initiating Fast-Start Failover to database "htz"...

Performing failover NOW, please wait...

Failover succeeded, new primary is "htz"

19:03:13.24 Friday, September 07, 2012

#提示已經把主切換到htz 

#在htz上面檢視一下 

SQL&gt; select open_mode ,database_role from v$database; 

OPEN_MODE            DATABASE_ROLE 

-------------------- ---------------- 

READ WRITE           PRIMARY 

已經成功

手動啟動原主庫

DGMGRL&gt; show configuration;

Configuration - htz

Protection Mode: MaxAvailability

Databases:

htz - Primary database

Warning: ORA-16817: unsynchronized fast-start failover configuration

htzb - (*) Physical standby database (disabled)

ORA-16661: the standby database needs to be reinstated

Fast-Start Failover: ENABLED

Configuration Status:

WARNING

DGMGRL&gt; connect sys/oracle@htzb

Connected.

DGMGRL&gt; startup

ORACLE instance started.

Database mounted.

ORA-16649: possible failover to another database prevents this database from being opened

#過一分會後我們再檢視一下狀态

DGMGRL&gt; connect sys/oracle@htz

DGMGRL&gt; show configuration

htzb - (*) Physical standby database

SUCCESS

檢視狀态,一切正常。

     本文轉自7343696 51CTO部落格,原文連結:http://blog.51cto.com/luoping/984294,如需轉載請自行聯系原作者