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

Step by Step Configuration Of DataGuard Broker for Oracle 19C

前言

DG Broker可以实现一条命令进行主从切换,但前提条件是必须先存在可用的DG架构,同时可以执行同步。

DG搭建

参考当前文档

https://www.modb.pro/db/1890265580175896576

DG Broker配置

重点:DG Broker必须在listener.ora中添加专有监听信息,否则无法开启

1、主节点更改listener.ora文件
需要添加的listener.ora配置如下:

    (SID_DESC =(GLOBAL_DBNAME = master_dgmgrl)(ORACLE_HOME = /data/19.3.0/product)(SID_NAME = master))

具体信息如下:

Step1:-Creating a Service Listener in primary and standby side(Both Side)
On Primary Side$ vi listener.ora
MASTER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = master.localdomain.com)(PORT = 1521))(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))))SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = master)(ORACLE_HOME = /data/19.3.0/product)(SID_NAME = master))(SID_DESC =(GLOBAL_DBNAME = master_dgmgrl)(ORACLE_HOME = /data/19.3.0/product)(SID_NAME = master))
)Reload  the listener:重新加载监听即可看到新的配置信息
$ lsnrctl reloadService "master" has 2 instance(s).Instance "master", status UNKNOWN, has 1 handler(s) for this service...Instance "master", status READY, has 1 handler(s) for this service...
Service "masterXDB" has 1 instance(s).Instance "master", status READY, has 1 handler(s) for this service...
Service "master_CFG" has 1 instance(s).Instance "master", status READY, has 1 handler(s) for this service...
Service "master_dgmgrl" has 1 instance(s).Instance "master", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

2、从节点更改listener.ora文件
需要添加的listener.ora配置如下:

    (SID_DESC =(GLOBAL_DBNAME = slave_dgmgrl)(ORACLE_HOME = /data/19.3.0/product)(SID_NAME = slave))

具体信息如下:

On Standby Side:$ vi listener.ora
SLAVE =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.62)(PORT = 1521))(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))))SID_LIST_LISTENER =(SID_LIST =(SID_DESC =(GLOBAL_DBNAME = slave)(ORACLE_HOME = /data/19.3.0/product)(SID_NAME = slave))(SID_DESC =(GLOBAL_DBNAME = slave_dgmgrl)(ORACLE_HOME = /data/19.3.0/product)(SID_NAME = slave))
)Reload  the listener:重新加载监听即可看到新的配置信息
$ lsnrctl reloadService "master_CFG" has 1 instance(s).Instance "slave", status READY, has 1 handler(s) for this service...
Service "slave" has 2 instance(s).Instance "slave", status UNKNOWN, has 1 handler(s) for this service...Instance "slave", status READY, has 1 handler(s) for this service...
Service "slaveXDB" has 1 instance(s).Instance "slave", status READY, has 1 handler(s) for this service...
Service "slave_dgmgrl" has 1 instance(s).Instance "slave", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

3、主节点更改参数

# 开启broker
SQL> ALTER SYSTEM SET dg_broker_start=true scope=both; -- 开启broker# 注册监听配置信息
SQL> ALTER SYSTEM SET local_listener='(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.61)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = master)))';  -- 配置监听参数

4、从节点更改参数

# 开启Broker
SQL> ALTER SYSTEM SET dg_broker_start=true scope=both;  -- 开启broker# 注册监听配置信息
SQL> ALTER SYSTEM SET local_listener='(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.60.62)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = slave)))'; -- 配置监听参数

5、主节点登录并创建DGMGRL

# 主节点登录
[oracle@master dbs]$ dgmgrl sys/admin@master
DGMGRL for Linux: Release 19.0.0.0.0 - Production on Wed Nov 12 00:39:44 2025
Version 19.3.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.Welcome to DGMGRL, type "help" for information.
Connected to "MASTER"
Connected as SYSDBA.#  查看是否存在broker配置,正常情况下是不会存在Broker配置的,报错的信息
显示的就是没有broker配置,所以此处我们需要新建
DGMGRL> show configuration;  
ORA-16532: Oracle Data Guard broker configuration does not exist  -- 显示不存在Configuration details cannot be determined by DGMGRL# 新建broker
# 注意:在create语句中的单引号用于区分大小写,取决于db_unique_name值
# 第一个参数:‘dgbroker’ 代指当前配置的别名
# 第二个参数:‘master’ 是主节点的db_unqiue_name值
# 第三个参数:‘master’ 也就是最后的值是主节点db_unqiue_name值DGMGRL> create configuration 'dgbroker' as primary database is 'master' connect identifier is master;  -- 新建broker配置,注意‘dbbroker’是别名
Configuration "dgbroker" created with primary database "master"# 查看配置
DGMGRL> show configuration;  -- 校验配置,没有报错或警告即可Configuration - dgbrokerProtection Mode: MaxPerformanceMembers:master - Primary databaseFast-Start Failover:  DisabledConfiguration Status:
DISABLED

6、DGMGRL中添加从库信息
注意:同样在主节点中执行

# 添加从库节点信息,这里的slave都是从节点的db_unique_name指代值
# 第一个参数:‘slave’ 是从节点的db_unqiue_name值
# 第二个参数:‘slave’ 是主节点的db_unqiue_name值DGMGRL> Add database 'slave' as connect identifier is slave maintained as physical;
Database "slave" added# 再次校验配置是否正确,没有错误或警告输出即可
DGMGRL> show configuration; Configuration - dgbrokerProtection Mode: MaxPerformanceMembers:master - Primary databaseslave  - Physical standby databaseFast-Start Failover:  DisabledConfiguration Status:
DISABLED

7、启动Broker

# 启动配置DGMGRL> enable configuration; 
Enabled.# 查看具体配置信息,如果有报错则在此处会显示DGMGRL> show configuration;Configuration - dgbrokerProtection Mode: MaxPerformanceMembers:master - Primary databaseslave  - Physical standby databaseFast-Start Failover:  DisabledConfiguration Status:
SUCCESS   (status updated 2 seconds ago)   -- 此处值为SUCCESS则无报错

8、查看配置信息

# 查看当前Broker参数配置
DGMGRL> show configuration verbose;Configuration - dgbrokerProtection Mode: MaxPerformanceMembers:master - Primary databaseslave  - Physical standby databaseProperties:FastStartFailoverThreshold      = '30'OperationTimeout                = '30'TraceLevel                      = 'USER'FastStartFailoverLagLimit       = '30'CommunicationTimeout            = '180'ObserverReconnect               = '0'FastStartFailoverAutoReinstate  = 'TRUE'FastStartFailoverPmyShutdown    = 'TRUE'BystandersFollowRoleChange      = 'ALL'ObserverOverride                = 'FALSE'ExternalDestination1            = ''ExternalDestination2            = ''PrimaryLostWriteAction          = 'CONTINUE'ConfigurationWideServiceName    = 'master_CFG'Fast-Start Failover:  DisabledConfiguration Status:
SUCCESS – 没有异常输出即可# 查看从库是否正常
DGMGRL> show database slave;Database - slaveRole:               PHYSICAL STANDBYIntended State:     APPLY-ONTransport Lag:      0 seconds (computed 0 seconds ago)Apply Lag:          0 seconds (computed 0 seconds ago)Average Apply Rate: 0 Byte/sReal Time Query:    ONInstance(s):slaveDatabase Status:
SUCCESS – 没有异常输出即可# 查看从库的broker详细配置信息
DGMGRL> show database verbose 'slave';  Database - slaveRole:               PHYSICAL STANDBYIntended State:     APPLY-ONTransport Lag:      0 seconds (computed 1 second ago)Apply Lag:          0 seconds (computed 1 second ago)Average Apply Rate: 0 Byte/sActive Apply Rate:  17.00 KByte/sMaximum Apply Rate: 17.00 KByte/sReal Time Query:    ONInstance(s):slaveProperties:DGConnectIdentifier             = 'slave'ObserverConnectIdentifier       = ''FastStartFailoverTarget         = ''PreferredObserverHosts          = ''LogShipping                     = 'ON'RedoRoutes                      = ''LogXptMode                      = 'ASYNC'DelayMins                       = '0'Binding                         = 'OPTIONAL'MaxFailure                      = '0'ReopenSecs                      = '300'NetTimeout                      = '30'RedoCompression                 = 'DISABLE'PreferredApplyInstance          = ''ApplyInstanceTimeout            = '0'ApplyLagThreshold               = '30'TransportLagThreshold           = '30'TransportDisconnectedThreshold  = '30'ApplyParallel                   = 'AUTO'ApplyInstances                  = '0'StandbyFileManagement           = ''ArchiveLagTarget                = '0'LogArchiveMaxProcesses          = '0'LogArchiveMinSucceedDest        = '0'DataGuardSyncLatency            = '0'LogArchiveTrace                 = '0'LogArchiveFormat                = ''DbFileNameConvert               = ''LogFileNameConvert              = ''ArchiveLocation                 = ''AlternateLocation               = ''StandbyArchiveLocation          = ''StandbyAlternateLocation        = ''InconsistentProperties          = '(monitor)'InconsistentLogXptProps         = '(monitor)'LogXptStatus                    = '(monitor)'SendQEntries                    = '(monitor)'RecvQEntries                    = '(monitor)'HostName                        = 'slave'StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.60.62)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=SLAVE_DGMGRL)(INSTANCE_NAME=slave)(SERVER=DEDICATED)))'TopWaitEvents                   = '(monitor)'SidName                         = '(monitor)'Log file locations:Alert log               : /data/19.3.0/diag/rdbms/slave/slave/trace/alert_slave.logData Guard Broker log   : /data/19.3.0/diag/rdbms/slave/slave/trace/drcslave.logDatabase Status:
SUCCESS  -- 没有异常输出即可# 查看主库的broker详细配置信息
DGMGRL> show database verbose 'master';#Database - masterRole:               PRIMARYIntended State:     TRANSPORT-ONInstance(s):masterProperties:DGConnectIdentifier             = 'master'ObserverConnectIdentifier       = ''FastStartFailoverTarget         = ''PreferredObserverHosts          = ''LogShipping                     = 'ON'RedoRoutes                      = ''LogXptMode                      = 'ASYNC'DelayMins                       = '0'Binding                         = 'optional'MaxFailure                      = '0'ReopenSecs                      = '300'NetTimeout                      = '30'RedoCompression                 = 'DISABLE'PreferredApplyInstance          = ''ApplyInstanceTimeout            = '0'ApplyLagThreshold               = '30'TransportLagThreshold           = '30'TransportDisconnectedThreshold  = '30'ApplyParallel                   = 'AUTO'ApplyInstances                  = '0'StandbyFileManagement           = ''ArchiveLagTarget                = '0'LogArchiveMaxProcesses          = '0'LogArchiveMinSucceedDest        = '0'DataGuardSyncLatency            = '0'LogArchiveTrace                 = '0'LogArchiveFormat                = ''DbFileNameConvert               = ''LogFileNameConvert              = ''ArchiveLocation                 = ''AlternateLocation               = ''StandbyArchiveLocation          = ''StandbyAlternateLocation        = ''InconsistentProperties          = '(monitor)'InconsistentLogXptProps         = '(monitor)'LogXptStatus                    = '(monitor)'SendQEntries                    = '(monitor)'RecvQEntries                    = '(monitor)'HostName                        = 'master'StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.60.61)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=MASTER_DGMGRL)(INSTANCE_NAME=master)(SERVER=DEDICATED)))'TopWaitEvents                   = '(monitor)'SidName                         = '(monitor)'Log file locations:Alert log               : /data/19.3.0/diag/rdbms/master/master/trace/alert_master.logData Guard Broker log   : /data/19.3.0/diag/rdbms/master/master/trace/drcmaster.logDatabase Status:
SUCCESS  -- 没有异常输出即可

9、验证主从切换

# 验证主库是否可切换成从库
DGMGRL> validate database 'master';Database Role:    Primary databaseReady for Switchover:  Yes  -- 当前值为yes即可切换Flashback Database Status:master:  OffManaged by Clusterware:master:  NOValidating static connect identifier for the primary database master...The static connect identifier allows for a connection to database "master".# 验证从库是否可切换成主库
注意:由于当前时间关系,没有对redo进行整改,标准作业流程下不能存在警告的字眼
DGMGRL> validate database 'slave';Database Role:     Physical standby databasePrimary Database:  masterReady for Switchover:  Yes  -- 当前值为yes即可切换Ready for Failover:    Yes (Primary Running)Flashback Database Status:master:  Offslave :  OffManaged by Clusterware:master:  NOslave :  NOValidating static connect identifier for the primary database master...The static connect identifier allows for a connection to database "master".Current Log File Groups Configuration:Thread #  Online Redo Log Groups  Standby Redo Log Groups Status(master)                (slave)1         3                       2                       Insufficient SRLsFuture Log File Groups Configuration:Thread #  Online Redo Log Groups  Standby Redo Log Groups Status(slave)                 (master)1         3                       0                       Insufficient SRLs
Warning: standby redo logs not configured for thread 1 on master

10、主从切换
注意:此处在主节点中执行。
重点:当执行该命令后,主从会自动发生切换,同时原从库会执行关机并自动重启

# 主从执行切换
注意:
DGMGRL> switchover to 'slave';
Performing switchover NOW, please wait...
Operation requires a connection to database "slave"
Connecting ...
Connected to "SLAVE"
Connected as SYSDBA.
New primary database "slave" is opening...
Operation requires start up of instance "master" on database "master"
Starting instance "master"...
Connected to an idle instance.
ORACLE instance started.
Connected to "MASTER"
Database mounted.
Database opened.
Connected to "MASTER"
Switchover succeeded, new primary is "slave"  -- 切换成功即可

11、验证同步即可

# 新主库创建数据执行同步
$ sqlplus / as sysdba
SQL>create table test (id number(10));
SQL>insert into test values(10);
SQL>commmit;
SQL>alter system switch logfile;# 新从库执行数据校验
$ sqlplus / as sysdba
SQL>select * from test;
-----------id10
http://www.dtcms.com/a/601611.html

相关文章:

  • 阿里云服务器网站备案工程造价材料信息网
  • 做底单的网站wordpress oauth
  • mkcert 自签证书以及 jssip
  • 新出土的古陶瓷碎片的图片并根据碎口尝试进行拼接用什么模型算法比较合适?古陶瓷碎片拼接算法选型
  • 网站建设人员需求化妆品网站的建设方案
  • Flink原理与实战(java版)#第2章 Flink的入门(第一节大数据架构的演变)
  • Python好玩的算法库
  • 银河麒麟V10下使用virt-manager安装Windows虚拟机
  • 插值——牛顿插值
  • 【稳定性】system_app_anr@1760693457221.txt和anr_2025-10-17-17-30-35-009有什么区别
  • 网站建设 教材 推荐免费网站提供
  • Java ee初阶——定时器
  • 【JavaEE初阶】网络层-IP协议
  • tomcat/idea打包部署报错,RUN 可以 DEBUG 不行
  • 地方网站还有得做吗永嘉做网站
  • 防滑齿位置与牙根断裂风险的相关性分析
  • Lua学习记录(1) --- Lua中的条件分支语句和循环语句
  • 铸铁实验平台概述
  • 微电网的“智能大脑”:ACCU-100M如何实现光储充一体化协调控制?
  • 算法 day 52
  • seo优化排名易下拉试验2022年seo还值得做吗
  • (Mysql)MySQL 查询执行顺序总结
  • Plaxis自动化建模与Python应用全解:从环境搭建到高级案例实战
  • 网络推广网站排名免费的行情软件网站不用下载
  • 建设网站困难的解决办法推荐营销型网站建设
  • 护航青春心 ——VR青少年心理健康体验系统的温柔守护
  • 20251112给荣品RD-RK3588开发板跑Rockchip的原厂Android13系统时适配gmac0
  • 网站支付页面怎么做的咸宁手机网站建设
  • 石油钻井、HDD、采矿:不同工况下,如何抉择您的陀螺定向短节?
  • MySQL: 体系结构与插件式存储引擎架构详解