当前位置: 首页 > DG > 正文

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下面,会有数据丢失,丢失多少数据由 FastStartFailoverLagLimit这个参数来配置。

只要observer进程启动过,我们就不需要人为的干预。当observer与指定的备数据库与主数据库失去连接的时间超过FastStartFailoverThreshold后,observer就会启动fast-start failover 到备数据库。如果配置了FastStartFailoverPmyShutdown为true,此时原来的主数据库将会自动的shutdown。如果配置FastStartFailoverAutoReinstate为true,当failover完成后,启动数据库时,会自动的执行Reinstate database,把原来的主数据库变成备库,并与新主库进行同步。

  fast-start failover包含3个过程,如下图:

 

测试开始:

   环境:OS REDHAT 5.6 X86_64 ,DB 11.2.0.2

1,DG环境的搭建。

见11GR2 搭建活动的物理DG/DATAGRUAD (READ ONLY模式)

2,broker的配置

3,配置保护模式与日志传递方式

之前已经说了FAST-START FAILOVER只 maximum availability mode与maximum performance mode

下面我们看一下每一种保护模式对应的日志传递方式。

 

3.1修改保护模式:

  1. [oracle@test admin]$ dgmgrl
  2. DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production
  3.  
  4. Copyright (c) 2000, 2009, Oracle. All rights reserved.
  5.  
  6. Welcome to DGMGRL, type "help" for information.
  7. DGMGRL> connect sys/oracle@htz 
  8. Connected.
  9. #通过help查看命令的帮忙。
  10. DGMGRL> help edit
  11. Edits a configuration, database, or instance
  12. Syntax:
  13.  
  14.   EDIT CONFIGURATION SET PROTECTION MODE AS 
  15.     {MaxProtection|MaxAvailability|MaxPerformance};
  16.  
  17.   EDIT CONFIGURATION SET PROPERTY <property name> = <value>;
  18.  
  19.   EDIT DATABASE <database name> SET PROPERTY <property name> = <value>;
  20.  
  21.   EDIT DATABASE <database name> RENAME TO <new database name>;
  22.  
  23.   EDIT DATABASE <database name> SET STATE = <state>
  24.     [WITH APPLY INSTANCE = <instance name>];
  25.  
  26.   EDIT INSTANCE <instance name> [ON DATABASE <database name>]
  27.     SET AUTO PFILE [ = {<initialization file path>|OFF} ];
  28.  
  29.   EDIT INSTANCE <instance name> [ON DATABASE <database name>]
  30.     SET PROPERTY <property name> = <value>;
  31.  
  32.   EDIT INSTANCE * ON DATABASE <database name>
  33.     SET PROPERTY <property name> = <value>;
  34.  
  35. DGMGRL> edit configuration set protection mode as maxavilability;
  36. Syntax error before or at "maxavilability"
  37. DGMGRL> show configuration;
  38.  
  39. Configuration - htz
  40. #最大可用的保护模式
  41.   Protection Mode: MaxAvailability
  42.   Databases:
  43.     htzb - Primary database
  44.     htz  - Physical standby database
  45. Fast-Start Failover: DISABLED
  46. Configuration Status:
  47. SUCCESS

3.2 修改日志传递方式

  1. DGMGRL> edit database htz set property logxptmode=sync;
  2. Property "logxptmode" updated
  3. DGMGRL> edit database htzb set property logxptmode=sync;
  4. Property "logxptmode" updated
  5. DGMGRL> show database htz logxptmode
  6.   LogXptMode = 'sync'
  7. DGMGRL> show database htzb logxptmode
  8.   LogXptMode = 'sync

4 配置数据库的flashback

4.1 主库上面

  1. SQL> select open_mode,database_role,log_mode,flashback_on from v$database;
  2.  
  3. OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON
  4. -------------------- ---------------- ------------ ------------------
  5. READ WRITE           PRIMARY          ARCHIVELOG   NO
  6. #配置flashback
  7. SQL> alter database flashback on;
  8.  
  9. Database altered.
  10.  
  11. SQL> select open_mode,database_role,log_mode,flashback_on from v$database;
  12.  
  13. OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON
  14. -------------------- ---------------- ------------ ------------------
  15. READ WRITE           PRIMARY          ARCHIVELOG   YES
  16. #flashback的配置目录与大小
  17. SQL> show parameter recovery
  18.  
  19. NAME                                 TYPE        VALUE
  20. ------------------------------------ ----------- ------------------------------
  21. db_recovery_file_dest                string      /u01/app/oracle/fast_recovery_
  22.                                                  area
  23. db_recovery_file_dest_size           big integer 4032M

4.2 备库上面

  1. SQL> select open_mode,database_role,log_mode,flashback_on from v$database;
  2.  
  3. OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON
  4. -------------------- ---------------- ------------ ------------------
  5. READ ONLY WITH APPLY PHYSICAL STANDBY ARCHIVELOG   NO
  6.  
  7. SQL> recover managed standby database cancel;
  8. Media recovery complete.
  9. SQL> alter database flashback on;
  10.  
  11. Database altered.
  12.  
  13. SQL> recover managed standby database using current logfile disconnect;
  14. Media recovery complete.
  15. SQL> select open_mode,database_role,log_mode,flashback_on from v$database;
  16.  
  17. OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON
  18. -------------------- ---------------- ------------ ------------------
  19. READ ONLY WITH APPLY PHYSICAL STANDBY ARCHIVELOG   YES

5 配置observer服务器

5.1 配置tnsnames.ora文件。

  1. [oracle@test admin]$ cat tnsnames.ora
  2. HTZB =
  3.   (DESCRIPTION =
  4.     (ADDRESS_LIST =
  5.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.31)(PORT = 1521))
  6.     )
  7.     (CONNECT_DATA =
  8.       (SERVER = dedicate)
  9.       (SERVICE_NAME = htzb)
  10.     )
  11.   )
  12.  
  13. HTZ =
  14.   (DESCRIPTION =
  15.     (ADDRESS_LIST =
  16.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.30)(PORT = 1521))
  17.     )
  18.     (CONNECT_DATA =
  19.       (SERVER = dedicate)
  20.       (SERVICE_NAME = htz)
  21.     )
  22.   )

5.2 启动observer进程

  1. [oracle@test admin]$ dgmgrl sys/oracle@htz "start observer"
  2. DGMGRL for Linux: Version 11.2.0.2.0 - 64bit Production
  3.  
  4. Copyright (c) 2000, 2009, Oracle. All rights reserved.
  5.  
  6. Welcome to DGMGRL, type "help" for information.
  7. Connected.
  8. Observer started

6 配置fast-start failover

  1. DGMGRL> edit database htz set property FastStartFailoverTarget=htzb;
  2. Property "faststartfailovertarget" updated
  3. DGMGRL> edit database htzb set property  FastStartFailoverTarget=htz;
  4. Property "faststartfailovertarget" updated

于fst-start failove相关的其它几个参数:

FastStartFailoverPmyShutdown

FastStartFailoverLagLimit

FastStartFailoverAutoReinstate

ObserverConnectIdentifier

这里我们都使用默认值;我们来看一下这些值的默认值;

  1. DGMGRL> show configuration verbose;
  2.  
  3. Configuration - htz
  4.  
  5.   Protection Mode: MaxAvailability
  6.   Databases:
  7.     htzb - Primary database
  8.     htz  - (*) Physical standby database
  9.  
  10.   (*) Fast-Start Failover target
  11.  
  12.   Properties:
  13.     FastStartFailoverThreshold      = '30'
  14.     OperationTimeout                = '30'
  15.     FastStartFailoverLagLimit       = '30'
  16.     CommunicationTimeout            = '180'
  17.     FastStartFailoverAutoReinstate  = 'TRUE'
  18.     FastStartFailoverPmyShutdown    = 'TRUE'
  19.     BystandersFollowRoleChange      = 'ALL'
  20.  
  21. Fast-Start Failover: DISABLE
  22.  
  23.   Threshold:        30 seconds
  24.   Target:           htz
  25.   Observer:         test
  26.   Lag Limit:        30 seconds (not in use)
  27.   Shutdown Primary: TRUE
  28.   Auto-reinstate:   TRUE
  29.  
  30. Configuration Status:
  31. SUCCESS

7 启用fast-start failover

  1. DGMGRL> show configuration
  2.  
  3. Configuration - htz
  4.  
  5.   Protection Mode: MaxAvailability
  6.   Databases:
  7.     htzb - Primary database
  8.     htz  - Physical standby database
  9.  
  10. Fast-Start Failover: DISABLED
  11.  
  12. Configuration Status:
  13. SUCCESS
  14. DGMGRL> enable fast_start failover
  15. Enabled.
  16. DGMGRL> 

8.测试FAST-START FAILOVER是否生效

  1. DGMGRL> show configuration
  2.  
  3. Configuration - htz
  4.  
  5.   Protection Mode: MaxAvailability
  6.   Databases:
  7.     htzb - Primary database
  8.     htz  - (*) Physical standby database
  9. Fast-Start Failover: ENABLED
  10. Configuration Status:
  11. SUCCESS
  12. #原主库直接shutdown abort;
  13. SQL> shutdown abort;
  14. ORACLE instance shut down.
  15. SQL> 
  16. #observer进程的日志
  17. 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
  18. #提示已经把主切换到htz
  19. #在htz上面查看一下
  20. SQL> select open_mode ,database_role from v$database;
  21.  
  22. OPEN_MODE            DATABASE_ROLE
  23. -------------------- ----------------
  24. READ WRITE           PRIMARY
  25. 已经成功
  26. 手动启动原主库
  27. DGMGRL> 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> connect sys/oracle@htzb
    Connected.
    DGMGRL> startup
    ORACLE instance started.
    Database mounted.
    ORA-16649: possible failover to another database prevents this database from being opened
  28. #过一分会后我们再查看一下状态
  29. DGMGRL> connect sys/oracle@htz
    Connected.
    DGMGRL> show configuration

    Configuration - htz

    Protection Mode: MaxAvailability
    Databases:
    htz - Primary database
    htzb - (*) Physical standby database

    Fast-Start Failover: ENABLED

    Configuration Status:
    SUCCESS
  30. 查看状态,一切正常。

本文固定链接: http://www.htz.pw/2014/06/18/11gr-datagruad%e7%8e%af%e5%a2%83broker%e9%85%8d%e7%bd%aefast-start-failover.html | 认真就输

该日志由 huangtingzhong 于2014年06月18日发表在 DG 分类下, 通告目前不可用,你可以至底部留下评论。
原创文章转载请注明: 11GR DATAGRUAD环境BROKER配置Fast-Start Failover | 认真就输
关键字: , ,