DM8配置读写分离集群

配置读写分离集群
下列机器事先都安装了DM,安装路径为’/dm8’,执行程序保存在’/dm8/bin’目录中,数据存放路径为’/dm8/data’。

各主备库的实例名建议采用“组名_守护环境_序号”的方式命名,方便按组区分不同实例,注意总长度不能超过16。本示例中组名为“GRP1”,配置为读写分离集群,主库命名为“JY1”,备库分别命名为JY2”和“JY3”。


机器名     IP地址                    初始状态                          操作系统
dm8rw1     10.10.13.213(对外)       主库 jy1                          redhat 7.8
           10.10.13.213(mal对内)

dm8rw2     10.10.13.214(对外)
           10.10.13.214(mal对内)     备库 jy2                          redhat 7.8

dm8rw3     10.10.13.215(对外)
           10.10.13.215(mal对内)     备库 jy3                          redhat 7.8

dm8rw4     10.10.13.216              确认监视器                       redhat 7.8



实例名              port_num             mal_inst_dw_port    mal_host                mal_port        mal_dw_port
jy1                 5236                 5237                10.10.13.213          5238            5239
jy2                 5236                 5237                10.10.13.214          5238            5239
jy3                 5236                 5237                10.10.13.215          5238            5239

安装DM数据库软件

数据准备
在主库机器上初始化数据库到目录/dm8/data:

[dmdba@dm8rw1 dm8]$ dminit path=/dm8/data db_name=jy instance_name=jy1 port_num=5236 page_size=8 charset=0
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2022-10-21
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL

 log file path: /dm8/data/jy/jy01.log


 log file path: /dm8/data/jy/jy02.log

write to dir [/dm8/data/jy].
create dm database success. 2022-01-18 21:10:20


创建DmAPService用于dmrman来执行备份
主库

[root@dm8rw1 bin]# /dm8/script/root/dm_service_installer.sh -t dmap
Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service.
Finished to create the service (DmAPService)

[root@dm8rw1 bin]# service DmAPService start
Redirecting to /bin/systemctl start DmAPService.service

备库jy2

[root@dm8rw2 bin]# /dm8/script/root/dm_service_installer.sh -t dmap
Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service.
Finished to create the service (DmAPService)

[root@dm8rw2 bin]# service DmAPService start
Redirecting to /bin/systemctl start DmAPService.service

备库jy3

[root@dm8rw3 bin]# /dm8/script/root/dm_service_installer.sh -t dmap
Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service.
Finished to create the service (DmAPService)
[root@dm8rw3 bin]# service DmAPService start
Redirecting to /bin/systemctl start DmAPService.service

注册服务用于启动数据库

[root@dm8rw1 bin]# /dm8/script/root/dm_service_installer.sh -dm_ini /dm8/data/jy/dm.ini -p jy1 -t dmserver
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicejy1.service to /usr/lib/systemd/system/DmServicejy1.service.
Finished to create the service (DmServicejy1)

正常启动数据库并正常关闭

[root@dm8rw1 bin]# service DmServicejy1 start
Redirecting to /bin/systemctl start DmServicejy1.service

[dmdba@dm8rw1 jy]$ disql SySDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is open
login used time : 4.305(ms)
disql V8
SQL> select instance_name from v$instance;

LINEID     INSTANCE_NAME
---------- -------------
1          JY1

used time: 5.512(ms). Execute id is 53700.

[root@dm8rw1 bin]# service DmServicejy1 stop
Redirecting to /bin/systemctl stop DmServicejy1.service

备份主库

1. 正常关闭数据库

[root@dm8rw1 bin]# service DmServicejy1 stop
Redirecting to /bin/systemctl stop DmServicejy1.service

2.使用dmrman来进行冷备份

[dmdba@dm8rw1 jy]$ dmrman CTLSTMT="backup database '/dm8/data/jy/dm.ini' full backupset  '/dm8/jy1_full_bak_1'"
dmrman V8
backup database '/dm8/data/jy/dm.ini' full backupset '/dm8/jy1_full_bak_1'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[26788], file_lsn[26788]
Processing backupset /dm8/jy1_full_bak_1
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:00][Remaining:00:00:00]
backup successfully!
time used: 00:00:01.468



将主库的备份复制备库:

[dmdba@dm8rw1 dm8]$ scp -r jy1_full_bak_1 10.10.13.214:/dm8
dmdba@10.10.13.214's password:
jy1_full_bak_1.bak                                                                                                                                                                                       100% 6334KB  24.8MB/s   00:00
jy1_full_bak_1.meta                                                                                                                                                                                      100%   77KB   4.2MB/s   00:00
[dmdba@dm8rw1 dm8]$ scp -r jy1_full_bak_1 10.10.13.215:/dm8
dmdba@10.10.13.215's password:
jy1_full_bak_1.bak                                                                                                                                                                                       100% 6334KB  10.9MB/s   00:00
jy1_full_bak_1.meta                                                                                                                                                                                      100%   77KB   1.2MB/s   00:00
[dmdba@dm8rw1 dm8]$

创建备库备库并恢复
备库jy2:

[dmdba@dm8rw2 dm8]$ dminit path=/dm8/data db_name=jy instance_name=jy2 port_num=5236 page_size=8 charset=0
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2022-10-21
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL

 log file path: /dm8/data/jy/jy01.log


 log file path: /dm8/data/jy/jy02.log

write to dir [/dm8/data/jy].
create dm database success. 2022-01-18 21:46:05

备库jy3:

[dmdba@dm8rw3 dm8]$ dminit path=/dm8/data db_name=jy instance_name=jy3 port_num=5236 page_size=8 charset=0
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2022-10-21
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL

 log file path: /dm8/data/jy/jy01.log


 log file path: /dm8/data/jy/jy02.log

write to dir [/dm8/data/jy].
create dm database success. 2022-01-18 21:46:37

恢复备库
备库jy2:

[dmdba@dm8rw2 ~]$ dmrman CTLSTMT="restore database '/dm8/data/jy/dm.ini' from backupset '/dm8/jy1_full_bak_1'"
dmrman V8
restore database '/dm8/data/jy/dm.ini' from backupset '/dm8/jy1_full_bak_1'
file dm.key not found, use default license!
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:05][Remaining:00:00:00]
restore successfully.
time used: 00:00:05.615

[dmdba@dm8rw2 ~]$ dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/jy/dm.ini' FROM BACKUPSET '/dm8/jy1_full_bak_1'"
dmrman V8
RECOVER DATABASE '/dm8/data/jy/dm.ini' FROM BACKUPSET '/dm8/jy1_full_bak_1'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[26788], file_lsn[26788]
no log generates while the backupset [/dm8/jy1_full_bak_1] created
recover successfully!
time used: 345.359(ms)

[dmdba@dm8rw2 ~]$ dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/jy/dm.ini' UPDATE DB_MAGIC"
dmrman V8
RECOVER DATABASE '/dm8/data/jy/dm.ini' UPDATE DB_MAGIC
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[26788], file_lsn[26788]
recover successfully!
time used: 00:00:01.066

备库jy3:

[dmdba@dm8rw3 ~]$ dmrman CTLSTMT="restore database '/dm8/data/jy/dm.ini' from backupset '/dm8/jy1_full_bak_1'"
dmrman V8
restore database '/dm8/data/jy/dm.ini' from backupset '/dm8/jy1_full_bak_1'
file dm.key not found, use default license!
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:06][Remaining:00:00:00]
restore successfully.
time used: 00:00:06.606
[dmdba@dm8rw3 ~]$ dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/jy/dm.ini' FROM BACKUPSET '/dm8/jy1_full_bak_1'"
dmrman V8
RECOVER DATABASE '/dm8/data/jy/dm.ini' FROM BACKUPSET '/dm8/jy1_full_bak_1'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[26788], file_lsn[26788]
no log generates while the backupset [/dm8/jy1_full_bak_1] created
recover successfully!
time used: 323.405(ms)
[dmdba@dm8rw3 ~]$ dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/jy/dm.ini' UPDATE DB_MAGIC"
dmrman V8
RECOVER DATABASE '/dm8/data/jy/dm.ini' UPDATE DB_MAGIC
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[26788], file_lsn[26788]
recover successfully!
time used: 00:00:01.069


配置操作
一.主库
配置dm.ini文件,配置以下参数

INSTANCE_NAME = jy1
PORT_NUM = 5236                             #数据库实例监听端口
DW_INACTIVE_INTERVAL = 60                   #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0                       #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2                       #不允许备库OFFLINE表空间
MAL_INI = 1                                 #打开MAL系统
ARCH_INI = 1                                #打开归档配置
RLOG_SEND_APPLY_MON = 64                    #统计最近64次的日志发送信息

配置dmmal.ini文件
配置MAL系统,各主备库的dmmal.ini配置必须完全一致,MAL_HOST使用内部网络IP,MAL_PORT与dm.ini中PORT_NUM使用不同的端口值,MAL_DW_PORT是各实例对应的守护进程之间,以及守护进程和监视器之间的通信端口,配置如下:

MAL_CHECK_INTERVAL = 5               #MAL链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 5           #判定MAL链路断开的时间

[MAL_INST1]
MAL_INST_NAME = jy1                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.213            #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.213       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口

[MAL_INST2]
MAL_INST_NAME = jy2                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.214            #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.214       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口

[MAL_INST3]
MAL_INST_NAME = jy3                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.215              #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.215       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口


[dmdba@dm8rw1 jy]$ vi dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5

[MAL_INST1]
MAL_INST_NAME = jy1
MAL_HOST = 10.10.13.213
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.213
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

[MAL_INST2]
MAL_INST_NAME = jy2
MAL_HOST = 10.10.13.214
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.214
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

[MAL_INST3]
MAL_INST_NAME = jy3
MAL_HOST = 10.10.13.215
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.215
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

配置dmarch.ini
修改dmarch.ini,配置本地归档和即时归档。
除了本地归档外,其他归档配置项中的ARCH_DEST表示实例是Primary模式时,需要同步归档数据的目标实例名。当前实例jy1是主库,需要向即时备库jy2/jy3同步数据,因此即时归档的ARCH_DEST分别配置为jy2和jy3。

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

[dmdba@dm8rw1 jy]$ vi dmarch.ini
[ARCHIVE_TIMELY1]
ARCH_TYPE = TIMELY
ARCH_DEST = jy2

[ARCHIVE_TIMELY2]
ARCH_TYPE = TIMELY
ARCH_DEST = jy3

[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

配置dmwatcher.ini
修改dmwatcher.ini配置守护进程,配置为全局守护类型,使用自动切换模式。

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


[dmdba@dm8rw1 jy]$ vi dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 222222
INST_INI = /dm8/data/jy/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

配置备库jy2
配置dm.ini文件,配置以下参数

INSTANCE_NAME = jy2
PORT_NUM = 5236                             #数据库实例监听端口
DW_INACTIVE_INTERVAL = 60                   #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0                       #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2                       #不允许备库OFFLINE表空间
MAL_INI = 1                                 #打开MAL系统
ARCH_INI = 1                                #打开归档配置
RLOG_SEND_APPLY_MON = 64                    #统计最近64次的日志发送信息

配置dmmal.ini文件
配置MAL系统,各主备库的dmmal.ini配置必须完全一致,MAL_HOST使用内部网络IP,MAL_PORT与dm.ini中PORT_NUM使用不同的端口值,MAL_DW_PORT是各实例对应的守护进程之间,以及守护进程和监视器之间的通信端口,配置如下:

MAL_CHECK_INTERVAL = 5               #MAL链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 5           #判定MAL链路断开的时间

[MAL_INST1]
MAL_INST_NAME = jy1                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.213            #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.213       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口

[MAL_INST2]
MAL_INST_NAME = jy2                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.214            #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.214       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口

[MAL_INST3]
MAL_INST_NAME = jy3                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.215              #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.215       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口


[dmdba@dm8rw2 jy]$ vi dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5

[MAL_INST1]
MAL_INST_NAME = jy1
MAL_HOST = 10.10.13.213
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.213
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

[MAL_INST2]
MAL_INST_NAME = jy2
MAL_HOST = 10.10.13.214
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.214
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

[MAL_INST3]
MAL_INST_NAME = jy3
MAL_HOST = 10.10.13.215
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.215
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

配置dmarch.ini
修改dmarch.ini,配置本地归档和即时归档。

除了本地归档外,其他归档配置项中的ARCH_DEST表示实例是Primary模式时,需要同步归档数据的目标实例名

当前实例jy2是备库,守护系统配置完成后,可能在各种故障处理中,jy2切换为新的主库,正常情况下,jy1会切换为新的备库,需要向jy1和jy3同步数据,因此即时归档的ARCH_DEST分别配置为jy1和jy3。

[dmdba@dm8rw2 jy]$ vi dmarch.ini
[ARCHIVE_TIMELY1]
ARCH_TYPE = TIMELY
ARCH_DEST = jy1

[ARCHIVE_TIMELY2]
ARCH_TYPE = TIMELY
ARCH_DEST = jy3

[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

配置dmwatcher.ini
修改dmwatcher.ini配置守护进程,配置为全局守护类型,使用自动切换模式。

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


[dmdba@dm8rw2 jy]$ vi dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 222222
INST_INI = /dm8/data/jy/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

配置备库jy3
配置dm.ini文件,配置以下参数

INSTANCE_NAME = jy3
PORT_NUM = 5236                             #数据库实例监听端口
DW_INACTIVE_INTERVAL = 60                   #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0                       #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2                       #不允许备库OFFLINE表空间
MAL_INI = 1                                 #打开MAL系统
ARCH_INI = 1                                #打开归档配置
RLOG_SEND_APPLY_MON = 64                    #统计最近64次的日志发送信息

配置dmmal.ini文件
配置MAL系统,各主备库的dmmal.ini配置必须完全一致,MAL_HOST使用内部网络IP,MAL_PORT与dm.ini中PORT_NUM使用不同的端口值,MAL_DW_PORT是各实例对应的守护进程之间,以及守护进程和监视器之间的通信端口,配置如下:

MAL_CHECK_INTERVAL = 5               #MAL链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 5           #判定MAL链路断开的时间

[MAL_INST1]
MAL_INST_NAME = jy1                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.213            #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.213       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口

[MAL_INST2]
MAL_INST_NAME = jy2                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.214            #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.214       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口

[MAL_INST3]
MAL_INST_NAME = jy3                  #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 10.10.13.215              #MAL系统监听TCP连接的IP地址
MAL_PORT = 5238                      #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.215       #实例的对外服务IP地址
MAL_INST_PORT = 5236                 #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5239                   #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5237              #实例监听守护进程TCP连接的端口


[dmdba@dm8rw3 jy]$ vi dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5

[MAL_INST1]
MAL_INST_NAME = jy1
MAL_HOST = 10.10.13.213
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.213
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

[MAL_INST2]
MAL_INST_NAME = jy2
MAL_HOST = 10.10.13.214
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.214
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

[MAL_INST3]
MAL_INST_NAME = jy3
MAL_HOST = 10.10.13.215
MAL_PORT = 5238
MAL_INST_HOST = 10.10.13.215
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5237

配置dmarch.ini
修改dmarch.ini,配置本地归档和即时归档。

除了本地归档外,其他归档配置项中的ARCH_DEST表示实例是Primary模式时,需要同步归档数据的目标实例名

当前实例jy3是备库,守护系统配置完成后,可能在各种故障处理中,jy3切换为新的主库,正常情况下,jy1会切换为新的备库,需要向jy1和jy2同步数据,因此即时归档的ARCH_DEST分别配置为jy1和jy2。

[dmdba@dm215 jy]$ vi dmarch.ini
[ARCHIVE_TIMELY1]
ARCH_TYPE = TIMELY
ARCH_DEST = jy1

[ARCHIVE_TIMELY2]
ARCH_TYPE = TIMELY
ARCH_DEST = jy2

[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

配置dmwatcher.ini
修改dmwatcher.ini配置守护进程,配置为全局守护类型,使用自动切换模式。

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


[dmdba@dm8rw3 jy]$ vi dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 222222
INST_INI = /dm8/data/jy/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

二:
主库启动到mount状态设置oguid

[dmdba@dm8rw1 ~]$ dmserver /dm8/data/jy/dm.ini mount
file dm.key not found, use default license!
version info: develop
DM Database Server x64 V8 1-2-84-21.10.21-149328-10032-ENT  startup...
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
License will expire on 2022-10-21
file lsn: 25300
ndct db load finished
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct fill fast pool finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
SYSTEM IS READY.


[dmdba@dm8rw1 jy]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is mount
login used time : 3.177(ms)
disql V8
SQL> sp_set_oguid(222222);
DMSQL executed successfully
used time: 66.753(ms). Execute id is 0.
SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          26788                26788

used time: 3.112(ms). Execute id is 1.
SQL> select permanent_magic;

LINEID     PERMANENT_MAGIC
---------- ---------------
1          518889968

used time: 1.941(ms). Execute id is 2.

备库jy2启动到mount状态设置oguid

[dmdba@dm8rw2 ~]$ dmserver /dm8/data/jy/dm.ini mount
file dm.key not found, use default license!
version info: develop
DM Database Server x64 V8 1-2-84-21.10.21-149328-10032-ENT  startup...
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
License will expire on 2022-10-21
file lsn: 26788
ndct db load finished
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct fill fast pool finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
SYSTEM IS READY.



[dmdba@dm8rw2 jy]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is mount
login used time : 5.278(ms)
disql V8
SQL> sp_set_oguid(222222);
DMSQL executed successfully
used time: 114.383(ms). Execute id is 0.
SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          26788                26788

used time: 19.022(ms). Execute id is 1.
SQL> select permanent_magic;

LINEID     PERMANENT_MAGIC
---------- ---------------
1          518889968

used time: 1.356(ms). Execute id is 2.

备库jy3启动到mount状态设置oguid

[dmdba@dm8rw3 ~]$ dmserver /dm8/data/jy/dm.ini mount
file dm.key not found, use default license!
version info: develop
DM Database Server x64 V8 1-2-84-21.10.21-149328-10032-ENT  startup...
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
Database mode = 0, oguid = 0
License will expire on 2022-10-21
file lsn: 26788
ndct db load finished
ndct second level fill fast pool finished
ndct third level fill fast pool finished
ndct fill fast pool finished
nsvr_startup end.
aud sys init success.
aud rt sys init success.
systables desc init success.
ndct_db_load_info success.
SYSTEM IS READY.


[dmdba@dm8rw3 jy]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is mount
login used time : 5.145(ms)
disql V8
SQL> sp_set_oguid(222222);
DMSQL executed successfully
used time: 110.938(ms). Execute id is 0.
SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          26788                26788

used time: 14.513(ms). Execute id is 1.
SQL> select permanent_magic;

LINEID     PERMANENT_MAGIC
---------- ---------------
1          518889968

used time: 1.549(ms). Execute id is 2.

备库jy2注册服务用于启动数据库

[root@dm8rw2 ~]# /dm8/script/root/dm_service_installer.sh -dm_ini /dm8/data/jy/dm.ini -p jy2 -t dmserver
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicejy2.service to /usr/lib/systemd/system/DmServicejy2.service.
Finished to create the service (DmServicejy2)

备库jy3注册服务用于启动数据库

[root@dm8rw3 ~]# /dm8/script/root/dm_service_installer.sh -dm_ini /dm8/data/jy/dm.ini -p jy3 -t dmserver
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicejy3.service to /usr/lib/systemd/system/DmServicejy3.service.
Finished to create the service (DmServicejy3)

三:
主库以primary打开

[dmdba@dm8rw1 jy]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is mount
login used time : 2.961(ms)
disql V8
SQL> alter database primary;
executed successfully
used time: 58.207(ms). Execute id is 0.

备库jy2以standby 打开

[dmdba@dm8rw2 jy]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is mount
login used time : 2.221(ms)
disql V8
SQL> alter database standby;
executed successfully
used time: 145.716(ms). Execute id is 0.

备库jy3以standby 打开

[dmdba@dm8rw3 jy]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is mount
login used time : 2.978(ms)
disql V8
SQL> alter database standby;
executed successfully
used time: 72.982(ms). Execute id is 0.

启动命令行工具DIsql,登录备库修改数据库为Standby模式如果当前数据库不是normal模式,需要先修改dm.ini中ALTER_MODE_STATUS值为1,允许修改数据库模式,修改Standby模式成功后再改回为0。如果是normal模式,请忽略下面的第1步和第3步。

SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1); ----第1步
SQL>alter database standby; ----第2步
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0); ----第3步

四:
启动守护进程
启动各个主备库上的守护进程:
主库

[dmdba@dm8rw1 ~]$ dmwatcher /dm8/data/jy/dmwatcher.ini
DMWATCHER[4.0] V8
DMWATCHER[4.0] IS READY
show
2022-01-18 22:23:19
---------------------------------------------------------------------------
GROUP_NAME       TYPE      MODE      OGUID       MPP_FLAG  AUTO_RESTART DW_STATUS       DW_SUB_STATUS   DW_CTL_STATUS
GRP1             GLOBAL    AUTO      222222      FALSE     TRUE         RECOVERY        WAIT_SEND_ARCH  VALID

INST_OK   NAME             SVR_MODE  SYS_STATUS   RTYPE     FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG
OK        JY1              PRIMARY   OPEN         TIMELY    4205            28044           4205            28044           4
---------------------------------------------------------------------------


备库jy2

[dmdba@dm8rw2 ~]$ dmwatcher /dm8/data/jy/dmwatcher.ini
DMWATCHER[4.0] V8
DMWATCHER[4.0] IS READY
show
2022-01-18 22:23:28
---------------------------------------------------------------------------
GROUP_NAME       TYPE      MODE      OGUID       MPP_FLAG  AUTO_RESTART DW_STATUS       DW_SUB_STATUS   DW_CTL_STATUS
GRP1             GLOBAL    AUTO      222222      FALSE     TRUE         OPEN            SUB_STATE_START VALID

INST_OK   NAME             SVR_MODE  SYS_STATUS   RTYPE     FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG
OK        JY2              STANDBY   OPEN         TIMELY    4204            28044           4204            28044           0

DATABASE(JY2) APPLY INFO:
REDOS_PARALLEL_NUM (1)
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4205, 4205, 4205], (RLSN, SLSN, KLSN)[28044, 28044, 28044], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28044)

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

备库jy3

[dmdba@dm8rw3 ~]$ dmwatcher /dm8/data/jy/dmwatcher.ini
DMWATCHER[4.0] V8
DMWATCHER[4.0] IS READY
show
2022-01-18 22:23:35
---------------------------------------------------------------------------
GROUP_NAME       TYPE      MODE      OGUID       MPP_FLAG  AUTO_RESTART DW_STATUS       DW_SUB_STATUS   DW_CTL_STATUS
GRP1             GLOBAL    AUTO      222222      FALSE     TRUE         OPEN            SUB_STATE_START VALID

INST_OK   NAME             SVR_MODE  SYS_STATUS   RTYPE     FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG
OK        JY3              STANDBY   OPEN         TIMELY    4204            28044           4204            28044           0

DATABASE(JY3) APPLY INFO:
REDOS_PARALLEL_NUM (1)
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4205, 4205, 4205], (RLSN, SLSN, KLSN)[28044, 28044, 28044], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28044)

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

也可以注册守护进程服务来进行启动
主库

[root@dm8rw1 ~]# /dm8/script/root/dm_service_installer.sh -watcher_ini /dm8/data/jy/dmwatcher.ini -p jy1 -t dmwatcher
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicejy1.service to /usr/lib/systemd/system/DmWatcherServicejy1.service.
Finished to create the service (DmWatcherServicejy1)

[root@dm8rw1 ~]# service DmWatcherServicejy1 start
Redirecting to /bin/systemctl start DmWatcherServicejy1.service

备库1

[root@dm8rw2 ~]# /dm8/script/root/dm_service_installer.sh -watcher_ini /dm8/data/jy/dmwatcher.ini -p jy2 -t dmwatcher
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicejy2.service to /usr/lib/systemd/system/DmWatcherServicejy2.service.
Finished to create the service (DmWatcherServicejy2)

[root@dm8rw2 ~]# service DmWatcherServicejy2 start
Redirecting to /bin/systemctl start DmWatcherServicejy2.service

备库2

[root@dm8rw3 ~]# /dm8/script/root/dm_service_installer.sh -watcher_ini /dm8/data/jy/dmwatcher.ini -p jy3 -t dmwatcher
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicejy3.service to /usr/lib/systemd/system/DmWatcherServicejy3.service.
Finished to create the service (DmWatcherServicejy3)

[root@dm8rw3 ~]# service DmWatcherServicejy3 start
Redirecting to /bin/systemctl start DmWatcherServicejy3.service

配置监视器
由于主库和即时备库的守护进程配置为自动切换模式,因此这里选择配置确认监视器。和普通监视器相比,确认监视器除了相同的命令支持外,在主库发生故障时,能够自动通知即时备库接管为新的主库,具有自动故障处理的功能。

修改dmmonitor.ini配置确认监视器,其中MON_DW_IP中的IP和PORT和dmmal.ini中的MAL_HOST和MAL_DW_PORT配置项保持一致。

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 = 222222                     #组GRP1的唯一OGUID值
                                            #以下配置为监视器到组GRP1的守护进程的连接信息,以“IP:PORT”的形式配置
                                            #IP对应dmmal.ini中的MAL_HOST,PORT对应dmmal.ini中的MAL_DW_PORT
MON_DW_IP = 10.10.13.213:5238
MON_DW_IP = 10.10.13.214:5238
MON_DW_IP = 10.10.13.215:5238


[dmdba@dm216 data]$ vi dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0

[GRP1]
MON_INST_OGUID = 222222



MON_DW_IP = 10.10.13.213:5238
MON_DW_IP = 10.10.13.214:5238
MON_DW_IP = 10.10.13.215:5238

启动监视器:

[dmdba@dm8rw4 data]$ dmmonitor /dm8/data/dmmonitor.ini
[monitor]         2022-01-18 22:28:01: DMMONITOR[4.0] V8
[monitor]         2022-01-18 22:28:02: DMMONITOR[4.0] IS READY.

[monitor]         2022-01-18 22:28:02: Received message from(JY1)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-18 22:28:02  OPEN           OK        JY1              OPEN        PRIMARY   VALID    3        28044           28044

[monitor]         2022-01-18 22:28:02: Received message from(JY3)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-18 22:28:02  OPEN           OK        JY3              OPEN        STANDBY   VALID    3        28044           28044

[monitor]         2022-01-18 22:28:02: Received message from(JY2)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-18 22:28:02  OPEN           OK        JY2              OPEN        STANDBY   VALID    3        28044           28044

show
2022-01-18 22:28:11
#================================================================================#
GROUP            OGUID       MON_CONFIRM     MODE            MPP_FLAG
GRP1             222222      TRUE            AUTO            FALSE


< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
10.10.13.213      5239         2022-01-18 22:28:10  GLOBAL    VALID     OPEN           JY1              OK        1     1     OPEN        PRIMARY   DSC_OPEN       TIMELY    VALID

EP INFO:
INST_IP             INST_PORT  INST_OK   INAME            ISTATUS     IMODE     DSC_SEQNO  DSC_CTL_NODE RTYPE     RSTAT    FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG
10.10.13.213      5236       OK        JY1              OPEN        PRIMARY   0          0            TIMELY    VALID    4207            28044           4207            28044           NONE

< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
10.10.13.214      5239         2022-01-18 22:28:10  GLOBAL    VALID     OPEN           JY2              OK        1     1     OPEN        STANDBY   DSC_OPEN       TIMELY    VALID

EP INFO:
INST_IP             INST_PORT  INST_OK   INAME            ISTATUS     IMODE     DSC_SEQNO  DSC_CTL_NODE RTYPE     RSTAT    FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG
10.10.13.214      5236       OK        JY2              OPEN        STANDBY   0          0            TIMELY    VALID    4204            28044           4204            28044           NONE

DATABASE(JY2) APPLY INFO FROM (JY1), REDOS_PARALLEL_NUM (1):
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4207, 4207, 4207], (RLSN, SLSN, KLSN)[28044, 28044, 28044], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28044)


< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
10.10.13.215      5239         2022-01-18 22:28:10  GLOBAL    VALID     OPEN           JY3              OK        1     1     OPEN        STANDBY   DSC_OPEN       TIMELY    VALID

EP INFO:
INST_IP             INST_PORT  INST_OK   INAME            ISTATUS     IMODE     DSC_SEQNO  DSC_CTL_NODE RTYPE     RSTAT    FSEQ            FLSN            CSEQ            CLSN            DW_STAT_FLAG
10.10.13.215      5236       OK        JY3              OPEN        STANDBY   0          0            TIMELY    VALID    4204            28044           4204            28044           NONE

DATABASE(JY3) APPLY INFO FROM (JY1), REDOS_PARALLEL_NUM (1):
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4207, 4207, 4207], (RLSN, SLSN, KLSN)[28044, 28044, 28044], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28044)


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

测试数据同步
主库:

SQL> create table test(id number(10));
executed successfully
used time: 198.382(ms). Execute id is 103.
SQL> insert into test values(1);
affect rows 1

SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          29574                29574

used time: 0.350(ms). Execute id is 501.



used time: 1.182(ms). Execute id is 104.
SQL> commit;
executed successfully
used time: 12.799(ms). Execute id is 105.

备库jy2:

SQL> select * from test;

LINEID     ID
---------- --
1          1

used time: 2.615(ms). Execute id is 202.
SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          29574                29574

used time: 5.798(ms). Execute id is 0.

备库jy3:

SQL> select * from test;

LINEID     ID
---------- --
1          1

used time: 2.691(ms). Execute id is 202.
SQL> select file_LSN, cur_LSN from v$rlog;
LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          29574                29574

used time: 5.949(ms). Execute id is 0.

接口说明

DM多种客户端接口都支持读写分离集群连接设置,以下说明客户端连接服务器时如何设置读写分离属性,详细可参考《DM8程序员手册》。4

JDBC接口
在JDBC连接串中增加了两个连接属性:
n rwSeparate 是否使用读写分离系统,默认0;取值(0不使用,1使用)。
n rwPercent 分发到主库的事务占主备库总事务的百分比,有效值0~100,默认值25。
dm.jdbc.driver.DmDriver
jdbc:dm://192.168.0.206:5236?rwSeparate=1&rwPercent=10

发表评论

电子邮件地址不会被公开。