阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Oracle RAC 11g DG Broker配置和测试

189次阅读
没有评论

共计 5922 个字符,预计需要花费 15 分钟才能阅读完成。

Oracle RAC 11g DG Broker 配置和测试

之前在《RHEL6.4 + Oracle 11g DG 测试环境快速搭建参考》已经简单说过。
本篇在实验环境中实际配置
环境: RHEL 6.5 + Oracle 11.2.0.4 GI、DB + Primary RAC(2 nodes)+ Standby RAC(2 nodes)
该实验环境的搭建可参考:模拟生产搭建 Standby RAC 实验环境(11.2.0.4 DG)

配置并测试 DG Broker 步骤:

  • 1. 停止 MRP
  • 2. 修改 Listener.ora 文件
  • 3. 修改参数文件
  • 4. 创建配置
  • 5. 启用配置
  • 6. 切换测试

1. 停止 MRP

在备库停止 MRP:

alter database recover managed standby database cancel;

2. 修改 Listener.ora 文件

在各个节点 grid 用户的监听文件中,

[grid@jyrac1 ~]$ cd $ORACLE_HOME/network/admin
[grid@jyrac1 admin]$ vi listener.ora

分别增加以下内容:

--Primary Node1
SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=jyzhao1)(GLOBAL_DBNAME=jyzhao_dgmgrl)(ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1)))
 
--Primary Node2
 
SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=jyzhao2)(GLOBAL_DBNAME=jyzhao_dgmgrl)(ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1)))
 
--Standby Node1
 
SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=jyzhao1)(GLOBAL_DBNAME=mynas_dgmgrl)(ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1)))
 
--Standby Node2
 
SID_LIST_LISTENER=(SID_LIST=(SID_DESC=(SID_NAME=jyzhao2)(GLOBAL_DBNAME=mynas_dgmgrl)(ORACLE_HOME=/opt/app/oracle/product/11.2.0/dbhome_1)))

注:因为我这里的环境之前没有配置其他的静态监听,而且默认使用的监听名字是 LISTENER,所以,只需要直接添加这一行配置即可。
添加完毕后分别在各节点重新启动监听:

--@all nodes
lsnrctl stop
lsnrctl start

3. 修改参数文件

检查当前 DG_BROKER_CONFIG_FILE 和 dg_broker_start 配置:

--ON Primary:

SYS@jyzhao1 >show parameter dg_broker

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /opt/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/dr1jyzhao.dat
dg_broker_config_file2               string      /opt/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/dr2jyzhao.dat
dg_broker_start                      boolean     FALSE

--ON Standby:

SQL> show parameter dg_broker

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /opt/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/dr1mynas.dat
dg_broker_config_file2               string      /opt/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/dr2mynas.dat
dg_broker_start                      boolean     FALSE

需要把 DG Broker 配置文件的默认路径修改到 ASM 磁盘上,并将 dg_broker_start 修改为 TRUE,具体操作如下:

--ON Primary:
ASMCMD>
mkdir +fra1/jyzhao/DATAGUARDCONFIG
mkdir +data1/jyzhao/DATAGUARDCONFIG
 
SQL>
ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1='+fra1/jyzhao/DATAGUARDCONFIG/dgb_config1.ora' SCOPE=BOTH sid='*';
ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2='+data1/jyzhao/DATAGUARDCONFIG/dgb_config2.ora' SCOPE=BOTH sid='*';
alter system set dg_broker_start=true scope=both sid='*';
show parameter dg_broker

--ON Standby:
ASMCMD>
mkdir +fra/mynas/DATAGUARDCONFIG
mkdir +data/mynas/DATAGUARDCONFIG
 
SQL>
ALTER SYSTEM SET DG_BROKER_CONFIG_FILE1='+fra/mynas/DATAGUARDCONFIG/dgb_config1.ora' SCOPE=BOTH sid='*';
ALTER SYSTEM SET DG_BROKER_CONFIG_FILE2='+data/mynas/DATAGUARDCONFIG/dgb_config2.ora' SCOPE=BOTH sid='*';
alter system set dg_broker_start=true scope=both sid='*';
show parameter dg_broker

此时,主备库的 alert 告警日志中都会有启动 DG Broker 的信息:

Sun Aug 13 16:45:27 2017
DMON started with pid=41, OS id=7432 
Starting Data Guard Broker (DMON)
Sun Aug 13 16:45:49 2017
INSV started with pid=54, OS id=7459 

4. 创建配置

dgmgrl sys/oracle
在 dgmgrl 下创建配置:

CREATE CONFIGURATION 'jydb' AS PRIMARY DATABASE IS 'jyzhao' CONNECT IDENTIFIER IS 'jyzhao';
ADD DATABASE 'mynas' AS CONNECT IDENTIFIER IS 'mynas';

实际操作如下:

DGMGRL> CREATE CONFIGURATION 'jydb' AS PRIMARY DATABASE IS 'jyzhao' CONNECT IDENTIFIER IS 'jyzhao';
Configuration "jydb" created with primary database "jyzhao"

DGMGRL> ADD DATABASE 'mynas' AS CONNECT IDENTIFIER IS 'mynas';
Database "mynas" added

5. 启用配置

在 dgmgrl 下启用配置,查看配置:

enable configuration;
show configuration;   
show database verbose jyzhao

实际操作如下:

DGMGRL> enable configuration;
Enabled.

DGMGRL> show configuration;   

Configuration - jydb

  Protection Mode: MaxPerformance
  Databases:
    jyzhao - Primary database
    mynas  - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> show database verbose jyzhao

Database - jyzhao

  Role:            PRIMARY
  Intended State:  TRANSPORT-ON
  Instance(s):
    jyzhao1
    jyzhao2

  Properties:
    DGConnectIdentifier             = 'jyzhao'
    ObserverConnectIdentifier       = ''
    LogXptMode                      = 'ASYNC'
    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               = '+data/mynas, +data1/jyzhao'
    LogFileNameConvert              = '+data/mynas, +data1/jyzhao, +fra/mynas, +fra1/jyzhao'
    FastStartFailoverTarget         = ''
    InconsistentProperties          = '(monitor)'
    InconsistentLogXptProps         = '(monitor)'
    SendQEntries                    = '(monitor)'
    LogXptStatus                    = '(monitor)'
    RecvQEntries                    = '(monitor)'
    ApplyLagThreshold               = '0'
    TransportLagThreshold           = '0'
    TransportDisconnectedThreshold  = '30'
    SidName(*)
    StaticConnectIdentifier(*)
    StandbyArchiveLocation(*)
    AlternateLocation(*)
    LogArchiveTrace(*)
    LogArchiveFormat(*)
    TopWaitEvents(*)
    (*) - Please check specific instance for the property value

Database Status:
SUCCESS

DGMGRL> 

附一些常用的命令汇总:

show configuration;
show database jyzhao;
show database mynas;
show database verbose jyzhao;
show database verbose mynas;
show instance verbose jyzhao1 on database jyzhao;
show instance verbose jyzhao2 on database jyzhao;
show instance verbose jyzhao1 on database mynas;
show instance verbose jyzhao2 on database mynas;

这些常用命令的输出结果大家可以在自己的实验环境测试一下,我这里就不赘述了。

6. 切换测试

我们配置 DG Broker 主要就是为了方便切换,在配置正确的环境中,只需要一条命令就可以 switchover 成功。
在 dgmgrl 下切换测试:

-- 一条命令完成 switchover 主备切换:switchover to mynas;    

-- 一条命令完成 switchover 主备切回:switchover to jyzhao; 

来看看实际 DG Broker 的强大功能, 以主备切换为例:

[oracle@jyrac1 ~]$ dgmgrl sys/oracle
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.
Connected.
DGMGRL> switchover to mynas;
Performing switchover NOW, please wait...
Operation requires a connection to instance "jyzhao2" on database "mynas"
Connecting to instance "jyzhao2"...
Connected.
New primary database "mynas" is opening...
Operation requires startup of instance "jyzhao1" on database "jyzhao"
Starting instance "jyzhao1"...
ORACLE instance started.
Database mounted.
Database opened.
Switchover succeeded, new primary is "mynas"

整个过程一条简单命令实现,这相当于我之前手工切换《Oracle 11g DG 手工 switchover 切换标准化流程》做的所有功能。
有了配置正确的 DG Broker,老板再也不用担心员工去 switchover 切换搞的手忙脚乱了哈~

更多 Oracle 相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-08/146330.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-22发表,共计5922字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中