DM读写分离集群环境搭建

搭建思路:
1.虚拟机:三台,分别安装数据库,添加网络适配器;
2.集群环境:一主两备;三台分别初始化实例,正常启动关闭数据库,主库做备份,还原恢复给两个备库;
3.三台分别配置数据库文件,分别以mount方式启动数据库,修改oguid,数据库模式;
4.配置监视器,分别依次启动数据库–守护–监视器,刷新监视器查看数据库状态,没有问题,搭建完成。

演示操作:
1.数据库环境介绍:
数据库版本:V8
操作系统版本:ContOS 7
三台主机IP:192.168.10.6 ,192.168.10.7 ,192.168.10.8
三台主机实例名:GRP1_RWW_01 ,GRP1_RWW_02 ,GRP1_RWW_03
端口号:5236

2.安装数据库过程参考:

https://blog.csdn.net/weixin_48588449/article/details/107786517

3.三台分别初始化数据库实例:

[dmdba@localhost bin]$ ./dminit path=/dm8/data INSTANCE_NAME=GRP1_RWW_01
initdb V8
db version: 0x7000a
file dm.key not found, use default license!
License will expire on 2021-06-24

 log file path: /dm8/data/DAMENG/DAMENG01.log


 log file path: /dm8/data/DAMENG/DAMENG02.log

write to dir [/dm8/data/DAMENG].
create dm database success. 2020-08-26 14:46:21
[dmdba@localhost bin]$ 
==============================================================
[dmdba@localhost bin]$  ./dminit path=/dm8/data INSTANCE_NAME=GRP1_RWW_02
initdb V8
db version: 0x7000a
file dm.key not found, use default license!
License will expire on 2021-06-24

 log file path: /dm8/data/DAMENG/DAMENG01.log


 log file path: /dm8/data/DAMENG/DAMENG02.log

write to dir [/dm8/data/DAMENG].
create dm database success. 2020-08-26 14:46:34
[dmdba@localhost bin]$ 
==============================================================
[dmdba@localhost bin]$  ./dminit path=/dm8/data INSTANCE_NAME=GRP1_RWW_03
initdb V8
db version: 0x7000a
file dm.key not found, use default license!
License will expire on 2021-06-24

 log file path: /dm8/data/DAMENG/DAMENG01.log


 log file path: /dm8/data/DAMENG/DAMENG02.log

write to dir [/dm8/data/DAMENG].
create dm database success. 2020-08-26 22:46:15
[dmdba@localhost bin]$ 

4.分别启动数据库:

[dmdba@localhost bin]$ ./dmserver /dm8/data/DAMENG/dm.ini 
。。。。。。。。。。。。。。。。。。。。。
pseg_crash_trx_rollback end
SYSTEM IS READY    =======结尾出现这个,表示启动成功
===============================================================

exit
Server is stopping...
listener closed  and all sessions disconnected
。。。。。。。。。。。。。
close lsnr socket
DM Database Server shutdown successfully.  ====表示关闭数据库
[dmdba@localhost bin]$ 

我的环境中主机名,数据库安装目录,实例安装目录都相同;

5.备份

[dmdba@localhost bin]$ ./dmrman 
dmrman V8
RMAN> backup database '/dm8/data/DAMENG/dm.ini' full to backup_file1 backupset '/dm8/data/BACKUP_FILE_01'
backup database '/dm8/data/DAMENG/dm.ini' full to backup_file1 backupset '/dm8/data/BACKUP_FILE_01'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[34895]
BACKUP DATABASE [DAMENG],execute......
CMD CHECK LSN......
BACKUP DATABASE [DAMENG],collect dbf......
CMD CHECK ......
DBF BACKUP SUBS......
total 0 packages processed...
total 0 packages processed...
total 0 packages processed...
DBF BACKUP MAIN......
BACKUPSET [/dm8/data/BACKUP_FILE_01] END, CODE [0]......
META GENERATING......
CMD END.CODE:[0]
backup successfully!
time used: 00:00:01.095
RMAN> 

6.还原恢复
将主库GRP1_RWW_01备份集分别传给两个备库,还原恢复备份集;

[dmdba@localhost bin]$ scp -r ../data/BACKUP_FILE_01 192.168.10.7:/dm8/data/
The authenticity of host '192.168.10.7 (192.168.10.7)' can't be established.
ECDSA key fingerprint is SHA256:PyvgBD9b1BWhTn/zbLuPRNDSE3q9WikYsolSn+Iae8o.
ECDSA key fingerprint is MD5:07:93:30:f0:bf:bf:2e:a0:14:09:bc:d2:16:8f:f4:ab.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.7' (ECDSA) to the list of known hosts.
[email protected]'s password: 
BACKUP_FILE_01.bak                                                                                  100% 5990KB  55.2MB/s   00:00    
BACKUP_FILE_01.meta                                                                                 100%   73KB  10.7MB/s   00:00    
[dmdba@localhost bin]$ scp -r ../data/BACKUP_FILE_01 192.168.10.8:/dm8/data/
The authenticity of host '192.168.10.8 (192.168.10.8)' can't be established.
ECDSA key fingerprint is SHA256:PyvgBD9b1BWhTn/zbLuPRNDSE3q9WikYsolSn+Iae8o.
ECDSA key fingerprint is MD5:07:93:30:f0:bf:bf:2e:a0:14:09:bc:d2:16:8f:f4:ab.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.8' (ECDSA) to the list of known hosts.
[email protected]'s password: 
BACKUP_FILE_01.bak                                                                                  100% 5990KB  50.4MB/s   00:00    
BACKUP_FILE_01.meta                                                                                 100%   73KB   7.1MB/s   00:00    
[dmdba@localhost bin]$ 

GRP1_RWW_02 做还原恢复

[dmdba@localhost bin]$ ./dmrman 
dmrman V8
RMAN> restore database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/data/BACKUP_FILE_01'
restore database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/data/BACKUP_FILE_01'
file dm.key not found, use default license!
RESTORE DATABASE CHECK......
RESTORE DATABASE,data collect......
RESTORE DATABASE,database refresh ......
RESTORE BACKUPSET [/dm8/data/BACKUP_FILE_01] START......
total 0 packages processed...
RESTORE DATABASE,UPDATE ctl file......
RESTORE DATABASE,REBUILD key file......
RESTORE DATABASE,CHECK db info......
RESTORE DATABASE,UPDATE db info......
CMD END.CODE:[0]
restore successfully.
time used: 379.496(ms)
RMAN> recover database '/dm8/data/DAMENG/dm.ini' update db_magic
recover database '/dm8/data/DAMENG/dm.ini' update db_magic
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[34895]
EP[0]'s apply_lsn[34895] >= end_lsn[34895]
recover successfully!
time used: 00:00:01.029
RMAN> 

GRP1_RWW_03 做还原恢复

[dmdba@localhost bin]$ ./dmrman 
dmrman V8
RMAN> restore database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/data/BACKUP_FILE_01'
restore database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/data/BACKUP_FILE_01'
file dm.key not found, use default license!
RESTORE DATABASE CHECK......
RESTORE DATABASE,data collect......
RESTORE DATABASE,database refresh ......
RESTORE BACKUPSET [/dm8/data/BACKUP_FILE_01] START......
total 0 packages processed...
RESTORE DATABASE,UPDATE ctl file......
RESTORE DATABASE,REBUILD key file......
RESTORE DATABASE,CHECK db info......
RESTORE DATABASE,UPDATE db info......
CMD END.CODE:[0]
restore successfully.
time used: 340.978(ms)
RMAN> recover database '/dm8/data/DAMENG/dm.ini' update db_magic
recover database '/dm8/data/DAMENG/dm.ini' update db_magic
Database mode = 0, oguid = 0
EP[0]'s cur_lsn[34895]
EP[0]'s apply_lsn[34895] >= end_lsn[34895]
recover successfully!
time used: 00:00:01.001
RMAN> 

数据准备OK,修改配置文件;

7.配置主库GRP1_RWW_01 数据库实例目录:/dm8/data/DAMENG
dm.ini 参数修改如下:

vim dm.ini

#实例名,建议使用―组名_守护环境_序号‖的命名方式,总长度不能超过 16
INSTANCE_NAME  = GRP1_RWW_01
PORT_NUM  = 5236 #数据库实例监听端口
DW_INACTIVE_INTERVAL  = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS  = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS  = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI  = 1 #打开归档配置
RLOG_SEND_APPLY_MON = 64 #统计最近 64 次的日志发送信息

配置 MAL 系统,各主备库的 dmmal.ini 配置必须完全一致

vim dmmal.ini

MAL_CHECK_INTERVAL = 5 #MAL 链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 5 #判定 MAL 链路断开的时间
[MAL_INST1]
MAL_INST_NAME  = GRP1_RWW_01 #实例名,和 dm.ini 中的 INSTANCE_NAME 一致
MAL_HOST  = 192.168.10.6 #MAL 系统监听 TCP 连接的 IP 地址
MAL_PORT = 61141 #MAL 系统监听 TCP 连接的端口
MAL_INST_HOST  = 192.168.10.147 #实例的对外服务 IP 地址
MAL_INST_PORT  = 5236 #实例的对外服务端口,和 dm.ini 中的 PORT_NUM 一致
MAL_DW_PORT = 52141 #实例对应的守护进程监听 TCP 连接的端口
MAL_INST_DW_PORT  = 33141 #实例监听守护进程 TCP 连接的端口
[MAL_INST2]
MAL_INST_NAME = GRP1_RWW_02
MAL_HOST = 192.168.10.7
MAL_PORT = 61142
MAL_INST_HOST = 192.168.10.148
MAL_INST_PORT = 5236
MAL_DW_PORT = 52142
MAL_INST_DW_PORT  = 33142
[MAL_INST3]
MAL_INST_NAME = GRP1_RWW_03
MAL_HOST = 192.168.10.8
MAL_PORT = 61143
MAL_INST_HOST = 192.168.10.146
MAL_INST_PORT = 5236
MAL_DW_PORT = 52143
MAL_INST_DW_PORT  = 33143

配置本地归档和即时归档

vim dmarch.ini

[ARCHIVE_TIMELY1]
ARCH_TYPE = TIMELY  #即时归档类型
ARCH_DEST = GRP1_RWW_02  #即时归档目标实例名
[ARCHIVE_TIMELY2]
ARCH_TYPE = TIMELY  #即时归档类型
ARCH_DEST = GRP1_RWW_03  #即时归档目标实例名
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST = /dm8/data/DAMENG/arch #本地归档文件存放路径
ARCH_FILE_SIZE = 128  #单位 Mb,本地单个归档文件最大值
ARCH_SPACE_LIMIT  = 1024 #单位 Mb,0 表示无限制,范围 1024~4294967294M

配置为全局守护类型,使用自动切换模式

vim dmwatcher.ini

[GRP1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = AUTO #自动切换模式
DW_ERROR_TIME = 10  #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #主库守护进程启动恢复的间隔时间
INST_ERROR_TIME = 10  #本地实例故障认定时间
INST_OGUID = 453332  #守护系统唯一 OGUID 值
INST_INI = /dm8/data/DAMENG/dm.ini  #dm.ini 配置文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /dm8/bin/dmserver #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阀值,默认关闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阀值,默认关闭

以 Mount 方式启动主库

./dmserver /dm/data/DAMENG/dm.ini mount

启动命令行工具 DIsql,登录主库设置 OGUID 值;主库修改数据库为 Primary 模式

[dmdba@localhost bin]$ ./disql 
disql V8
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间: 5.169(毫秒)
SQL> sp_set_para_value(1,'ALTER_MODE_STATUS',1);
DMSQL 过程已成功完成
已用时间: 5.844(毫秒). 执行号:1.
SQL> sp_set_oguid(453332);
DMSQL 过程已成功完成
已用时间: 8.227(毫秒). 执行号:2.
SQL> alter database primary;
操作已执行
已用时间: 19.847(毫秒). 执行号:0.
SQL> sp_set_para_value(1,'ALTER_MODE_STATUS',0);
DMSQL 过程已成功完成
已用时间: 4.984(毫秒). 执行号:3.

8.配置主库GRP1_RWW_02 数据库实例目录:/dm8/data/DAMENG
dm.ini 参数修改如下:

vim dm.ini

#实例名,建议使用―组名_守护环境_序号‖的命名方式,总长度不能超过 16
INSTANCE_NAME  = GRP1_RWW_02
PORT_NUM  = 5236 #数据库实例监听端口
DW_INACTIVE_INTERVAL  = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS  = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS  = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI  = 1 #打开归档配置
RLOG_SEND_APPLY_MON = 64 #统计最近 64 次的日志重演信息

配置 MAL 系统,各主备库的 dmmal.ini 配置必须完全一致
拷贝主库的即可

[dmdba@localhost DAMENG]$ scp 192.168.10.6:/dm8/data/DAMENG/dmmal.ini .
The authenticity of host '192.168.10.6 (192.168.10.6)' can't be established.
ECDSA key fingerprint is SHA256:PyvgBD9b1BWhTn/zbLuPRNDSE3q9WikYsolSn+Iae8o.
ECDSA key fingerprint is MD5:07:93:30:f0:bf:bf:2e:a0:14:09:bc:d2:16:8f:f4:ab.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.6' (ECDSA) to the list of known hosts.
[email protected]'s password: 
dmmal.ini                                                                                           100%  986   907.6KB/s   00:00    
[dmdba@localhost DAMENG]$ 

配置本地归档和即时归档

vim dmarch.ini

[ARCHIVE_TIMELY1]
ARCH_TYPE = TIMELY  #即时归档类型
ARCH_DEST = GRP1_RWW_01  #即时归档目标实例名
[ARCHIVE_TIMELY2]
ARCH_TYPE = TIMELY  #即时归档类型
ARCH_DEST = GRP1_RWW_03  #即时归档目标实例名
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST = /dm8/data/DAMENG/arch #本地归档文件存放路径
ARCH_FILE_SIZE = 128  #单位 Mb,本地单个归档文件最大值
ARCH_SPACE_LIMIT  = 1024 #单位 Mb,0 表示无限制,范围 1024~4294967294M

配置为全局守护类型,使用自动切换模式

vim dmwatcher.ini

[GRP1]
DW_TYPE =GLOBAL #全局守护类型
DW_MODE = AUTO #自动切换模式
DW_ERROR_TIME = 10  #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #主库守护进程启动恢复的间隔时间
INST_ERROR_TIME = 10  #本地实例故障认定时间
INST_OGUID = 453332  #守护系统唯一 OGUID 值
INST_INI = /dm8/data/DAMENG/dm.ini  #dm.ini 配置文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /dm8/bin/dmserver #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阀值,默认关闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阀值,默认关闭

以 Mount 方式启动备库

./dmserver /dm/data/DAMENG/dm.ini mount

启动命令行工具 DIsql,登录备库设置 OGUID 值;备库修改数据库为 standby模式

[dmdba@localhost bin]$ ./disql 
disql V8
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间: 2.883(毫秒)
SQL> sp_set_para_value(1,'ALTER_MODE_STATUS',1);
DMSQL 过程已成功完成
已用时间: 6.885(毫秒). 执行号:1.
SQL> sp_set_oguid(453332);
DMSQL 过程已成功完成
已用时间: 5.944(毫秒). 执行号:2.
SQL> alter database standby;
操作已执行
已用时间: 3.685(毫秒). 执行号:0.
SQL> sp_set_para_value(1,'ALTER_MODE_STATUS',0);
DMSQL 过程已成功完成
已用时间: 3.545(毫秒). 执行号:3.
SQL> 

9.配置主库GRP1_RWW_03 数据库实例目录:/dm8/data/DAMENG
dm.ini 参数修改如下:

vim dm.ini

#实例名,建议使用―组名_守护环境_序号‖的命名方式,总长度不能超过 16
INSTANCE_NAME  = GRP1_RWW_03
PORT_NUM  = 5236 #数据库实例监听端口
DW_INACTIVE_INTERVAL  = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS  = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS  = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI  = 1 #打开归档配置
RLOG_SEND_APPLY_MON = 64 #统计最近 64 次的日志重演信息

配置 MAL 系统,各主备库的 dmmal.ini 配置必须完全一致
拷贝主库的即可

[dmdba@localhost DAMENG]$ scp 192.168.10.6:/dm8/data/DAMENG/dmmal.ini .
The authenticity of host '192.168.10.6 (192.168.10.6)' can't be established.
ECDSA key fingerprint is SHA256:PyvgBD9b1BWhTn/zbLuPRNDSE3q9WikYsolSn+Iae8o.
ECDSA key fingerprint is MD5:07:93:30:f0:bf:bf:2e:a0:14:09:bc:d2:16:8f:f4:ab.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.6' (ECDSA) to the list of known hosts.
[email protected]'s password: 
dmmal.ini                                                                                           100%  986   805.9KB/s   00:00    
[dmdba@localhost DAMENG]$ 

配置本地归档和即时归档

vim dmarch.ini

[ARCHIVE_TIMELY1]
ARCH_TYPE  = TIMELY  #即时归档类型
ARCH_DEST  = GRP1_RWW_01  #即时归档目标实例名
[ARCHIVE_TIMELY2]
ARCH_TYPE  = TIMELY  #即时归档类型
ARCH_DEST  = GRP1_RWW_02  #即时归档目标实例名
[ARCHIVE_LOCAL1]
ARCH_TYPE  = LOCAL #本地归档类型
ARCH_DEST  = /dm8/data/DAMENG/arch #本地归档文件存放路径
ARCH_FILE_SIZE = 128  #单位 Mb,本地单个归档文件最大值
ARCH_SPACE_LIMIT  = 1024 #单位 Mb,0 表示无限制,范围 1024~4294967294M

配置为全局守护类型,使用自动切换模式

vim dmwatcher.ini

[GRP1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = AUTO #自动切换模式
DW_ERROR_TIME = 10  #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #主库守护进程启动恢复的间隔时间
INST_ERROR_TIME = 10  #本地实例故障认定时间
INST_OGUID = 453332  #守护系统唯一 OGUID 值
INST_INI = /dm8/data/DAMENG/dm.ini  #dm.ini 配置文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /dm8/bin/dmserver  #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阀值,默认关闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阀值,默认关闭

以 Mount 方式启动备库

./dmserver /dm/data/DAMENG/dm.ini mount

启动命令行工具 DIsql,登录备库设置 OGUID 值;备库修改数据库为 standby模式

[dmdba@localhost bin]$ ./disql 
disql V8
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间: 3.870(毫秒)
SQL> sp_set_para_value(1,'ALTER_MODE_STATUS',1);
DMSQL 过程已成功完成
已用时间: 9.899(毫秒). 执行号:1.
SQL> sp_set_oguid(453332);
DMSQL 过程已成功完成
已用时间: 4.269(毫秒). 执行号:2.
SQL> alter database standby;
操作已执行
已用时间: 5.229(毫秒). 执行号:0.
SQL> sp_set_para_value(1,'ALTER_MODE_STATUS',0);
DMSQL 过程已成功完成
已用时间: 3.965(毫秒). 执行号:3.
SQL> 

10,配置监视器(监视器尽量配置再集群以外的机器),依次启动。

vim dmmonitor.ini

MON_DW_Confirm = 1 #确认监视器模式
MON_LOG_PATH = /dm8/data/log #监视器日志文件存放路径
MON_LOG_INTERVAL  = 60  #每隔 60s 定时记录系统信息到日志文件
MON_LOG_FILE_SIZE = 32  #每个日志文件最大 32M
MON_LOG_SPACE_LIMIT = 0 #不限定日志文件总占用空间
[GRP1]
MON_INST_OGUID = 453332 #组 GRP1 的唯一 OGUID 值
#以下配置为监视器到组 GRP1 的守护进程的连接信息,以―IP:PORT‖的形式配置
#IP 对应 dmmal.ini 中的 MAL_HOST,PORT 对应 dmmal.ini 中的 MAL_DW_PORT
MON_DW_IP = 192.168.10.6:52141
MON_DW_IP = 192.168.10.7:52142
MON_DW_IP = 192.168.10.8:52143

配置后台启动服务用确认监视器,
MON_DW_Confirm=0 为非确认监视器,仅供查看数据库集群状

启动数据库:

[dmdba@localhost bin]$ ./dmserver /dm8/data/DAMENG/dm.ini mount

启动守护

[dmdba@localhost bin]$ ./dmwatcher /dm8/data/DAMENG/dmwatcher.ini 
DMWATCHER[4.0] V8
DMWATCHER[4.0] IS READY

启动监视器

[dmdba@localhost bin]$ ./dmmonitor /dm8/data/DAMENG/dmmonitor.ini 
[monitor]         2020-08-26 23:47:18: DMMONITOR[4.0] V8
[monitor]         2020-08-26 23:47:18: DMMONITOR[4.0] IS READY.

[monitor]         2020-08-26 23:47:18: 收到守护进程(GRP1_RWW_02)消息
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN            
                  2020-08-26 15:48:19  OPEN           OK        GRP1_RWW_02      OPEN        STANDBY   NULL     2        36153           36153           

[monitor]         2020-08-26 23:47:18: 收到守护进程(GRP1_RWW_03)消息
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN            
                  2020-08-26 23:47:18  OPEN           OK        GRP1_RWW_03      OPEN        STANDBY   NULL     2        36153           36153           

[monitor]         2020-08-26 23:47:18: 收到守护进程(GRP1_RWW_01)消息
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN            
                  2020-08-26 15:48:19  OPEN           OK        GRP1_RWW_01      OPEN        PRIMARY   VALID    2        36153           36153  

show  ========查看集群状态
2020-08-26 23:47:35 
#================================================================================#
GROUP            OGUID       MON_CONFIRM     MODE            MPP_FLAG  
GRP1             453332      TRUE            AUTO            FALSE     


<<DATABASE GLOBAL INFO:>>
IP              MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT    
192.168.10.6    52141        2020-08-26 15:48:36  GLOBAL    VALID     OPEN           GRP1_RWW_01      OK        1     1     OPEN        PRIMARY   DSC_OPEN       TIMELY    VALID    

EP INFO:
INST_PORT  INST_OK   INAME            ISTATUS     IMODE     DSC_SEQNO  DSC_CTL_NODE RTYPE     RSTAT    FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG          
5236       OK        GRP1_RWW_01      OPEN        PRIMARY   0          0            TIMELY    VALID    3943            36153           3943            36153           NONE                  

<<DATABASE GLOBAL INFO:>>
IP              MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT    
192.168.10.7    52142        2020-08-26 15:48:36  GLOBAL    VALID     OPEN           GRP1_RWW_02      OK        1     1     OPEN        STANDBY   DSC_OPEN       TIMELY    VALID    

EP INFO:
INST_PORT  INST_OK   INAME            ISTATUS     IMODE     DSC_SEQNO  DSC_CTL_NODE RTYPE     RSTAT    FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG          
5236       OK        GRP1_RWW_02      OPEN        STANDBY   0          0            TIMELY    VALID    3941            36153           3941            36153           NONE                  

DATABASE(GRP1_RWW_02) APPLY INFO FROM (GRP1_RWW_01):
DSC_SEQNO[0], (ASEQ, SSEQ, KSEQ)[3943, 3943, 3943], (ALSN, SLSN, KLSN)[36153, 36153, 36153], N_TSK[0], TSK_MEM_USE[0]


<<DATABASE GLOBAL INFO:>>
IP              MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT    
192.168.10.8    52143        2020-08-26 23:47:35  GLOBAL    VALID     OPEN           GRP1_RWW_03      OK        1     1     OPEN        STANDBY   DSC_OPEN       TIMELY    VALID    

EP INFO:
INST_PORT  INST_OK   INAME            ISTATUS     IMODE     DSC_SEQNO  DSC_CTL_NODE RTYPE     RSTAT    FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG          
5236       OK        GRP1_RWW_03      OPEN        STANDBY   0          0            TIMELY    VALID    3941            36153           3941            36153           NONE                  

DATABASE(GRP1_RWW_03) APPLY INFO FROM (GRP1_RWW_01):
DSC_SEQNO[0], (ASEQ, SSEQ, KSEQ)[3943, 3943, 3943], (ALSN, SLSN, KLSN)[36153, 36153, 36153], N_TSK[0], TSK_MEM_USE[0]


#================================================================================#
                  

DM读写分离集群环境搭建_第1张图片
通过观察监视器,可知道集群状态正常;

11.以上操作都是dmdba用户执行,root用户配置后台开机自启服务
路径在数据库安装目录:/bin/script/root 下

[root@localhost root]# pwd
/dm8/script/root
[root@localhost root]# ls
dm_service_installer.sh  dm_service_uninstaller.sh  root_installer.sh
[root@localhost root]# ./dm_service_installer.sh -h
Usage: dm_service_installer.sh -t service_type [-p service_name_postfix] [-dm_ini dm_ini_file]
        [-watch_ini watch_ini_file ] [-wmon_ini wmon_ini_file] [-rww_ini rww_ini_file]
        [-watcher_ini watcher_ini_file ] [-monitor_ini monitor_ini_file] [-cssm_ini cssm_ini_file]
        [-dfs_ini dfs_ini_file] [-dcr_ini dcr_ini_file]
        [-dss_ini dss_ini_file] [-drs_ini drs_ini_file] [-dras_ini dras_ini_file] [-dcs_ini dcs_ini_file] [-server server_info]
        [-m open|mount] [-y dependent_service] [-auto true|false]
  or dm_service_installer.sh [-s service_file_path]
  or dm_service_installer.sh -h

   -t               服务类型,包括dmimon,dmap,dmserver,dmwatcher,dmmonitor,dmcss,dmcssm,dmasmsvr,dmdcs,dmdrs,dmdras,dmdss
   -p               服务名后缀,对于dmimon,dmap服务类型无效
   -dm_ini          dm.ini文件路径
   -watch_ini       dmwatch.ini文件路径.
   -wmon_ini        dmwmon.ini文件路径.
   -rww_ini         dmrww.ini文件路径.
   -watcher_ini     dmwatcher.ini文件路径.
   -monitor_ini     dmmonitor.ini文件路径.
   -dcr_ini         dmdcr.ini文件路径.
   -cssm_ini        dmcssm.ini文件路径.
   -dss_ini         dss.ini文件路径.
   -drs_ini         drs.ini文件路径.
   -dras_ini        dras.ini文件路径.
   -dcs_ini         dcs.ini文件路径.
   -dfs_ini         dfs.ini文件路径.
   -server          服务器信息(IP:PORT)
   -auto            设置服务是否自动启动,值为true或false,默认true.
   -m               设置服务器启动模式open或mount,只针对dmserver服务类型生效,可选
   -y               设置依赖服务,此选项只针对systemd服务环境下的dmserver和dmasmsvr服务生效
   -s               服务脚本路径,设置则忽略除-y外的其他参数选项
   -h               帮助
[root@localhost root]# 

配置主库GRP1_RWW_01

[root@localhost root]# ./dm_service_installer.sh -t dmserver -p 01 -dm_ini /dm8/data/DAMENG/dm.ini -m mount
Created symlink from /etc/systemd/system/multi-user.target.wants/DmService01.service to /usr/lib/systemd/system/DmService01.service.
创建服务(DmService01)完成
[root@localhost root]# ./dm_service_installer.sh -t dmwatcher -p 01 -watcher_ini /dm8/data/DAMENG/dmwatcher.ini 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherService01.service to /usr/lib/systemd/system/DmWatcherServic
e01.service.创建服务(DmWatcherService01)完成
[root@localhost root]# 

配置主库GRP1_RWW_02

[root@localhost root]# ./dm_service_installer.sh -t dmserver -p 02 -dm_ini /dm8/data/DAMENG/dm.ini -m mount 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmService02.service to /usr/lib/systemd/system/DmService02.service.
创建服务(DmService02)完成
[root@localhost root]# ./dm_service_installer.sh -t dmwatcher -p 02 -watcher_ini /dm8/data/DAMENG/dmwatcher.ini 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherService02.service to /usr/lib/systemd/system/DmWatcherServic
e02.service.创建服务(DmWatcherService02)

配置主库GRP1_RWW_03

[root@localhost root]# ./dm_service_installer.sh -t dmserver -p 03 -dm_ini /dm8/data/DAMENG/dm.ini -m mount 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmService03.service to /usr/lib/systemd/system/DmService03.service.
创建服务(DmService03)完成
[root@localhost root]# ./dm_service_installer.sh -t dmwatcher -p 03 -watcher_ini /dm8/data/DAMENG/dmwatcher.ini 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherService03.service to /usr/lib/systemd/system/DmWatcherServic
e03.service.创建服务(DmWatcherService03)完成

配置监视器的后台服务

[root@localhost root]# ./dm_service_installer.sh -t dmmonitor -p 03 -monitor_ini /dm8/data/DAMENG/dmmonitor.ini 
Created symlink from /etc/systemd/system/multi-user.target.wants/DmMonitorService03.service to /usr/lib/systemd/system/DmMonitorServic
e03.service.创建服务(DmMonitorService03)完成
[root@localhost root]# 

12.启动后台自启服务,使用非确认监视器查看;
分别依次启动各个数据库实例–守护–监视器;(先主后备)

GRP1_RWW_01

[dmdba@localhost bin]$ ./DmService01 start
Starting DmService01:                                      [ OK ]
[dmdba@localhost bin]$ ./DmWatcherService01 start
Starting DmWatcherService01:                               [ OK ]
[dmdba@localhost bin]$ 

GRP1_RWW_02

[dmdba@localhost bin]$ ./DmService02 start
Starting DmService02:                                      [ OK ]
[dmdba@localhost bin]$ ./DmWatcherService02 start
Starting DmWatcherService02:                               [ OK ]
[dmdba@localhost bin]$ 

GRP1_RWW_03

[dmdba@localhost bin]$ ./DmService03 start
Starting DmService03:                                      [ OK ]
[dmdba@localhost bin]$ ./DmWatcherService03 start
Starting DmWatcherService03:                               [ OK ]
[dmdba@localhost bin]$ ./DmMonitorService03 start
Starting DmMonitorService03:                               [ OK ]
[dmdba@localhost bin]$ 

到这里读写分离集群已经搭建完成了

关闭顺序:依次关闭监视器–守护–数据库实例
使用非确认监视器查看数据库集群状态:
DM读写分离集群环境搭建_第2张图片

你可能感兴趣的:(DM)