oracle data guard broker配置與使用(上)

背景需求:有時候手工切換ADG,步驟繁瑣,麻煩。這裏介紹oracle自帶的broker工具的快捷切換以及它的failover特性

 

前提:

配置好了DGADG

安裝了oracle軟件(一般都安裝了)

 

 

1:配置監聽(添加下面內容)

(SID_DESC =

     (GLOBAL_DBNAME=dg1_DGMGRL)

     (ORACLE_HOME = /u01/oracle/11g)

     (SID_NAME =orcl)

)

 

 

2:啓動broken(主庫和備庫都切換)

alter system set dg_broker_start=true;

 

3:開啓閃回(主庫和備庫都開啓)

主庫

SQL> alter database flashback on;

 

Database altered.

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

 

OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON

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

READ WRITE           PRIMARY          ARCHIVELOG   YES

備庫

SQL> select database_role from v$database;

 

DATABASE_ROLESQL> recover managed standby database cancel;

Media recovery complete.

SQL> alter database flashback on;

 

Database altered.

 

SQL> recover managed standby database using current logfile disconnect;

Media recovery complete.

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

 

OPEN_MODE            DATABASE_ROLE    LOG_MODE     FLASHBACK_ON

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

READ ONLY WITH APPLY PHYSICAL STANDBY ARCHIVELOG   YES

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

PHYSICAL STANDBY

 

開始配置Broker

1:創建主庫配置

[oracle@ADG1 ~]$ dgmgrl

DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production

 

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

 

Welcome to DGMGRL, type "help" for information.

DGMGRL> connect sys/manager@dg1

Connected.

DGMGRL> help create

 

Creates a broker configuration

 

Syntax:

 

  CREATE CONFIGURATION <configuration name> AS

    PRIMARY DATABASE IS <database name>

    CONNECT IDENTIFIER IS <connect identifier>;

 

DGMGRL> create configuration dg as primary database is dg1 connect identifier is dg1;      

Configuration "dg" created with primary database "dg1"

2:添加備庫配置

DGMGRL> help add

 

Adds a standby database to the broker configuration

 

Syntax:

 

  ADD DATABASE <database name>

    [AS CONNECT IDENTIFIER IS <connect identifier>]

    [MAINTAINED AS {PHYSICAL|LOGICAL}];

 

DGMGRL> add database dg2 as connect identifier is dg2;

Database "dg2" added

3:生效配置參數

DGMGRL> enable configuration

 

Enabled.

4:顯示配置參數

DGMGRL> show configuration

 

Configuration - dg

 

  Protection Mode: MaxPerformance

  Databases:

    dg1 - Primary database

    dg2 - Physical standby database

      Warning: ORA-16792: configurable property value is inconsistent with database setting

 

Fast-Start Failover: DISABLED

 

Configuration Status:

WARNING

Note:出現警告,配置參數值不正確

查看報錯信息

DGMGRL> show database dg2 statusreport

STATUS REPORT

       INSTANCE_NAME   SEVERITY ERROR_TEXT

                orcl    WARNING ORA-16714: the value of property ArchiveLagTarget is inconsistent with the database setting

                orcl    WARNING ORA-16714: the value of property LogArchiveMaxProcesses is inconsistent with the database setting

                orcl    WARNING ORA-16714: the value of property LogArchiveMinSucceedDest is inconsistent with the database setting

                orcl    WARNING ORA-16714: the value of property LogArchiveTrace is inconsistent with the database setting

                orcl    WARNING ORA-16714: the value of property LogArchiveFormat is inconsistent with the database setting

 

DGMGRL> show database dg1 statusreport

STATUS REPORT

       INSTANCE_NAME   SEVERITY ERROR_TEXT

NoteDG2(備庫)報歸檔格式不識別

 

解決方法:

主庫

SQL> show  parameter format;

 

NAME                                 TYPE        VALUE

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

log_archive_format                   string      %t_%s_%r.dbf

 

備庫

SQL> show  parameter format;

 

NAME                                 TYPE        VALUE

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

log_archive_format                   string      %t_%s_%r.dbf

Note:不知道爲什麼報此錯誤

 

更新一下配置的格式

DGMGRL> edit database dg2 set property LogArchiveFormat='%t_%s_%r.dbf';  

DGMGRL> enable configuration

Enabled.

DGMGRL> show configuration

 

Configuration - dg

 

  Protection Mode: MaxPerformance

  Databases:

    dg1 - Primary database

    dg2 - Physical standby database

 

Fast-Start Failover: DISABLED

 

Configuration Status:

SUCCESS

 

5:查看主庫所有的參數配置

DGMGRL> show database verbose dg1

 

Database - dg1

 

  Role:            PRIMARY

  Intended State:  TRANSPORT-ON

  Instance(s):

    orcl

 

  Properties:

    DGConnectIdentifier             = 'dg1'

    ObserverConnectIdentifier       = ''

    LogXptMode                      = 'ASYNC'

    DelayMins                       = '0'

    Binding                         = 'optional'

    MaxFailure                      = '0'

    MaxConnections                  = '1'

    ReopenSecs                      = '300'

    NetTimeout                      = '30'

    RedoCompression                 = 'DISABLE'

    LogShipping                     = 'ON'

    PreferredApplyInstance          = ''

    ApplyInstanceTimeout            = '0'

    ArchiveLagTarget                = '0'

    LogArchiveMaxProcesses          = '4'

    LogArchiveMinSucceedDest        = '1'

    FastStartFailoverTarget         = ''

    InconsistentProperties          = '(monitor)'

    InconsistentLogXptProps         = '(monitor)'

    SendQEntries                    = '(monitor)'

    LogXptStatus                    = '(monitor)'

    RecvQEntries                    = '(monitor)'

    ApplyLagThreshold               = '0'

    TransportLagThreshold           = '0'

    TransportDisconnectedThreshold  = '30'

    SidName                         = 'orcl'

    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.200)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=dg1_DGMGRL)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))'

    StandbyArchiveLocation          = '/home/standbylog'

    AlternateLocation               = ''

    LogArchiveTrace                 = '0'

    LogArchiveFormat                = '%t_%s_%r.dbf'

    TopWaitEvents                   = '(monitor)'

 

Database Status:

SUCCESS

 

6:查看備庫的所有參數配置

DGMGRL> show database verbose dg2;

 

Database - dg2

 

  Role:            PHYSICAL STANDBY

  Intended State:  APPLY-ON

  Transport Lag:   0 seconds (computed 0 seconds ago)

  Apply Lag:       0 seconds (computed 0 seconds ago)

  Apply Rate:      0 Byte/s

  Real Time Query: ON

  Instance(s):

    orcl

 

  Properties:

    DGConnectIdentifier             = 'dg2'

    ObserverConnectIdentifier       = ''

    LogXptMode                      = 'SYNC'

    DelayMins                       = '0'

    Binding                         = 'OPTIONAL'

    MaxFailure                      = '0'

    MaxConnections                  = '1'

    ReopenSecs                      = '300'

    NetTimeout                      = '30'

    RedoCompression                 = 'DISABLE'

    LogShipping                     = 'ON'

    PreferredApplyInstance          = ''

    ApplyInstanceTimeout            = '0'

    ApplyParallel                   = 'AUTO'

    StandbyFileManagement           = 'AUTO'

    ArchiveLagTarget                = '0'

    LogArchiveMaxProcesses          = '4'

    LogArchiveMinSucceedDest        = '1'

    DbFileNameConvert               = ''

    LogFileNameConvert              = ''

    FastStartFailoverTarget         = 'dg1'

    InconsistentProperties          = '(monitor)'

    InconsistentLogXptProps         = '(monitor)'

    SendQEntries                    = '(monitor)'

    LogXptStatus                    = '(monitor)'

    RecvQEntries                    = '(monitor)'

    ApplyLagThreshold               = '0'

    TransportLagThreshold           = '0'

    TransportDisconnectedThreshold  = '30'

    SidName                         = 'orcl'

    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.201))(CONNECT_DATA=(SERVICE_NAME=dg2_DGMGRL)(INSTANCE_NAME=orcl)(SERVER=DEDICATED)))'

    StandbyArchiveLocation          = '/home/standbylog'

    AlternateLocation               = ''

    LogArchiveTrace                 = '0'

    LogArchiveFormat                = '%t_%s_%r.dbf'

    TopWaitEvents                   = '(monitor)'

 

Database Status:

SUCCESS

 

7:開啓failover

DGMGRL> ENABLE FAST_START FAILOVER;

Error: ORA-16651: requirements not met for enabling fast-start failover

Note:沒有滿足需求


開啓dg1sync同步模式

DGMGRL> edit database dg1 set property LogXptMode='SYNC';

Property "logxptmode" updated

更改爲最大可用性

DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;

Succeeded.

DGMGRL> show configuration;

 

Configuration - dg

 

  Protection Mode: MaxAvailability

  Databases:

    dg1 - Primary database

    dg2 - Physical standby database

 

Fast-Start Failover: DISABLED

 

Configuration Status:

SUCCESS

8:再次開啓failover

DGMGRL> ENABLE FAST_START FAILOVER;

Enabled.

DGMGRL> show configuration;

 

Configuration - dg

 

  Protection Mode: MaxAvailability

  Databases:

    dg1 - Primary database

      Warning: ORA-16819: fast-start failover observer not started

 

    dg2 - (*) Physical standby database

      Warning: ORA-16819: fast-start failover observer not started

 

Fast-Start Failover: ENABLED

 

Configuration Status:

WARNING

Note:報錯沒有開啓觀察進程

 

9:設置閾值爲10

DGMGRL> EDIT CONFIGURATION SET PROPERTY FastStartFailoverThreshold = 10;

Property "faststartfailoverthreshold" updated

開啓觀察進程

DGMGRL> start observer;

Observer started

 

再次查看配置

DGMGRL> show configuration;

 

Configuration - dg

 

  Protection Mode: MaxAvailability

  Databases:

    dg1 - Primary database

    dg2 - (*) Physical standby database

 

Fast-Start Failover: ENABLED

 

Configuration Status:

SUCCESS

配置完成

發佈了64 篇原創文章 · 獲贊 51 · 訪問量 24萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章