首页 > 其他分享 >配置dataguard broker(19C)并主从切换

配置dataguard broker(19C)并主从切换

时间:2023-02-01 15:24:03浏览次数:43  
标签:slavea NAME database broker dataguard oracle DGMGRL slnngk 19C

环境:
OS:CentOS 7
Oracle:19.3.0.0
拓扑结构:一主一从

角色                  ip                          实例id
主库                 192.168.1.102      slnngk
从库                 192.168.1.103      slavea
observer机器   192.168.1.104

说明:
(ob机器需要安装同版本的数据库软件)

 

1 前置条件
已经部署好了一主一从的dataguard,同时ob机器需要安装好同版本的oracle软件

 

2 主备库和observer机器配置好tns

tnsslnngk =
    (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = slnngk)
    )
  )

tnsslavea =
    (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = slavea)
    )
  )

 

3 主备库添加静态监听

主库
vi /u01/app/oracle/product/19.3.0.0/db_1/network/admin/listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = slnngk_DGMGRL)
      (ORACLE_HOME =/u01/app/oracle/product/19.3.0.0/db_1)
      (SID_NAME =slnngk)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = slnngk)
      (ORACLE_HOME =/u01/app/oracle/product/19.3.0.0/db_1)
      (SID_NAME =slnngk)
    )
  )

备库
vi /u01/app/oracle/product/19.3.0.0/db_1/network/admin/listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = slavea_DGMGRL)
      (ORACLE_HOME =/u01/app/oracle/product/19.3.0.0/db_1)
      (SID_NAME =slavea)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = slavea)
      (ORACLE_HOME =/u01/app/oracle/product/19.3.0.0/db_1)
      (SID_NAME =slavea)
    )
  )

 

主备库监听重启动
su - oracle
lsnrctl stop
lsnrctl start
lsnrctl status

 

若是不配置静态监听器的话 需要在observer的机器上进行如下的配置

DGMGRL> edit database slnngk set property StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slnngk)(INSTANCE_NAME=slnngk)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated
DGMGRL> edit database slavea set property StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.103)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slavea)(INSTANCE_NAME=slavea)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated

 

4.主备库配置相应参数

主库

alter system set dg_broker_config_file1='/u01/app/oracle/product/19.3.0.0/db_1/dbs/dr1slnngk.dat' scope=both;
alter system set dg_broker_config_file2='/u01/app/oracle/product/19.3.0.0/db_1/dbs/dr2slnngk.dat' scope=both;

主库启用dgbroker
alter system set dg_broker_start=true scope=both;

备库

alter system set dg_broker_config_file1='/u01/app/oracle/product/19.3.0.0/db_1/dbs/dr1slavea.dat' scope=both;
alter system set dg_broker_config_file2='/u01/app/oracle/product/19.3.0.0/db_1/dbs/dr2slavea.dat' scope=both;

文件名称无关紧要,可以随便取,一般放dbs目录下,若是asm的需要放共享磁盘上.

备库启用dgbroker
alter system set dg_broker_start=true scope=both;

 

6.observer服务器配置/etc/hosts

observer服务器需要配置ip和主机的解析,如下:

[root@19c-slaveb ~]# more /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.102 19c
192.168.1.103 19c-slavea

若observer服务器与数据库服务器是部署在一起的话,那么也需要进行配置hosts解析

 

若不想配置hosts,那么可以在配置文件中写死ip

DGMGRL> edit database slnngk set property StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slnngk_DGMGRL)(INSTANCE_NAME=slnngk)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated
DGMGRL> edit database slavea set property StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.103)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slavea_DGMGRL)(INSTANCE_NAME=slavea)(SERVER=DEDICATED)))';
Property "staticconnectidentifier" updated

 

7.配置dgbroker(在observer机器上操作)

添加主库
在observer机器上执行
[oracle@dg admin]$ dgmgrl sys/oracle@tnsslnngk; ##这里的tnsslnngk是连接主库的tns,也可以连接备库

添加主库

DGMGRL> create configuration slnngktest as primary database is 'slnngk' connect identifier is 'tnsslnngk';
Configuration "slnngktest" created with primary database "slnngk"

slnngktest:配置别名,可以随意取
slnngk:主库的db_unique_name
tnsslnngk:连接主库的tns
#启用配置文件(这个时候生成主库的配置文件dr1slnngk.dat,dr2slnngk.dat)

DGMGRL> enable configuration;
Enabled.

 

#添加备库

[oracle@dg admin]$ dgmgrl sys/oracle@tnsslnngk;
DGMGRL> add database 'slavea' as connect identifier is 'tnsslavea';
Error: ORA-16698: member has a LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set

Failed.

这个错误是之前手工部署dataguard的时候配置了相应的的归档路径,如log_archive_dest_2导致的,配置dgbroker后这些配置
都交给DG broker 来管理了,不再需要人为介入设置。
备库执行以下语句,重置参数log_archive_dest_2
SQL> alter system set log_archive_dest_2='' scope=both;

重新执行:

DGMGRL> add database 'slavea' as connect identifier is 'tnsslavea';
Database "slavea" added

DGMGRL>  enable database 'slavea';
Enabled.

 

8.查看配置信息

[oracle@dg admin]$ dgmgrl sys/oracle@tnsslnngk;
DGMGRL> show configuration

Configuration - slnngktest

  Protection Mode: MaxPerformance
  Members:
  slnngk - Primary database
    slavea - Physical standby database 

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 49 seconds ago)

 

9.查看主备库的配置情况

DGMGRL> show database verbose slnngk;
DGMGRL> show database verbose slavea;

 

10.switchover切换

10.1 连接到其中一个数据库,我这里连接到主库
[oracle@dg admin]$ dgmgrl sys/oracle@tnsslnngk;

连接从库也是可以操作的
[oracle@dg admin]$ dgmgrl sys/oracle@tnsslavea;

 

10.2 查看配置

DGMGRL> show configuration

Configuration - slnngktest

  Protection Mode: MaxPerformance
  Members:
  slnngk - Primary database
    slavea - Physical standby database 

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 6 seconds ago)

 

10.3 切换到slavea

DGMGRL> switchover to slavea;
Performing switchover NOW, please wait...
Operation requires a connection to database "slavea"
Connecting ...
Connected to "slavea"
Connected as SYSDBA.
New primary database "slavea" is opening...
Operation requires start up of instance "slnngk" on database "slnngk"
Starting instance "slnngk"...
Unable to connect to database using (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=19c)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slnngk_DGMGRL)(INSTANCE_NAME=slnngk)(SERVER=DEDICATED)))
ORA-12545: Connect failed because target host or object does not exist

Failed.

Please complete the following steps to finish switchover:
        start up instance "slnngk" of database "slnngk"

 

这里不能正常启动备库是 因为在/etc/hosts文件中没有对主机名和ip进行解析导致的,出现这种情况的话,需要在observer机器上配置/etc/hosts解析,同时手工启动备库,手工启动备库会自动应用日志,不需要手工输入alter database recover managed standby database using current logfile disconnect from session

 

手工启动从库slnngk
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 3372217840 bytes
Fixed Size                  8902128 bytes
Variable Size             671088640 bytes
Database Buffers         2684354560 bytes
Redo Buffers                7872512 bytes
Database mounted.
Database opened.

从库会自动启动日志应用进程
SQL> select process,status from v$managed_standby;

PROCESS   STATUS
--------- ------------
ARCH      CONNECTED
DGRD      ALLOCATED
DGRD      ALLOCATED
ARCH      CONNECTED
ARCH      CONNECTED
RFS       IDLE
ARCH      CONNECTED
RFS       IDLE
RFS       IDLE
RFS       IDLE
MRP0      APPLYING_LOG

11 rows selected.

 

标签:slavea,NAME,database,broker,dataguard,oracle,DGMGRL,slnngk,19C
From: https://www.cnblogs.com/hxlasky/p/17082914.html

相关文章

  • [Oracle19C 数据库管理] 用户与权限管理
    用户管理用户具有以下属性:用户名:不能超过30位。不能包含特殊字符。必须用字符开头。用户名不区分大小写。认证方式:最常见的是密码认证。默认永久表空间:控制用户可......
  • [Oracle19C 数据库管理] 管理回滚表空间(UNDO Tablespace)
    当对数据进行修改时,Oracle数据库会将旧的数据存储到UNDO表空间(回滚表空间)。回滚表空间让用户可以rollback到修改前的数据,提供了读一致性,并支持闪回查询过去的数据。Undo......
  • 19CData Guard Physical Standby无法实时同步问题
    【现象】DataGuardPhysicalStandby发现无法实时同步数据,需要在主库执行切换altersystemswitchlogfile;操作,备库才能同步到数据。【检查】从上面现象可以看出,需要......
  • [Oracle19C 数据库管理] 管理存储
    存储概览存储的架构ControlFile:储存了数据物理存储的信息。存在多个副本来避免单点故障。没有控制文件,数据库无法打开。DATAFile:存储用户与应用的信息,以及元数据与......
  • 关于19c RU补丁报错问题的分析处理
    本文演示关于19cRU补丁常见报错问题的分析处理:1.查看补丁应用失败的原因2.问题解决后可继续应用补丁3.发现DB的RU补丁未更新4.opatchauto应用DB补丁报错解决1.查看......
  • [Oracle19C 数据库管理] 创建PDB
    使用PDB$SEED模板创建PDB通过PDB$SEED创建PDB数据库,将会触发以下动作:将文件从PDB$SEED文件夹复制到新创建的PDB数据库文件夹中。创建表空间SYSTEMSYSAUXUNDO创......
  • docker 部署 Oracle 19c
    标签(空格分隔):Oracle系列一:系统环境介绍操作系统:centos7.9x64oracle19c配置说明:主机名:cat/etc/hosts----172.16.10.11flyfish11172.16.10.12fl......
  • windows 11安装oracle 19c客户端
    文档课题:windows11安装oracle19c客户端.软件包:WINDOWS.X64_193000_client.zip--以管理员身份双击setup.exe参考网址:https://cdn.modb.pro/db/580252......
  • [Oracle19C 数据库管理] 初始化参数
    初始化参数文件默认情况下,初始化参数文件保存在$ORACLE_HOME/dbs目录中。初始化参数分为SPFILE和Pfile两种。SPFILE(ServerParameterFile)二进制文件,可以由数......
  • [Oracle19C 数据库管理] 启动和停止Oracle数据库
    数据库启动的三个阶段startupnomount数据库根据初始化文件启动实例,分配内存给系统全局区SGA,并启动所有的后台进程。打开alertlog和tracefile。这个阶段实例会启动......