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

DM8 数据守护实时主备搭建

数据守护实时主备搭建

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

各主备库的实例名建议采用“组名_守护环境_序号”的方式命名,方便按组区分不同实例,注意总长度不能超过16。本示例中组名为“GRP1”,配置为实时主备,主库命名为“GRP1_RT_01”,备库命名为“GRP1_RT_02”。

机器名     IP地址                  初始状态                         操作系统
dm209     10.10.13.209(对外)     主库 dm1                         redhat 7.8
          11.11.11.209(mal对内)


dm210    10.10.13.210(对外)
         11.11.11.210(mal对内)     备库 dm2                         redhat 7.8

dm211    11.11.11.211            确认监视器                       redhat 7.8


实例名       port_num             mal_inst_dw_port    mal_host              mal_port        mal_dw_port
dm1          5236                 5239                11.11.11.209          5237            5238
dm2          5236                 5239                11.11.11.210          5237            5238

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

[dmdba@dm209 dm8]$ dminit path=/dm8/data db_name=dm instance_name=dm1 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/dm/dm01.log


 log file path: /dm8/data/dm/dm02.log

write to dir [/dm8/data/dm].
create dm database success. 2022-01-13 10:28:01

注册服务用于启动数据库

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

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

[root@dm209 root]# service DmServicedm1 start
Redirecting to /bin/systemctl start DmServicedm1.service
[root@dm209 root]# ps -ef | grep dmserver
dmdba    18402     1 17 10:33 ?        00:00:04 /dm8/bin/dmserver path=/dm8/data/dm/dm.ini -noconsole
root     18487  4030  0 10:34 pts/1    00:00:00 grep --color=auto dmserver

[root@dm209 ~]# su - dmdba
Last login: Thu Jan 13 10:16:30 CST 2022 on pts/1
[dmdba@dm209 ~]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is normal, state is open
login used time : 7.108(ms)
disql V8
SQL> exit

[root@dm209 ~]# service DmServicedm1 stop
Redirecting to /bin/systemctl stop DmServicedm1.service

注册服务用于将数据库启动到mount状态

[root@dm209 root]# ./dm_service_installer.sh -dm_ini /dm8/data/dm/dm.ini -p dm1mount -t dmserver -m mount
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedm1mount.service to /usr/lib/systemd/system/DmServicedm1mount.service.
Finished to create the service (DmServicedm1mountT)

备份主库
使用联机备份:

[root@dm209 root]# ./dm_service_installer.sh -t dmap -dm_ini /dm8/data/dm/dm.ini
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@dm209 root]# service DmAPService start
Redirecting to /bin/systemctl start DmAPService.service


SQL> BACKUP DATABASE FULL BACKUPSET '/dm8/data/dm_full_01';
executed successfully
used time: 00:00:02.521. Execute id is 501.

创建备库备库并恢复

[dmdba@dm210 data]$ dminit path=/dm8/data db_name=dm instance_name=dm2 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/dm/dm01.log


 log file path: /dm8/data/dm/dm02.log

write to dir [/dm8/data/dm].
create dm database success. 2022-01-13 16:02:51


将主库的备份复制备库:

[root@dm209 data]# scp -r dm_full_01 10.10.13.210:/dm8/data
root@10.10.13.210's password:
dm_full_01.bak                                                                                                                                                                                           100%   15MB  30.7MB/s   00:00
dm_full_01_1.bak                                                                                                                                                                                         100%  164KB   6.2MB/s   00:00
dm_full_01.meta                                                                                                                                                                                          100%   85KB   3.6MB/s   00:00
[root@dm209 data]#

恢复备库:

[dmdba@dm210 data]$ dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/dm/dm.ini' FROM BACKUPSET '/dm8/data/dm_full_01'"
dmrman V8
RESTORE DATABASE '/dm8/data/dm/dm.ini' FROM BACKUPSET '/dm8/data/dm_full_01'
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.629

[dmdba@dm210 ~]$ dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/dm/dm.ini' FROM BACKUPSET '/dm8/data/dm_full_01'"
dmrman V8
RECOVER DATABASE '/dm8/data/dm/dm.ini' FROM BACKUPSET '/dm8/data/dm_full_01'
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[25922], file_lsn[25922]
[Percent:100.00%][Speed:0.00PKG/s][Cost:00:00:00][Remaining:00:00:00]
recover successfully!
time used: 00:00:02.895

[dmdba@dm210 ~]$ dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/dm/dm.ini' UPDATE DB_MAGIC"
dmrman V8
RECOVER DATABASE '/dm8/data/dm/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[26568], file_lsn[26568]
recover successfully!
time used: 00:00:01.093


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

DW_INACTIVE_INTERVAL = 60   #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0       #不允许手工方式修改实例模式/状态
ENABLE_OFFLINEi_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 = dm1              #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 11.11.11.209          #MAL系统监听TCP连接的IP地址
MAL_PORT = 5237                  #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.209   #实例的对外服务IP地址
MAL_INST_PORT = 5236             #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5238               #实例本地的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5239          #实例监听守护进程TCP连接的端口

[MAL_INST2]
MAL_INST_NAME = dm2              #实例名,和dm.ini中的INSTANCE_NAME一致
MAL_HOST = 11.11.11.210          #MAL系统监听TCP连接的IP地址
MAL_PORT = 5237                  #MAL系统监听TCP连接的端口
MAL_INST_HOST = 10.10.13.210   #实例的对外服务IP地址
MAL_INST_PORT = 5236             #实例的对外服务端口,和dm.ini中的PORT_NUM一致
MAL_DW_PORT = 5238               #实例本地的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5239          #实例监听守护进程TCP连接的端口
[dmdba@dm209 dm]$ vi dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5

[MAL_INST1]
MAL_INST_NAME = dm1
MAL_HOST = 11.11.11.209
MAL_PORT = 5237
MAL_INST_HOST = 10.10.13.209
MAL_INST_PORT = 5236
MAL_DW_PORT = 5238
MAL_INST_DW_PORT = 5239

[MAL_INST2]
MAL_INST_NAME = dm2
MAL_HOST = 11.11.11.210
MAL_PORT = 5237
MAL_INST_HOST = 10.10.13.210
MAL_INST_PORT = 5236
MAL_DW_PORT = 5238
MAL_INST_DW_PORT = 5239

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

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


[dmdba@dm209 dm]$ vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = dm2
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/data/dm/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 = 111111                                      #守护系统唯一OGUID值
INST_INI = /dm8/data/dm/dm.ini                       #dm.ini配置文件路径
INST_AUTO_RESTART = 1                                    #打开实例的自动启动功能(建议设置成0)
INST_STARTUP_CMD = /dm8/bin/dmserver                     #命令行方式启动
RLOG_SEND_THRESHOLD = 0                                  #指定主库发送日志到备库的时间阀值,默认关闭
RLOG_APPLY_THRESHOLD = 0                                 #指定备库重演日志的时间阀值,默认关闭

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

以mount模式启动主库

[root@dm209 root]# service DmServicedm1 stop
Redirecting to /bin/systemctl stop DmServicedm1.service

[root@dm209 root]# service DmServicedm1mountT start
Redirecting to /bin/systemctl start DmServicedm1mountT.service

设置主库 OGUID

SQL> sp_set_oguid(111111);
DMSQL executed successfully
used time: 115.044(ms). Execute id is 0.

修改主数据库模式

SQL> alter database primary;
executed successfully
used time: 80.002(ms). Execute id is 0.

将主库的dm.ini,dmmal.ini,dmarch.ini,dmwatcher.ini文件复制到备库

[root@dm209 dm]# scp dm*.ini 10.10.13.210:/dm8/data/dm
root@10.10.13.210's password:
dmarch.ini                                                                                                                                                                                               100%  346    18.3KB/s   00:00
dm.ini                                                                                                                                                                                                   100%   52KB  29.9MB/s   00:00
dmmal.ini                                                                                                                                                                                                100%  547    16.9KB/s   00:00
dmwatcher.ini                                                                                                                                                                                            100%  568   332.1KB/s   00:00
[root@dm209 dm]#

二备库
备机修改相关配置
修改dm.ini

INSTANCE_NAME = DM2

dmmal.ini与主库一致不用修改

修改dmarch.ini

ARCH_DEST = DM1

dmwatcher.ini 和主库一致

注册服务用于启动数据库到mount状态

[root@dm210 root]# ./dm_service_installer.sh -dm_ini /dm8/data/dm/dm.ini -p dm2mount -t dmserver -m mount
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedm2mount.service to /usr/lib/systemd/system/DmServicedm2mount.service.
Finished to create the service (DmServicedm2mount)

注册服务用于启动数据库

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

以mount方式启动备库

[root@dm210 root]# service DmServicedm2mount start
Redirecting to /bin/systemctl start DmServicedm2mount.service

设置备库 OGUID

SQL> sp_set_oguid(111111);
DMSQL executed successfully
used time: 115.044(ms). Execute id is 0.

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

SQL> alter database standby;
alter database standby;
[-720]:Error in line: 1
Dmwatcher is active, or current configuration(ALTER_MODE_STATUS) not allowed to alter database.
used time: 0.636(ms). Execute id is 0.
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
DMSQL executed successfully
used time: 7.791(ms). Execute id is 1.
SQL> alter database standby;
executed successfully
used time: 94.298(ms). Execute id is 0.
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
DMSQL executed successfully
used time: 8.414(ms). Execute id is 2.

注册并启动守护进程
主库

[root@dm209 root]# ./dm_service_installer.sh -watcher_ini /dm8/data/dm/dmwatcher.ini -p dw1 -t dmwatcher
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedw1.service to /usr/lib/systemd/system/DmWatcherServicedw1.service.
Finished to create the service (DmWatcherServicedw1)

[root@dm209 root]# service DmWatcherServicedw1 start
Redirecting to /bin/systemctl start DmWatcherServicedw1.service

备库

[root@dm210 root]# ./dm_service_installer.sh -watcher_ini /dm8/data/dm/dmwatcher.ini -p dw2 -t dmwatcher
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedw2.service to /usr/lib/systemd/system/DmWatcherServicedw2.service.
Finished to create the service (DmWatcherServicedw2)

[root@dm210 root]# service DmWatcherServicedw2 start
Redirecting to /bin/systemctl start DmWatcherServicedw2.service

查看file_lsn与cur_lsn主备库是否一致
主库

[dmdba@dm209 arch]$ disql SYSDBA/SYSDBA

Server[LOCALHOST:5236]:mode is primary, state is mount
login used time : 4.992(ms)
disql V8
SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          28059                28059

used time: 4.592(ms). Execute id is 700.

备库

[dmdba@dm210 ~]$ disql SYsDBA/SYSDBA

Server[LOCALHOST:5236]:mode is standby, state is open
login used time : 5.676(ms)
disql V8
SQL> select file_LSN, cur_LSN from v$rlog;

LINEID     FILE_LSN             CUR_LSN
---------- -------------------- --------------------
1          28059                28059

used time: 3.306(ms). Execute id is 200.

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

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

[dmdba@dm211 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 = 111111


MON_DW_IP = 11.11.11.209:5238
MON_DW_IP = 11.11.11.210:5238

启动监视器:

[dmdba@dm211 data]$ dmmonitor /dm8/data/dmmonitor.ini
[monitor]         2022-01-14 10:43:58: DMMONITOR[4.0] V8
[monitor]         2022-01-14 10:43:58: DMMONITOR[4.0] IS READY.

[monitor]         2022-01-14 10:43:58: Received message from(DM1)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 10:43:57  OPEN           OK        DM1              OPEN        PRIMARY   VALID    3        28059           28059

[monitor]         2022-01-14 10:43:58: Received message from(DM2)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 10:43:57  OPEN           OK        DM2              OPEN        STANDBY   VALID    3        28059           28059


show
2022-01-14 10:44:26
#================================================================================#
GROUP            OGUID       MON_CONFIRM     MODE            MPP_FLAG
GRP1             111111      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
11.11.11.209        5238         2022-01-14 10:44:24  GLOBAL    VALID     OPEN           DM1              OK        1     1     OPEN        PRIMARY   DSC_OPEN       REALTIME  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.209      5236       OK        DM1              OPEN        PRIMARY   0          0            REALTIME  VALID    4264            28059           4264            28059           NONE

< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
11.11.11.210        5238         2022-01-14 10:44:25  GLOBAL    VALID     OPEN           DM2              OK        1     1     OPEN        STANDBY   DSC_OPEN       REALTIME  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.210      5236       OK        DM2              OPEN        STANDBY   0          0            REALTIME  VALID    4210            28059           4210            28059           NONE

DATABASE(DM2) APPLY INFO FROM (DM1), REDOS_PARALLEL_NUM (1):
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4264, 4264, 4264], (RLSN, SLSN, KLSN)[28059, 28059, 28059], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28059)


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

或者[root@ora19c root]# ./dm_service_installer.sh -i /dm8/data/dmmonitor.ini -p DM -t dmmonitor

ln -s '/usr/lib/systemd/system/DmMonitorServiceDM.service' '/etc/systemd/system/multi-user.target.wants/DmMonitorServiceDM.service'
Finished to create the service (DmMonitorServiceDM)

使用服务方式启动不能执行相关命令来显示监控信息所以一般不使用

主备同步测试
主库:

[dmdba@dm209 arch]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is primary, state is open
login used time : 6.172(ms)
disql V8
SQL> create table t1(id int);
executed successfully
used time: 60.028(ms). Execute id is 800.
SQL> insert into t1 values(1);
affect rows 1

used time: 1.253(ms). Execute id is 801.
SQL> commit;
executed successfully
used time: 2.770(ms). Execute id is 802.
SQL> select * from t1;

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

used time: 1.224(ms). Execute id is 803.

备库:

[dmdba@dm210 ~]$ disql SYSDBA/SYSDBA@localhost:5236

Server[localhost:5236]:mode is standby, state is open
login used time : 5.946(ms)
disql V8
SQL> select * from t1;

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

used time: 7.131(ms). Execute id is 300.

主库:

SQL> update t1 set id=2;
affect rows 1

used time: 1.081(ms). Execute id is 804.
SQL> commit;
executed successfully
used time: 2.552(ms). Execute id is 805.
SQL> select * from t1;

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

used time: 0.435(ms). Execute id is 806.

备库:

SQL> select * from t1;

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

used time: 2.014(ms). Execute id is 301.

主备切换测试
操作直接在监控器里执行。
Switchover 切换



show
2022-01-14 11:15:30
#================================================================================#
GROUP            OGUID       MON_CONFIRM     MODE            MPP_FLAG
GRP1             111111      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
11.11.11.209        5238         2022-01-14 11:15:29  GLOBAL    VALID     OPEN           DM1              OK        1     1     OPEN        PRIMARY   DSC_OPEN       REALTIME  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.209      5236       OK        DM1              OPEN        PRIMARY   0          0            REALTIME  VALID    4288            28136           4288            28136           NONE

< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
11.11.11.210        5238         2022-01-14 11:15:29  GLOBAL    VALID     OPEN           DM2              OK        1     1     OPEN        STANDBY   DSC_OPEN       REALTIME  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.210      5236       OK        DM2              OPEN        STANDBY   0          0            REALTIME  VALID    4210            28136           4210            28136           NONE

DATABASE(DM2) APPLY INFO FROM (DM1), REDOS_PARALLEL_NUM (1):
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4288, 4288, 4288], (RLSN, SLSN, KLSN)[28136, 28136, 28136], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28136)


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

choose switchover grp1
Can choose one of the following instances to do switchover:
1: DM2

switchover grp1.dm2
[monitor]         2022-01-14 11:16:27: Not login dmmonitor or server public key changed, please try to login again!

login
username:SYSDBA
password:
[monitor]         2022-01-14 11:17:03: Login dmmonitor success!

switchover grp1.dm2
[monitor]         2022-01-14 11:17:23: Start to switchover instance DM2
[monitor]         2022-01-14 11:17:23: Notify dmwatcher(DM1) switch to SWITCHOVER status
[monitor]         2022-01-14 11:17:23: Dmwatcher process DM1 status switching [OPEN-->SWITCHOVER]
[monitor]         2022-01-14 11:17:23: Switch dmwatcher DM1 to SWITCHOVER status success
[monitor]         2022-01-14 11:17:23: Notify dmwatcher(DM2) switch to SWITCHOVER status
[monitor]         2022-01-14 11:17:23: Dmwatcher process DM2 status switching [OPEN-->SWITCHOVER]
[monitor]         2022-01-14 11:17:25: Switch dmwatcher DM2 to SWITCHOVER status success
[monitor]         2022-01-14 11:17:25: Instance DM1 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 6)
[monitor]         2022-01-14 11:17:25: Instance DM1 execute sql SP_SET_GLOBAL_DW_STATUS(0, 6) success
[monitor]         2022-01-14 11:17:25: Instance DM2 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 6)
[monitor]         2022-01-14 11:17:25: Instance DM2 execute sql SP_SET_GLOBAL_DW_STATUS(0, 6) success
[monitor]         2022-01-14 11:17:25: Instance DM1 start to execute sql ALTER DATABASE MOUNT
[monitor]         2022-01-14 11:17:25: Instance DM1 execute sql ALTER DATABASE MOUNT success
[monitor]         2022-01-14 11:17:25: Instance DM2 start to execute sql SP_APPLY_KEEP_PKG()
[monitor]         2022-01-14 11:17:25: Instance DM2 execute sql SP_APPLY_KEEP_PKG() success
[monitor]         2022-01-14 11:17:25: Instance DM2 start to execute sql ALTER DATABASE MOUNT
[monitor]         2022-01-14 11:17:25: Instance DM2 execute sql ALTER DATABASE MOUNT success
[monitor]         2022-01-14 11:17:25: Instance DM1 start to execute sql ALTER DATABASE STANDBY
[monitor]         2022-01-14 11:17:25: Instance DM1 execute sql ALTER DATABASE STANDBY success
[monitor]         2022-01-14 11:17:25: Instance DM2 start to execute sql ALTER DATABASE PRIMARY
[monitor]         2022-01-14 11:17:26: Instance DM2 execute sql ALTER DATABASE PRIMARY success
[monitor]         2022-01-14 11:17:26: Notify instance DM2 to change all arch status to be invalid
[monitor]         2022-01-14 11:17:26: Succeed to change all instances arch status to be invalid
[monitor]         2022-01-14 11:17:26: Instance DM1 start to execute sql ALTER DATABASE OPEN FORCE
[monitor]         2022-01-14 11:17:26: Instance DM1 execute sql ALTER DATABASE OPEN FORCE success
[monitor]         2022-01-14 11:17:26: Instance DM2 start to execute sql ALTER DATABASE OPEN FORCE
[monitor]         2022-01-14 11:17:26: Instance DM2 execute sql ALTER DATABASE OPEN FORCE success
[monitor]         2022-01-14 11:17:26: Instance DM1 start to execute sql SP_SET_GLOBAL_DW_STATUS(6, 0)
[monitor]         2022-01-14 11:17:26: Instance DM1 execute sql SP_SET_GLOBAL_DW_STATUS(6, 0) success
[monitor]         2022-01-14 11:17:26: Instance DM2 start to execute sql SP_SET_GLOBAL_DW_STATUS(6, 0)
[monitor]         2022-01-14 11:17:26: Instance DM2 execute sql SP_SET_GLOBAL_DW_STATUS(6, 0) success
[monitor]         2022-01-14 11:17:26: Notify dmwatcher(DM1) switch to OPEN status
[monitor]         2022-01-14 11:17:26: Dmwatcher process DM1 status switching [SWITCHOVER-->OPEN]
[monitor]         2022-01-14 11:17:27: Switch dmwatcher DM1 to OPEN status success
[monitor]         2022-01-14 11:17:27: Notify dmwatcher(DM2) switch to OPEN status
[monitor]         2022-01-14 11:17:28: Dmwatcher process DM2 status switching [SWITCHOVER-->OPEN]
[monitor]         2022-01-14 11:17:28: Switch dmwatcher DM2 to OPEN status success
[monitor]         2022-01-14 11:17:28: Notify group(GRP1)'s dmwatcher to do clear
[monitor]         2022-01-14 11:17:29: Clean request of dmwatcher processer DM1 success
[monitor]         2022-01-14 11:17:29: Clean request of dmwatcher processer DM2 success
[monitor]         2022-01-14 11:17:29: Switchover instance DM2 success

2022-01-14 11:17:29
#================================================================================#
GROUP            OGUID       MON_CONFIRM     MODE            MPP_FLAG
GRP1             111111      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
11.11.11.210        5238         2022-01-14 11:17:28  GLOBAL    VALID     OPEN           DM2              OK        1     1     OPEN        PRIMARY   DSC_OPEN       REALTIME  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.210      5236       OK        DM2              OPEN        PRIMARY   0          0            REALTIME  VALID    4289            29494           4289            29494           NONE

< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
11.11.11.209        5238         2022-01-14 11:17:28  GLOBAL    VALID     OPEN           DM1              OK        1     1     OPEN        STANDBY   DSC_OPEN       REALTIME  INVALID

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.209      5236       OK        DM1              OPEN        STANDBY   0          0            REALTIME  INVALID  4288            28136           4288            28136           NONE

DATABASE(DM1) APPLY INFO FROM (DM2), REDOS_PARALLEL_NUM (1):
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4288, 4288, 4288], (RLSN, SLSN, KLSN)[28136, 28136, 28136], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (28136)


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

[monitor]         2022-01-14 11:17:30: Dmwatcher process DM2 status switching [OPEN-->RECOVERY]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 11:17:30  RECOVERY       OK        DM2              OPEN        PRIMARY   VALID    4        29494           29494

[monitor]         2022-01-14 11:17:33: Dmwatcher process DM2 status switching [RECOVERY-->OPEN]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 11:17:32  OPEN           OK        DM2              OPEN        PRIMARY   VALID    4        29494           29494

Takeover 接管

choose takeover grp1
Group(grp1) has active primary instance, not get standby instance list any more!

将主库网络直接中断:

[root@dm210 data]# systemctl stop network

#此时可以接管了:
[monitor]         2022-01-14 14:36:50: Received message timeout from(DM2)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:36:39  ERROR          OK        DM2              OPEN        PRIMARY   VALID    4        29501           29501

[monitor]         2022-01-14 14:36:51: Check primary instance error in group(GRP1), start to auto takeover

[monitor]         2022-01-14 14:36:51: Notify group(GRP1)'s active dmwatcher to set MID
[monitor]         2022-01-14 14:36:51: Notify group(GRP1)'s active dmwatcher to set MID success
[monitor]         2022-01-14 14:36:51: Start to takeover use instance DM1
[monitor]         2022-01-14 14:36:51: Notify dmwatcher(DM1) switch to TAKEOVER status
[monitor]         2022-01-14 14:36:51: Dmwatcher process DM1 status switching [OPEN-->TAKEOVER]
[monitor]         2022-01-14 14:36:52: Switch dmwatcher DM1 to TAKEOVER status success
[monitor]         2022-01-14 14:36:52: Instance DM1 start to execute sql SP_SET_GLOBAL_DW_STATUS(0, 7)
[monitor]         2022-01-14 14:36:52: Instance DM1 execute sql SP_SET_GLOBAL_DW_STATUS(0, 7) success
[monitor]         2022-01-14 14:36:52: Instance DM1 start to execute sql SP_APPLY_KEEP_PKG()
[monitor]         2022-01-14 14:36:52: Instance DM1 execute sql SP_APPLY_KEEP_PKG() success
[monitor]         2022-01-14 14:36:52: Instance DM1 start to execute sql ALTER DATABASE MOUNT
[monitor]         2022-01-14 14:36:52: Instance DM1 execute sql ALTER DATABASE MOUNT success
[monitor]         2022-01-14 14:36:52: Instance DM1 start to execute sql ALTER DATABASE PRIMARY
[monitor]         2022-01-14 14:36:53: Instance DM1 execute sql ALTER DATABASE PRIMARY success
[monitor]         2022-01-14 14:36:53: Notify instance DM1 to change all arch status to be invalid
[monitor]         2022-01-14 14:36:53: Succeed to change all instances arch status to be invalid
[monitor]         2022-01-14 14:36:53: Instance DM1 start to execute sql ALTER DATABASE OPEN FORCE
[monitor]         2022-01-14 14:36:53: Instance DM1 execute sql ALTER DATABASE OPEN FORCE success
[monitor]         2022-01-14 14:36:53: Instance DM1 start to execute sql SP_SET_GLOBAL_DW_STATUS(7, 0)
[monitor]         2022-01-14 14:36:53: Instance DM1 execute sql SP_SET_GLOBAL_DW_STATUS(7, 0) success
[monitor]         2022-01-14 14:36:53: Notify dmwatcher(DM1) switch to OPEN status
[monitor]         2022-01-14 14:36:54: Dmwatcher process DM1 status switching [TAKEOVER-->OPEN]
[monitor]         2022-01-14 14:36:54: Switch dmwatcher DM1 to OPEN status success
[monitor]         2022-01-14 14:36:54: Notify group(GRP1)'s dmwatcher to do clear
[monitor]         2022-01-14 14:36:54: Clean request of dmwatcher processer DM1 success
[monitor]         2022-01-14 14:36:54: Success to takeover use instance DM1

[monitor]         2022-01-14 14:36:54: Group(GRP1) use instance DM1 auto takeover success

恢复DW环境
恢复原主库的网络后,监视器自动将原主库切换成了备库:

[monitor]         2022-01-14 14:42:19: Dmwatcher process DM2 status switching [NONE-->MON CONFIRM]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:19  MON CONFIRM    OK        DM2              SUSPEND     PRIMARY   VALID    4        29501           29501

[monitor]         2022-01-14 14:42:21: Dmwatcher process DM2 status switching [MON CONFIRM-->STARTUP]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:20  STARTUP        OK        DM2              SUSPEND     PRIMARY   VALID    4        29501           29501

[monitor]         2022-01-14 14:42:23: Instance DM2[PRIMARY, SUSPEND, ISTAT_SAME:TRUE] error
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:22  STARTUP        ERROR     DM2              SUSPEND     PRIMARY   VALID    4        29501           29501

[monitor]         2022-01-14 14:42:35: Instance DM2[STANDBY, MOUNT, ISTAT_SAME:TRUE] recover to OK
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:35  STARTUP        OK        DM2              MOUNT       STANDBY   INVALID  4        29501           29501

[monitor]         2022-01-14 14:42:36: Dmwatcher process DM2 status switching [STARTUP-->OPEN]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:36  OPEN           OK        DM2              OPEN        STANDBY   INVALID  4        29501           29501

[monitor]         2022-01-14 14:42:40: Dmwatcher process DM1 status switching [OPEN-->RECOVERY]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:39  RECOVERY       OK        DM1              OPEN        PRIMARY   VALID    5        30859           30859

[monitor]         2022-01-14 14:42:43: Dmwatcher process DM1 status switching [RECOVERY-->OPEN]
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 14:42:42  OPEN           OK        DM1              OPEN        PRIMARY   VALID    5        30859           30859

show
2022-01-14 14:43:05
#================================================================================#
GROUP            OGUID       MON_CONFIRM     MODE            MPP_FLAG
GRP1             111111      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
11.11.11.209        5238         2022-01-14 14:43:03  GLOBAL    VALID     OPEN           DM1              OK        1     1     OPEN        PRIMARY   DSC_OPEN       REALTIME  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.209      5236       OK        DM1              OPEN        PRIMARY   0          0            REALTIME  VALID    4359            30859           4359            30859           NONE

< >
DW_IP               MAL_DW_PORT  WTIME                WTYPE     WCTLSTAT  WSTATUS        INAME            INST_OK   N_EP  N_OK  ISTATUS     IMODE     DSC_STATUS     RTYPE     RSTAT
11.11.11.210        5238         2022-01-14 14:43:03  GLOBAL    VALID     OPEN           DM2              OK        1     1     OPEN        STANDBY   DSC_OPEN       REALTIME  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.210      5236       OK        DM2              OPEN        STANDBY   0          0            REALTIME  VALID    4356            30859           4356            30859           NONE

DATABASE(DM2) APPLY INFO FROM (DM1), REDOS_PARALLEL_NUM (1):
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4359, 4359, 4359], (RLSN, SLSN, KLSN)[30859, 30859, 30859], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (30859)


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

DW 环境启动与关闭测试
因为Global 守护类型的守护进程,会自动将数据库实例切换到 Open 状态,并将守护进程状态也切换为 Open。因此在关闭DW系统时,必须按照一定的顺序来关闭守护进程和实例。

可以在监视器中执行 Stop Instance 命令关闭数据守护系统,命令执行成功后,数据库实例正常关闭。但守护进程并没有真正退出,而是将状态切换为Shutdown 状态。

如果使用手动方式关闭数据守护系统,请严格按照以下顺序:

1) 如果启动了确认监视器,先关闭确认监视器(防止自动接管)
2) 关闭主库守护进程(防止重启实例)
3) 关闭备库守护进程(防止重启实例)

在关闭守护进程时会自动关闭对应的DM实例。 所以我们这里只需要关闭对应的守护进程即可。

关闭DW 环境
我们这里使用手工方式关闭DW.
1.关闭监视器进程
直接ctrl + c 结束命令即可。

2.关闭主库守护进程

[root@dm209 root]# systemctl stop DmWatcherServicedw1
[root@dm209 root]# ps -ef|grep dm.ini
root      4515 18565  0 15:16 pts/1    00:00:00 grep --color=auto dm.ini

3.关闭备库守护进程

[root@dm210 log]# service DmWatcherServicedw2 stop
Redirecting to /bin/systemctl stop DmWatcherServicedw2.service
[root@dm210 log]# ps -ef | grep dm.ini
root      3725 20825  0 15:16 pts/2    00:00:00 grep --color=auto dm.ini

启动DW环境
启动备库守护进程

[root@dm210 log]# service DmWatcherServicedw2 start
Redirecting to /bin/systemctl start DmWatcherServicedw2.service
[root@dm210 log]# ps -ef | grep dm.ini
dmdba     3795     1  1 15:18 ?        00:00:00 /dm8/bin/dmserver /dm8/data/dm/dm.ini mount
root      3887 20825  0 15:18 pts/2    00:00:00 grep --color=auto dm.ini

启动守护进程时会自动启动DM 实例。

启动主库守护进程

[root@dm209 root]# service DmWatcherServicedw1 start
Redirecting to /bin/systemctl start DmWatcherServicedw1.service
[root@dm209 root]# ps -ef|grep dm.ini
dmdba     4598     1  0 15:20 ?        00:00:00 /dm8/bin/dmserver /dm8/data/dm/dm.ini mount
root      4713 18565  0 15:21 pts/1    00:00:00 grep --color=auto dm.ini

启动监视器

[dmdba@dm211 data]$ dmmonitor /dm8/data/dmmonitor.ini
[monitor]         2022-01-14 15:43:58: DMMONITOR[4.0] V8
[monitor]         2022-01-14 15:43:58: DMMONITOR[4.0] IS READY.

[monitor]         2022-01-14 15:43:58: Received message from(DM1)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 15:43:57  OPEN           OK        DM1              OPEN        PRIMARY   VALID    3        30859           30859

[monitor]         2022-01-14 15:43:58: Received message from(DM2)
                  WTIME                WSTATUS        INST_OK   INAME            ISTATUS     IMODE     RSTAT    N_OPEN   FLSN            CLSN
                  2022-01-14 15:43:57  OPEN           OK        DM2              OPEN        STANDBY   VALID    3        30859           30859

DM8搭建MPP集群

DM MPP环境搭建
我们将以一个简单的两节点MPP为例,介绍手动配置与搭建DM MPP环境的步骤。
一. 系统规划
本例配置一个两节点MPP。两个节点都配置两块网卡,一块接入内部网络交换模块,一块接入到外部交换机。两节点实例名分别为EP01和EP02,相关的IP、端口等规划见下表。

实例名  MAL_INST_HOST      MAL_INST_PORT     MAL_HOST       MAL端口     MPP_SEQNO
ep01    10.10.13.207     5236              11.11.11.6     5237        0
ep02    10.10.13.208     5236              11.11.11.7     5237        1

DM MPP各EP使用的DM服务器版本应一致,同时还应注意各EP所在主机的操作系统位数、大小端模式、时区及时间设置都应一致,否则可能造成意想不到的错误。

先在两个节点上安装DM数据库
二、操作系统配置
1、关闭防火墙和SELINUX

[root@gbase ~]# systemctl stop firewalld
[root@gbase ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@gbase ~]# systemctl status firewalld
   firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 16 16:06:07 gbase systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 16 16:06:12 gbase systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 16 16:47:52 gbase systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 16 16:47:53 gbase systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@gbase ~]# setenforce 0
[root@gbase ~]# sed -i s:^SELINUX=.*$:SELINUX=disabled:g /etc/selinux/config
[root@gbase ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@gbase ~]# systemctl stop firewalld
[root@gbase ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@gbase ~]# systemctl status firewalld
   firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 16 16:06:18 gbase systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 16 16:06:20 gbase systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 16 16:47:55 gbase systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 16 16:47:56 gbase systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@gbase ~]# setenforce 0
[root@gbase ~]# sed -i s:^SELINUX=.*$:SELINUX=disabled:g /etc/selinux/config
[root@gbase ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

2、修改主机名
[root@gbase ~]# hostnamectl set-hostname dm8mpp1
[root@gbase ~]# sed -i s:^HOSTNAME=.*$:HOSTNAME=dm8mpp1:g /etc/sysconfig/network
[root@gbase ~]# echo "
> 10.10.13.207   dm8mpp1
> 10.10.13.208   dm8mpp2" >> /etc/hosts

[root@gbase ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.13.207   dm8mpp1
10.10.13.208   dm8mpp2

[root@gbase ~]# hostnamectl set-hostname dm8mpp2
[root@gbase ~]# sed -i s:^HOSTNAME=.*$:HOSTNAME=dm8mpp2:g /etc/sysconfig/network
[root@gbase ~]# echo "
> 10.10.13.201   dm8mpp1
> 10.10.13.202   dm8mpp2" >> /etc/hosts
[root@gbase ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.13.207   dm8mpp1
10.10.13.208   dm8mpp2

[root@gbase ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.13.207   dm8mpp1
10.10.13.208   dm8mpp2

三、 安装达梦软件

3.1检查Linux(Unix)系统信息

[root@dm8mpp1 ~]# getconf LONG_BIT
64

[root@dm8mpp2 ~]# getconf LONG_BIT
64

查询操作系统release信息
[root@dm8mpp1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 Beta (Maipo)

[root@dm8mpp2 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 Beta (Maipo)

3.2创建安装用户
为了减少对操作系统的影响,用户不应该以root系统用户来安装和运行DM。用户可以在安装之前为DM创建一个专用的系统用户。
1. 创建安装用户组dinstall。

[root@dm8mpp1 ~]# groupadd dinstall

[root@dm8mpp2 ~]# groupadd dinstall

2. 创建安装用户dmdba。

[root@dm8mpp1 ~]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

[root@dm8mpp2 ~]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

3. 初始化用户密码。

[root@dm8mpp1 ~]# passwd dmdba
Changing password for user dmdba.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.


[root@dm8mpp2 ~]# passwd dmdba
Changing password for user dmdba.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

3.3 Linux(Unix)下检查操作系统限制
在Linux(Unix)系统中,因为ulimit命令的存在,会对程序使用操作系统资源进行限制。为了使DM能够正常运行,建议用户检查当前安装用户的ulimit参数。

运行ulimit -a进行查询。如下图所示:

[root@dm8mpp1 ~]#  ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31152
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


[root@dm8mpp2 ~]#  ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31152
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

参数使用限制:
1.data seg size
data seg size (kbytes, -d)
建议用户设置为1048576(即1GB)以上或unlimited(无限制),此参数过小将导致数据库启动失败。
2. file size
file size(blocks, -f)
建议用户设置为unlimited(无限制),此参数过小将导致数据库安装或初始化失败。
3. open files
open files(-n)
建议用户设置为65536以上或unlimited(无限制)。
4.virtual memory
virtual memory (kbytes, -v)
建议用户设置为1048576(即1GB)以上或unlimited(无限制),此参数过小将导致数据库启动失败。

如果用户需要为当前安装用户更改ulimit的资源限制,请修改文件/etc/security/limits.conf。

[root@dm8mpp1 ~]# vi /etc/security/limits.conf
dmdba soft data unlimited
dmdba hard data unlimited
dmdba soft fsize unlimited
dmdba hard fsize unlimited
dmdba soft nofile 65536
dmdba hard nofile 65536


[root@dm8mpp2 ~]# vi /etc/security/limits.conf
dmdba soft data unlimited
dmdba hard data unlimited
dmdba soft fsize unlimited
dmdba hard fsize unlimited
dmdba soft nofile 65536
dmdba hard nofile 65536

[root@dm8mpp1 ~]# su - dmdba
[dmdba@dm8mpp1 ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

[root@dm8mpp2 ~]# su - dmdba
[dmdba@dm8mpp2 ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

3.4.检查系统内存与存储空间
1.检查内存
为了保证DM的正确安装和运行,要尽量保证操作系统至少1GB的可用内存(RAM)。如果可用内存过少,可能导致DM安装或启动失败。用户可以使用以下命令检查操作内存:
#获取内存总大小

[root@dm8mpp1 ~]# grep MemTotal /proc/meminfo
MemTotal:        8009072 kB

[root@dm8mpp2 ~]# grep MemTotal /proc/meminfo
MemTotal:        8009072 kB

#获取交换分区大小

[root@dm8mpp1 ~]# grep SwapTotal /proc/meminfo
SwapTotal:       8257532 kB

[root@dm8mpp2 ~]# grep SwapTotal /proc/meminfo
SwapTotal:       8257532 kB

#获取内存使用详情

[root@dm8mpp1 ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           6
Swap:             7           0           7


[root@dm8mpp2 ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           6
Swap:             7           0           7

2.检查存储空间
1) DM完全安装需要1GB的存储空间,用户需要提前规划好安装目录,预留足够的存储空间。用户在DM安装前也应该为数据库实例预留足够的存储空间,规划好数据路径和备份路径。用户可使用以下命令检查存储空间:
#查询目录/dm8可用空间

[root@dm8mpp1 ~]# mkdir /dm8
[root@dm8mpp1 ~]#  chown -R dmdba:dinstall /dm8
[root@dm8mpp1 ~]# chmod -R 775 /dm8

[root@dm8mpp2 ~]# mkdir /dm8
[root@dm8mpp2 ~]#  chown -R dmdba:dinstall /dm8
[root@dm8mpp2 ~]# chmod -R 775 /dm8

[root@dm8mpp1 ~]# df -h /dm8
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

[root@dm8mpp2 ~]# df -h /dm8
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

2) DM安装程序在安装时将产生临时文件,临时文件需要1GB的存储空间,临时文件目录默认为/tmp。用户可以使用以下命令检查存储空间。
如下图所示:

[root@dm8mpp1 ~]# df -h /tmp
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

[root@dm8mpp2 ~]# df -h /tmp
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

3.5.安装DM
创建目录/soft/dmsoft用来存储挂载iso文件后来显示软件包中的文
[root@dm8mpp1 ~]# cd /soft

[root@dm8mpp1 soft]# unzip dm8_20211021_x86_rh6_64_ent.zip
Archive:  dm8_20211021_x86_rh6_64_ent.zip
   creating: dm8_20211021_x86_rh6_64_ent/
  inflating: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso
 extracting: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso_SHA256.txt
 extracting: dm8_20211021_x86_rh6_64_ent/verinfo.txt

[root@dm8mpp1 soft]# ls -lrt
total 778320
drwxr-xr-x 2 root root       132 Nov 12 13:43 dm8_20211021_x86_rh6_64_ent
-rw-r--r-- 1 root root 796998047 Nov 29 10:25 dm8_20211021_x86_rh6_64_ent.zip
[root@dm8mpp1 soft]# mv dm8_20211021_x86_rh6_64_ent dm8
[root@dm8mpp1 soft]# mkdir dmsoft
[root@dm8mpp1 soft]# mount -t iso9660 -o loop dm8/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso  /soft/dmsoft
mount: /dev/loop0 is write-protected, mounting read-only
[root@dm8mpp1 soft]# cd dmsoft
[root@dm8mpp1 dmsoft]# ls -lrt
total 790160
-r-xr-xr-x 1 root root   2802503 Oct 21 14:04 DM8 Install.pdf
-r-xr-xr-x 1 root root 806320703 Oct 21 14:11 DMInstall.bin



[root@dm8mpp2 ~]# cd /soft
[root@dm8mpp2 soft]# unzip dm8_20211021_x86_rh6_64_ent.zip
Archive:  dm8_20211021_x86_rh6_64_ent.zip
   creating: dm8_20211021_x86_rh6_64_ent/
  inflating: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso
 extracting: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso_SHA256.txt
 extracting: dm8_20211021_x86_rh6_64_ent/verinfo.txt

[root@dm8mpp2 soft]# ls -lrt
total 778320
drwxr-xr-x 2 root root       132 Nov 12 13:43 dm8_20211021_x86_rh6_64_ent
-rw-r--r-- 1 root root 796998047 Nov 29 10:25 dm8_20211021_x86_rh6_64_ent.zip
[root@dm8mpp2 soft]# mv dm8_20211021_x86_rh6_64_ent dm8
[root@dm8mpp2 soft]# mkdir dmsoft
[root@dm8mpp2 soft]# mount -t iso9660 -o loop dm8/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso  /soft/dmsoft
mount: /dev/loop0 is write-protected, mounting read-only
[root@dm8mpp2 soft]# cd dmsoft
[root@dm8mpp2 dmsoft]# ls -lrt
total 790160
-r-xr-xr-x 1 root root   2802503 Oct 21 14:04 DM8 Install.pdf
-r-xr-xr-x 1 root root 806320703 Oct 21 14:11 DMInstall.bin

在/soft/dmsoft目录下存在DMInstall.bin文件, DMInstall.bin文件就是DM的安装程序。在运行安装程序前,需要赋予DMInstall.bin文件执行权限。具体命令如下所示:

[root@dm8mpp1 dmsoft]# chmod 755  DMInstall.bin
chmod: changing permissions of ‘DMInstall.bin’: Read-only file system

[root@dm8mpp2 dmsoft]# chmod 755  DMInstall.bin
chmod: changing permissions of ‘DMInstall.bin’: Read-only file system

在现实中,许多Linux(Unix)操作系统上是没有图形化界面的,为了使DM能够在这些操作系统上顺利安装,DM提供了命令行的安装方式。在终端进入到安装程序所在文件夹,执行以下命令进行命令行安装:

[root@dm8mpp1 dmsoft]# su - dmdba
Last login: Fri Dec 17 15:57:31 CST 2021 on pts/0
[dmdba@dm8mpp1 ~]$ cd /soft/dmsoft
[dmdba@dm8mpp1 dmsoft]$ ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:e
Extract install files.........
Welcome to DM DBMS Installer

Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n

Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:21

Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:4
1 Server component
2 Client component
  2.1 Manager
  2.2 Monitor
  2.3 DTS
  2.4 Console
  2.5 Analyzer
  2.6 DISQL
3 DM Drivers
4 Manual component
5 DBMS Service
  5.1 Realtime Audit Service
  5.2 Job Service
  5.3 Instance Monitor Service
  5.4 Assistant Plug-In Service
Please Input the number of the Installation Type [1 2 3 4 5]:1 2 3 4 5
Require Space: 1242M

Please Input the install path [/home/dmdba/dmdbms]:/dm8
Available Space:39G
Please Confirm the install path(/dm8)? (Y/y:Yes N/n:No) [Y/y]:y

Pre-Installation Summary
Installation Location: /dm8
Require Space: 1242M
Available Space: 39G
Version Information:
Expire Date:
Installation Type: Custom
Confirm to Install? (Y/y:Yes N/n:No):y
2021-12-17 16:16:08
[INFO] Installing DM DBMS...
2021-12-17 16:16:08
[INFO] Installing BASE Module...
2021-12-17 16:16:10
[INFO] Installing SERVER Module...
2021-12-17 16:16:15
[INFO] Installing CLIENT Module...
2021-12-17 16:16:25
[INFO] Installing DRIVERS Module...
2021-12-17 16:16:26
[INFO] Installing MANUAL Module...
2021-12-17 16:16:26
[INFO] Installing SERVICE Module...
2021-12-17 16:16:31
[INFO] Move log file to log directory.
2021-12-17 16:16:32
[INFO] Installed DM DBMS completely.

Please execute the commands by root:
/dm8/script/root/root_installer.sh

End

[root@dm8mpp2 dmsoft]# su - dmdba
Last login: Fri Dec 17 15:57:45 CST 2021 on pts/0
[dmdba@dm8mpp2 ~]$ cd /soft/dmsoft
[dmdba@dm8mpp2 dmsoft]$ ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:e
Extract install files.........
Welcome to DM DBMS Installer

Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n

Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:21

Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:4
1 Server component
2 Client component
  2.1 Manager
  2.2 Monitor
  2.3 DTS
  2.4 Console
  2.5 Analyzer
  2.6 DISQL
3 DM Drivers
4 Manual component
5 DBMS Service
  5.1 Realtime Audit Service
  5.2 Job Service
  5.3 Instance Monitor Service
  5.4 Assistant Plug-In Service
Please Input the number of the Installation Type [1 2 3 4 5]:1 2 3 4 5
Require Space: 1242M

Please Input the install path [/home/dmdba/dmdbms]:/dm8
Available Space:39G
Please Confirm the install path(/dm8)? (Y/y:Yes N/n:No) [Y/y]:y

Pre-Installation Summary
Installation Location: /dm8
Require Space: 1242M
Available Space: 39G
Version Information:
Expire Date:
Installation Type: Custom
Confirm to Install? (Y/y:Yes N/n:No):y
2021-12-17 16:18:44
[INFO] Installing DM DBMS...
2021-12-17 16:18:44
[INFO] Installing BASE Module...
2021-12-17 16:18:46
[INFO] Installing SERVER Module...
2021-12-17 16:18:49
[INFO] Installing CLIENT Module...
2021-12-17 16:19:04
[INFO] Installing DRIVERS Module...
2021-12-17 16:19:04
[INFO] Installing MANUAL Module...
2021-12-17 16:19:05
[INFO] Installing SERVICE Module...
2021-12-17 16:19:11
[INFO] Move log file to log directory.
2021-12-17 16:19:12
[INFO] Installed DM DBMS completely.

Please execute the commands by root:
/dm8/script/root/root_installer.sh

End

以root用户来执行上面的脚本

[root@dm8mpp1 ~]# /dm8/script/root/root_installer.sh
Move /dm8/bin/dm_svc.conf to /etc
Modify the files' mode of DM Server

[root@dm8mpp1 ~]# su - dmdba
Last login: Fri Dec 17 16:14:18 CST 2021 on pts/1
[dmdba@dm8mpp1 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
export PATH=$PATH:$LD_LIBRARY_PATH



[root@dm8mpp2 ~]# /dm8/script/root/root_installer.sh
Move /dm8/bin/dm_svc.conf to /etc
Modify the files' mode of DM Server

[root@dm8mpp2 ~]# su - dmdba
Last login: Fri Dec 17 16:17:23 CST 2021 on pts/1
[dmdba@dm8mpp2 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
export PATH=$PATH:$LD_LIBRARY_PATH

4.2.2 配置dm.ini
首先,在dmmpp1和dmmpp2上分别创建数据库,用户可以使用DM的图形化客户端工具“数据库配置助手”或命令行工具dminit 创建数据库。

[dmdba@dm8mpp1 ~]$ dminit path=/dm8/data page_size=16 case_sensitive=1 charset=0 db_name=ep01 instance_name=ep01 port_num=5236
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/ep01/ep0101.log


 log file path: /dm8/data/ep01/ep0102.log

write to dir [/dm8/data/ep01].
create dm database success. 2021-12-17 16:29:12

[dmdba@dm8mpp2 ~]$ dminit path=/dm8/data page_size=16 case_sensitive=1 charset=0 db_name=ep02 instance_name=ep02 port_num=5236
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/ep02/ep0201.log


 log file path: /dm8/data/ep02/ep0202.log

write to dir [/dm8/data/ep02].
create dm database success. 2021-12-17 16:29:35

分别对两个实例的dm.ini进行配置。
修改ep01的dm.ini的以下几个参数如下:

MAL_INI = 1
MPP_INI = 1

修改ep02的dm.ini的以下几个参数如下:

MAL_INI = 1
MPP_INI = 1

4.2.3 配置dmmal.ini
为两个EP配置dmmal.ini如下,配置完全一样,EP间可互相拷贝。dmmal.ini与dm.ini放在相同的目录下。

[dmdba@dm8mpp1 ep01]$ vi dmmal.ini
[MAL_INST1]
MAL_INST_NAME = ep01
MAL_HOST = 11.11.11.6
MAL_PORT = 5237
MAL_INST_HOST = 10.10.13.207
MAL_INST_PORT = 5236
[MAL_INST2]
MAL_INST_NAME = ep02
MAL_HOST = 11.11.11.7
MAL_PORT = 5237
MAL_INST_HOST = 10.10.13.208
MAL_INST_PORT = 5236


[dmdba@dm8mpp2 ep02]$ vi dmmal.ini
[MAL_INST1]
MAL_INST_NAME = ep01
MAL_HOST = 11.11.11.6
MAL_PORT = 5237
MAL_INST_HOST = 10.10.13.207
MAL_INST_PORT = 5236
[MAL_INST2]
MAL_INST_NAME = ep02
MAL_HOST = 11.11.11.7
MAL_PORT = 5237
MAL_INST_HOST = 10.10.13.208
MAL_INST_PORT = 5236

4.2.4 配置dmmpp.ctl
dmmpp.ctl是一个二进制文件,用户不能直接配置,需要先配置dmmpp.ini。
配置dmmpp.ini如下:

[dmdba@dm8mpp1 ep01]$ vi dmmpp.ini
[SERVICE_NAME1]
MPP_SEQ_NO = 0
MPP_INST_NAME = ep01
[SERVICE_NAME2]
MPP_SEQ_NO = 1
MPP_INST_NAME = ep02


[dmdba@dm8mpp1 ep02]$ vi dmmpp.ini
[SERVICE_NAME1]
MPP_SEQ_NO = 0
MPP_INST_NAME = ep01
[SERVICE_NAME2]
MPP_SEQ_NO = 1
MPP_INST_NAME = ep02

使用DM提供的工具dmctlcvt将dmmpp.ini转换成dmmpp.ctl,dmctlcvt工具在DM安装目录的“bin”子目录中。转换生成的dmmpp.ctl需要放在与dm.ini同一个目录。假设DM的安装路径为c盘根目录,下面的命令将dmmpp.ini转换为dmmpp.ctl,命令中的
“TYPE=2”参数表示将文本文件转换成控制文件,也可以使用“TYPE=1”参数进行逆向转换。

[dmdba@dm8mpp1 ~]$ dmctlcvt type=2 src=/dm8/data/ep01/dmmpp.ini dest=/dm8/data/ep01/dmmpp.ctl
DMCTLCVT V8
convert txt to ctl success!

[dmdba@dm8mpp1 ep01]$ ls -lrt dmmpp.ctl
-rw-r--r-- 1 dmdba dinstall 41540 Dec 17 16:40 dmmpp.ctl

将生成的dmmpp.ctl拷贝至另一EP,保证MPP系统中所有EP的dmmpp.ctl完全相同。

[dmdba@dm8mpp1 ep01]$ scp  dmmpp.ctl dmdba@10.10.13.208:/dm8/data/ep02/
The authenticity of host '10.10.13.208 (10.10.13.208)' can't be established.
ECDSA key fingerprint is SHA256:6O8c9WEeEYPbL4ncdRR1RsrjxxmfzPq9Tkq4/6uLSP4.
ECDSA key fingerprint is MD5:e1:73:3e:8d:79:be:5c:82:0f:c7:58:79:45:ad:df:86.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.13.208' (ECDSA) to the list of known hosts.
dmdba@10.10.13.208's password:
dmmpp.ctl                                                                                                                                                                                                100%   41KB   1.2MB/s   00:00
[dmdba@dm8mpp2 ep02]$ ls -lrt dmmpp.ctl
-rw-r--r-- 1 dmdba dinstall 41540 Dec 17 16:41 dmmpp.ctl

4.2.5 运行MPP
经过前面四个步骤,DM MPP环境已经配置完成了。分别启动EP01和EP02的DM数据库实例(顺序不分先后),DM MPP系统即能正常运行,用户就可以登录任一EP进行数据库操作了。

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


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

[root@dm8mpp1 /]# service DmServiceep01 start
Redirecting to /bin/systemctl start DmServiceep01.service
[root@dm8mpp1 /]# ps -ef | grep dmserver
dmdba    19859     1 13 16:47 ?        00:00:04 /dm8/bin/dmserver path=/dm8/data/ep01/dm.ini -noconsole
root     19947 16769  0 16:48 pts/1    00:00:00 grep --color=auto dmserver

[root@dm8mpp2 /]# service DmServiceep02 start
Redirecting to /bin/systemctl start DmServiceep02.service
[root@dm8mpp2 /]# ps -ef | grep dmserver
dmdba    19722     1 12 16:47 ?        00:00:03 /dm8/bin/dmserver path=/dm8/data/ep02/dm.ini -noconsole
root     19816 16615  0 16:48 pts/1    00:00:00 grep --color=auto dmserver

[dmdba@dm8mpp1 ~]$ disql SYSDBA/SYSDBA@localhost:5236

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

LINEID     NAME INSTANCE_NAME INSTANCE_NUMBER HOST_NAME SVR_VERSION                DB_VERSION          START_TIME          STATUS$ MODE$  OGUID       DSC_SEQNO   DSC_ROLE
---------- ---- ------------- --------------- --------- -------------------------- ------------------- ------------------- ------- ------ ----------- ----------- --------
1          EP01 EP01          1               dm8mpp1   DM Database Server x64 V8  DB Version: 0x7000c 2021-12-17 16:47:27 OPEN    NORMAL 0           0           NULL
2          EP02 EP02          2               dm8mpp2   DM Database Server x64 V8  DB Version: 0x7000c 2021-12-17 16:47:46 OPEN    NORMAL 0           0           NULL

used time: 10.969(ms). Execute id is 312185.

[dmdba@dm8mpp2 ~]$ disql SYSDBA/SYSDBA@localhost:5236

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

LINEID     NAME INSTANCE_NAME INSTANCE_NUMBER HOST_NAME SVR_VERSION                DB_VERSION          START_TIME          STATUS$ MODE$  OGUID       DSC_SEQNO   DSC_ROLE
---------- ---- ------------- --------------- --------- -------------------------- ------------------- ------------------- ------- ------ ----------- ----------- --------
1          EP02 EP02          2               dm8mpp2   DM Database Server x64 V8  DB Version: 0x7000c 2021-12-17 16:47:46 OPEN    NORMAL 0           0           NULL
2          EP01 EP01          1               dm8mpp1   DM Database Server x64 V8  DB Version: 0x7000c 2021-12-17 16:47:27 OPEN    NORMAL 0           0           NULL

used time: 11.362(ms). Execute id is 747780.

4.3 建立分布表
DM MPP支持表数据的哈希分布、随机分布、复制分布、范围分布、LIST分布类型,用户可根据实际情况选择合适的分布类型。MPP的数据分布类型和具体设置在建表时指定,语法如下,建表的其他语法分支可参见《DM8_SQL语言使用手册》。

CREATE [[GLOBAL] TEMPORARY] TABLE < 表名定义> < 表结构定义>;
< 表结构定义>::=< 表结构定义1> | < 表结构定义2>
< 表结构定义1>::= (< 列定义> {,< 列定义>} [,< 表级约束定义>{,< 表级约束定义>}]) [ON COMMIT  ROWS] [][< 空间限制子句>] [][< 压缩子句>] [][]
< 表结构定义2>::= [ON COMMIT  ROWS] [< 空间限制子句>] [] [< 压缩子句>]AS < 不带INTO的SELECT语句>[];
::=DISTRIBUTED[|]
|DISTRIBUTED BY [](< 列名> {,< 列名>})
|DISTRIBUTED BY RANGE (< 列名> {,< 列名>})(< 范围分布项> {,< 范围分布项>})
|DISTRIBUTED BY LIST (< <列名> {,< 列名>}>)( {,})
< 范围分布项>::= VALUES LESS THAN (< 表达式>{,< 表达式>}) ON < 实例名>
|VALUES EQU OR LESS THAN (< 表达式>{,< 表达式>}) ON < 实例名>
::= VALUES (< 表达式>{,< 表达式>}) ON < 实例名>

下面给出几个简单的创建不同类型分布表的例子。
例1:创建哈希分布表T_HASH,分布列为C1。

SQL> create table t_hash(c1 int,c2 varchar(50)) distributed by hash(c1);
executed successfully
used time: 92.798(ms). Execute id is 53801.

SQL> begin
2   for i in 1 .. 100000 loop
3    insert into t_hash values(i,'a'||i);
4   end loop;
5   commit;
6   end;
7   /
DMSQL executed successfully
used time: 00:00:32.408. Execute id is 412195.

SQL> select * from v$dm_ini where para_name='PARALLEL_POLICY';

LINEID     PARA_NAME       PARA_VALUE MIN_VALUE MAX_VALUE DEFAULT_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION     PARA_TYPE
---------- --------------- ---------- --------- --------- ------------- ------- ---------- ---------- --------------- ---------
1          PARALLEL_POLICY 0          0         2         0             Y       0          0          Parallel policy IN FILE
2          PARALLEL_POLICY 0          0         2         0             Y       0          0          Parallel policy IN FILE

used time: 14.487(ms). Execute id is 747782.
SQL> sp_set_para_value(2,'PARALLEL_POLICY',2);
DMSQL executed successfully
used time: 18.129(ms). Execute id is 747783.
SQL> select * from v$dm_ini where para_name='PARALLEL_POLICY';

LINEID     PARA_NAME       PARA_VALUE MIN_VALUE MAX_VALUE DEFAULT_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION     PARA_TYPE
---------- --------------- ---------- --------- --------- ------------- ------- ---------- ---------- --------------- ---------
1          PARALLEL_POLICY 0          0         2         0             Y       0          2          Parallel policy IN FILE
2          PARALLEL_POLICY 0          0         2         0             Y       0          2          Parallel policy IN FILE

used time: 11.234(ms). Execute id is 747785.

重启数据库

[root@dm8mpp1 /]# service DmServiceep01 restart
Redirecting to /bin/systemctl restart DmServiceep01.service

[root@dm8mpp2 /]# service DmServiceep02 restart
Redirecting to /bin/systemctl restart DmServiceep02.service

SQL> select * from v$dm_ini where para_name='PARALLEL_POLICY';

LINEID     PARA_NAME       PARA_VALUE MIN_VALUE MAX_VALUE DEFAULT_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION     PARA_TYPE
---------- --------------- ---------- --------- --------- ------------- ------- ---------- ---------- --------------- ---------
1          PARALLEL_POLICY 2          0         2         0             Y       2          2          Parallel policy IN FILE
2          PARALLEL_POLICY 2          0         2         0             Y       2          2          Parallel policy IN FILE

used time: 11.378(ms). Execute id is 119090.

SQL> explain select * from t_hash;

1   #NSET2: [5, 50000, 60]
2     #MPP COLLECT: [5, 50000, 60]; op_id(1) n_grp_by (0) n_cols(0) n_keys(0) for_sync(FALSE)
3       #PRJT2: [5, 50000, 60]; exp_num(3), is_atom(FALSE)
4         #CSCN2: [5, 50000, 60]; INDEX33555458(T_HASH)

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

使用python解密工具来解密SecureCRT会话中保存的登录密码

使用python解密工具来解密SecureCRT会话中保存的登录密码
环境为windows7,SecureCRT7,Python 3.8.8

操作步骤如下:
1.安装python
从下载python3.8.8,下载时查看该版本是否支持你的操作系统下载软件包后直接双击安装包进行安装,安装时可以选择自动配置环境变量。安装完成后查看python版本。

C:\Users\Administrator>python –version
Python 3.8.8
2.从github下下载how-does-SecureCRT-encrypt-password工具(https://github.com/HyperSine/how-does-SecureCRT-encrypt-password)一个名为SecureCRTCipher.py的python文件,使用方法如下:

F:\how-does-SecureCRT-encrypt-password-master\python3>python SecureCRTCipher.py
Usage:
SecureCRTCipher.py [-v2] [-p ConfigPassphrase]
“enc” for encryption, “dec” for decryption.
This parameter must be specified. –(加密|解密)必选项
[-v2] Encrypt/Decrypt with “Password V2″ algorithm.
This parameter is optional.–(如果加密使用的是Password V2算法则加上这个参数)可选项
[-p ConfigPassphrase] The config passphrase that SecureCRT uses.
This parameter is optional.–(如果你的SecureCRT打开时要密码,则要加上这个参数,并在后面加上你使用的密码)可选项
Plaintext string or ciphertext string.
NOTICE: Ciphertext string must be a hex string.
This parameter must be specified.–(明文或密文,密文必须是16进制的字符串)必选项
3.安装pycryptodome模块

C:\Users\Administrator>pip3 install pycryptodome
Collecting pycryptodome
Downloading pycryptodome-3.14.1-cp35-abi3-win_amd64.whl (1.8 MB)
|████████████████████████████████| 1.8 MB 30 kB/s
Installing collected packages: pycryptodome
Successfully installed pycryptodome-3.14.1
WARNING: You are using pip version 20.2.3; however, version 22.0.4 is available.
You should consider upgrading via the ‘c:\program files\python38\python.exe -m pip install –upgrade pip’ command.
上面提示我升级一下pip3的版本

C:\Users\Administrator>python -m pip install –upgrade pip
Collecting pip
Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 142 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-22.0.4
4.找到SecureCRT会话配置文件
Options->Global Options->Category->Configuration Paths->Configuration folder文件夹下的对应的会话配置文件xxx.ini,并将其打开例如:

D:”Is Session”=00000001
S:”Protocol Name”=SSH2
D:”Request pty”=00000001
S:”Shell Command”=
D:”Use Shell Command”=00000000
D:”Force Close On Exit”=00000000
D:”Forward X11″=00000000
S:”XAuthority File”=
S:”XServer Host”=127.0.0.1
D:”XServer Port”=00001770
D:”XServer Screen Number”=00000000
D:”Enforce X11 Authentication”=00000001
D:”Request Shell”=00000001
S:”Port Forward Filter”=allow,127.0.0.0/255.0.0.0,0 deny,0.0.0.0/0.0.0.0,0
S:”Reverse Forward Filter”=allow,127.0.0.1,0 deny,0.0.0.0/0.0.0.0,0
D:”Max Packet Size”=00001000
D:”Pad Password Packets”=00000001
S:”Sftp Tab Local Directory”=C:\Users\Administrator\Documents
S:”Sftp Tab Remote Directory”=
S:”Hostname”=12.18.1.23
S:”Firewall Name”=None
S:”Username”=root
D:”[SSH2] Port”=00000016
S:”Password”=uc71bd1c86f3b804e42432f53247c50d9287f410c7e59166969acab69daa6eaadbe15c0c54c0e076e945a6d82f9e13df2
5.在SecureCRTCipher.py文件目录下cmd命令行窗口中执行命令即可查看明文(命令行中字符串比Password中的字符串少个u):

F:\how-does-SecureCRT-encrypt-password-master\python3>python SecureCRTCipher.py dec c71bd1c86f3b804e42432f53247c50d9287f410c7e59166969acab69daa6eaadbe15c0c54c0e076e945a6d82f9e13df2
DoubleLabyrinth
6.解密脚本文件SecureCRTCipher.py的内容如下:

#!/usr/bin/env python3
import os
from Crypto.Hash import SHA256
from Crypto.Cipher import AES, Blowfish
class SecureCRTCrypto:
def __init__(self):
”’
Initialize SecureCRTCrypto object.
”’
self.IV = b’\x00′ * Blowfish.block_size
self.Key1 = b’\x24\xA6\x3D\xDE\x5B\xD3\xB3\x82\x9C\x7E\x06\xF4\x08\x16\xAA\x07′
self.Key2 = b’\x5F\xB0\x45\xA2\x94\x17\xD9\x16\xC6\xC6\xA2\xFF\x06\x41\x82\xB7′
def Encrypt(self, Plaintext : str):
”’
Encrypt plaintext and return corresponding ciphertext.
Args:
Plaintext: A string that will be encrypted.
Returns:
Hexlified ciphertext string.
”’
plain_bytes = Plaintext.encode(‘utf-16-le’)
plain_bytes += b’\x00\x00′
padded_plain_bytes = plain_bytes + os.urandom(Blowfish.block_size – len(plain_bytes) % Blowfish.block_size)
cipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)
cipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV)
return cipher1.encrypt(os.urandom(4) + cipher2.encrypt(padded_plain_bytes) + os.urandom(4)).hex()
def Decrypt(self, Ciphertext : str):
”’
Decrypt ciphertext and return corresponding plaintext.
Args:
Ciphertext: A hex string that will be decrypted.
Returns:
Plaintext string.
”’
cipher1 = Blowfish.new(self.Key1, Blowfish.MODE_CBC, iv = self.IV)
cipher2 = Blowfish.new(self.Key2, Blowfish.MODE_CBC, iv = self.IV)
ciphered_bytes = bytes.fromhex(Ciphertext)
if len(ciphered_bytes) < = 8: raise ValueError('Invalid Ciphertext.') padded_plain_bytes = cipher2.decrypt(cipher1.decrypt(ciphered_bytes)[4:-4]) i = 0 for i in range(0, len(padded_plain_bytes), 2): if padded_plain_bytes[i] == 0 and padded_plain_bytes[i + 1] == 0: break plain_bytes = padded_plain_bytes[0:i] try: return plain_bytes.decode('utf-16-le') except UnicodeDecodeError: raise(ValueError('Invalid Ciphertext.')) class SecureCRTCryptoV2: def __init__(self, ConfigPassphrase : str = ''): ''' Initialize SecureCRTCryptoV2 object. Args: ConfigPassphrase: The config passphrase that SecureCRT uses. Leave it empty if config passphrase is not set. ''' self.IV = b'\x00' * AES.block_size self.Key = SHA256.new(ConfigPassphrase.encode('utf-8')).digest() def Encrypt(self, Plaintext : str): ''' Encrypt plaintext and return corresponding ciphertext. Args: Plaintext: A string that will be encrypted. Returns: Hexlified ciphertext string. ''' plain_bytes = Plaintext.encode('utf-8') if len(plain_bytes) > 0xffffffff:
raise OverflowError(‘Plaintext is too long.’)
plain_bytes = \
len(plain_bytes).to_bytes(4, ‘little’) + \
plain_bytes + \
SHA256.new(plain_bytes).digest()
padded_plain_bytes = \
plain_bytes + \
os.urandom(AES.block_size – len(plain_bytes) % AES.block_size)
cipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV)
return cipher.encrypt(padded_plain_bytes).hex()
def Decrypt(self, Ciphertext : str):
”’
Decrypt ciphertext and return corresponding plaintext.
Args:
Ciphertext: A hex string that will be decrypted.
Returns:
Plaintext string.
”’
cipher = AES.new(self.Key, AES.MODE_CBC, iv = self.IV)
padded_plain_bytes = cipher.decrypt(bytes.fromhex(Ciphertext))
plain_bytes_length = int.from_bytes(padded_plain_bytes[0:4], ‘little’)
plain_bytes = padded_plain_bytes[4:4 + plain_bytes_length]
if len(plain_bytes) != plain_bytes_length:
raise ValueError(‘Invalid Ciphertext.’)
plain_bytes_digest = padded_plain_bytes[4 + plain_bytes_length:4 + plain_bytes_length + SHA256.digest_size]
if len(plain_bytes_digest) != SHA256.digest_size:
raise ValueError(‘Invalid Ciphertext.’)
if SHA256.new(plain_bytes).digest() != plain_bytes_digest:
raise ValueError(‘Invalid Ciphertext.’)
return plain_bytes.decode(‘utf-8’)
if __name__ == ‘__main__’:
import sys
def Help():
print(‘Usage:’)
print(‘ SecureCRTCipher.py [-v2] [-p ConfigPassphrase] ‘)
print(”)
print(‘ “enc” for encryption, “dec” for decryption.’)
print(‘ This parameter must be specified.’)
print(”)
print(‘ [-v2] Encrypt/Decrypt with “Password V2″ algorithm.’)
print(‘ This parameter is optional.’)
print(”)
print(‘ [-p ConfigPassphrase] The config passphrase that SecureCRT uses.’)
print(‘ This parameter is optional.’)
print(”)
print(‘ Plaintext string or ciphertext string.’)
print(‘ NOTICE: Ciphertext string must be a hex string.’)
print(‘ This parameter must be specified.’)
print(”)
def EncryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Plaintext : str):
try:
if UseV2:
print(SecureCRTCryptoV2(ConfigPassphrase).Encrypt(Plaintext))
else:
print(SecureCRTCrypto().Encrypt(Plaintext))
return True
except:
print(‘Error: Failed to encrypt.’)
return False
def DecryptionRoutine(UseV2 : bool, ConfigPassphrase : str, Ciphertext : str):
try:
if UseV2:
print(SecureCRTCryptoV2(ConfigPassphrase).Decrypt(Ciphertext))
else:
print(SecureCRTCrypto().Decrypt(Ciphertext))
return True
except:
print(‘Error: Failed to decrypt.’)
return False
def Main(argc : int, argv : list):
if 3 < = argc and argc <= 6: bUseV2 = False ConfigPassphrase = '' if argv[1].lower() == 'enc': bEncrypt = True elif argv[1].lower() == 'dec': bEncrypt = False else: Help() return -1 i = 2 while i < argc - 1: if argv[i].lower() == '-v2': bUseV2 = True i += 1 elif argv[i].lower() == '-p' and i + 1 < argc - 1: ConfigPassphrase = argv[i + 1] i += 2 else: Help() return -1 if bUseV2 == False and len(ConfigPassphrase) != 0: print('Error: ConfigPassphrase is not supported if "-v2" is not specified') return -1 if bEncrypt: return 0 if EncryptionRoutine(bUseV2, ConfigPassphrase, argv[-1]) else -1 else: return 0 if DecryptionRoutine(bUseV2, ConfigPassphrase, argv[-1]) else -1 else: Help() exit(Main(len(sys.argv), sys.argv))

DM8 DMDSC动态扩展节点

DMDSC动态扩展节点
DMDSC集群支持动态扩展节点,每次扩展可以在原有基础上增加一个节点。动态扩展节点要求当前DMDSC集群的所有节点都为OK状态,所有dmserver实例都处于OPEN状态,且可以正常访问。

注意:扩展节点过程中,不应该有修改数据库状态或模式的操作

一. 环境说明
新增节点环境为: 操作系统:RedHat Linux 64位。
网络配置:eth0网卡为10.10.13.0外网网段,该机器为10.10.13.203;eth1为11.11.11.0内网网段,该机器为11.11.11.5内网网段用于MAL通讯。
DM各种工具位于目录:/dm8/bin。
配置文件位于目录:/dm8/data。

二、操作系统配置
1、关闭防火墙和SELINUX

[root@dm8rac3 ~]# systemctl stop firewalld
[root@dm8rac3 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@dm8rac3 ~]# systemctl status firewalld
   firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 09 17:28:02 dm8rac3 systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 09 17:28:04 dm8rac3 systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 10 08:29:20 dm8rac3 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 10 08:29:21 dm8rac3 systemd[1]: Stopped firewalld - dynamic firewall daemon.

[root@dm8rac3 ~]# setenforce 0
[root@dm8rac3 ~]# sed -i s:^SELINUX=.*$:SELINUX=disabled:g /etc/selinux/config
[root@dm8rac3 ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

2、修改主机名

[root@dm8rac3 ~]# hostnamectl set-hostname dm8rac3
[root@dm8rac3 ~]# sed -i s:^HOSTNAME=.*$:HOSTNAME=dm8rac3:g /etc/sysconfig/network
[root@dm8rac3 ~]# echo "
>  10.10.13.201   dm8rac1
>  10.10.13.202   dm8rac2
>  10.10.13.203   dm8rac3" >> /etc/hosts
[root@dm8rac3 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 10.10.13.201   dm8rac1
 10.10.13.202   dm8rac2
 10.10.13.203   dm8rac3

[root@dm8rac1 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 10.10.13.201   dm8rac1
 10.10.13.202   dm8rac2
 10.10.13.203   dm8rac3

[root@dm8rac2 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

 10.10.13.201   dm8rac1
 10.10.13.202   dm8rac2
 10.10.13.203   dm8rac3

三、 安装达梦软件

3.1检查Linux(Unix)系统信息

[root@dm8rac3 ~]# getconf LONG_BIT
64

查询操作系统release信息

[root@dm8rac3 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 Beta (Maipo)

3.2创建安装用户
为了减少对操作系统的影响,用户不应该以root系统用户来安装和运行DM。用户可以在安装之前为DM创建一个专用的系统用户。
1. 创建安装用户组dinstall。

[root@dm8rac3 ~]# groupadd dinstall

2. 创建安装用户dmdba。

[root@dm8rac3 ~]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

3. 初始化用户密码。

[root@dm8rac3 ~]# passwd dmdba
Changing password for user dmdba.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

3.3 Linux(Unix)下检查操作系统限制
在Linux(Unix)系统中,因为ulimit命令的存在,会对程序使用操作系统资源进行限制。为了使DM能够正常运行,建议用户检查当前安装用户的ulimit参数。

运行ulimit -a进行查询。如下图所示:

[root@dm8rac3 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31152
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

参数使用限制:
1.data seg size
data seg size (kbytes, -d)
建议用户设置为1048576(即1GB)以上或unlimited(无限制),此参数过小将导致数据库启动失败。
2. file size
file size(blocks, -f)
建议用户设置为unlimited(无限制),此参数过小将导致数据库安装或初始化失败。
3. open files
open files(-n)
建议用户设置为65536以上或unlimited(无限制)。
4.virtual memory
virtual memory (kbytes, -v)
建议用户设置为1048576(即1GB)以上或unlimited(无限制),此参数过小将导致数据库启动失败。
如果用户需要为当前安装用户更改ulimit的资源限制,请修改文件/etc/security/limits.conf。

[root@dm8rac3 ~]# vi /etc/security/limits.conf
dmdba soft data unlimited
dmdba hard data unlimited
dmdba soft fsize unlimited
dmdba hard fsize unlimited
dmdba soft nofile 65536
dmdba hard nofile 65536

[root@dm8rac3 ~]# su - dmdba
[dmdba@dm8rac3 ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

3.4.检查系统内存与存储空间
1.检查内存
为了保证DM的正确安装和运行,要尽量保证操作系统至少1GB的可用内存(RAM)。如果可用内存过少,可能导致DM安装或启动失败。用户可以
使用以下命令检查操作内存:

#获取内存总大小
[root@dm8rac3 ~]# grep MemTotal /proc/meminfo
MemTotal:        8009068 kB

#获取交换分区大小
[root@dm8rac3 ~]# grep SwapTotal /proc/meminfo
SwapTotal:       8257532 kB

#获取内存使用详情
[root@dm8rac3 ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           6
Swap:             7           0           7

2.检查存储空间
1) DM完全安装需要1GB的存储空间,用户需要提前规划好安装目录,预留足够的存储空间。用户在DM安装前也应该为数据库实例预留足够的存储空间,规划好数据路径和备份路径。用户可使用以下命令检查存储空间:
#查询目录/dm8可用空间

[root@dm8rac3 ~]# mkdir /dm8
[root@dm8rac3 ~]# chown -R dmdba:dinstall /dm8
[root@dm8rac3 ~]# chmod -R 775 /dm8

[root@dm8rac3 ~]# df -h /dm8
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

2) DM安装程序在安装时将产生临时文件,临时文件需要1GB的存储空间,临时文件目录默认为/tmp。用户可以使用以下命令检查存储空间。
如下图所示:

[root@dm8rac3 ~]# df -h /tmp
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

3.5.安装DM
创建目录/soft/dmsoft用来存储挂载iso文件后来显示软件包中的文件

[root@dm8rac3 ~]# cd /soft
[root@dm8rac3 soft]# unzip dm8_20211021_x86_rh6_64_ent.zip
Archive:  dm8_20211021_x86_rh6_64_ent.zip
   creating: dm8_20211021_x86_rh6_64_ent/
  inflating: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso
 extracting: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso_SHA256.txt
 extracting: dm8_20211021_x86_rh6_64_ent/verinfo.txt
[root@dm8rac3 soft]# ls -lrt
total 778320
drwxr-xr-x. 2 root root       132 Nov 12 13:43 dm8_20211021_x86_rh6_64_ent
-rw-r--r--. 1 root root 796998047 Nov 29 10:25 dm8_20211021_x86_rh6_64_ent.zip
[root@dm8rac3 soft]# mv dm8_20211021_x86_rh6_64_ent dm8
[root@dm8rac3 soft]# mkdir dmsoft
[root@dm8rac3 soft]# mount -t iso9660 -o loop dm8/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso  /soft/dmsoft
mount: /dev/loop0 is write-protected, mounting read-only
[root@dm8rac3 soft]# cd dmsoft
[root@dm8rac3 dmsoft]# ls -lrt
total 790160
-r-xr-xr-x. 1 root root   2802503 Oct 21 14:04 DM8 Install.pdf
-r-xr-xr-x. 1 root root 806320703 Oct 21 14:11 DMInstall.bin

在/soft/dmsoft目录下存在DMInstall.bin文件, DMInstall.bin文件就是DM的安装程序。在运行安装程序前,需要赋予DMInstall.bin文件执行权限。具体命令如下所示:

[root@dm8rac3 dmsoft]# chmod 755  DMInstall.bin
chmod: changing permissions of ‘DMInstall.bin’: Read-only file system

在现实中,许多Linux(Unix)操作系统上是没有图形化界面的,为了使DM能够在这些操作系统上顺利安装,DM提供了命令行的安装方式。在终端进入到安装程序所在文件夹,执行以下命令进行命令行安装:

[dmdba@dm8rac3 dmsoft]$ ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:e
Extract install files.........
Welcome to DM DBMS Installer

Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n

Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:21

Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:4
1 Server component
2 Client component
  2.1 Manager
  2.2 Monitor
  2.3 DTS
  2.4 Console
  2.5 Analyzer
  2.6 DISQL
3 DM Drivers
4 Manual component
5 DBMS Service
  5.1 Realtime Audit Service
  5.2 Job Service
  5.3 Instance Monitor Service
  5.4 Assistant Plug-In Service
Please Input the number of the Installation Type [1 2 3 4 5]:1 2 3 4 5
Require Space: 1242M

Please Input the install path [/home/dmdba/dmdbms]:/dm8
Available Space:39G
Please Confirm the install path(/dm8)? (Y/y:Yes N/n:No) [Y/y]:y

Pre-Installation Summary
Installation Location: /dm8
Require Space: 1242M
Available Space: 39G
Version Information:
Expire Date:
Installation Type: Custom
Confirm to Install? (Y/y:Yes N/n:No):y
2021-12-10 08:52:34
[INFO] Installing DM DBMS...
2021-12-10 08:52:34
[INFO] Installing BASE Module...
2021-12-10 08:52:36
[INFO] Installing SERVER Module...
2021-12-10 08:52:39
[INFO] Installing CLIENT Module...
2021-12-10 08:52:54
[INFO] Installing DRIVERS Module...
2021-12-10 08:52:55
[INFO] Installing MANUAL Module...
2021-12-10 08:52:55
[INFO] Installing SERVICE Module...
2021-12-10 08:53:03
[INFO] Move log file to log directory.
2021-12-10 08:53:04
[INFO] Installed DM DBMS completely.

Please execute the commands by root:
/dm8/script/root/root_installer.sh

End

以root用户来执行上面的脚本

[root@dm8rac3 ~]# /dm8/script/root/root_installer.sh
Move /dm8/bin/dm_svc.conf to /etc
Modify the files' mode of DM Server

[dmdba@dm8rac3 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
export PATH=$PATH:$LD_LIBRARY_PATH

四、绑定UDEV
编辑/etc/udev/rules.d/99-dm-devices.rules文件

[root@dm8rac3 ~]# vi /etc/udev/rules.d/99-dm-devices.rules
ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sde", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdf", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdg", RUN+="/bin/raw /dev/raw/raw6 %N"

ACTION=="add", KERNEL=="raw[1-6]", OWNER="dmdba", GROUP="dinstall", MODE="660"

如果不能正常显示就重启操作系统

[root@dm8rac3 ~]# ls -lrt /dev/raw/
total 0
crw-rw---- 1 root  disk     162, 0 Dec 10 09:01 rawctl
crw-rw---- 1 dmdba dinstall 162, 6 Dec 10 09:01 raw6
crw-rw---- 1 dmdba dinstall 162, 5 Dec 10 09:01 raw5
crw-rw---- 1 dmdba dinstall 162, 4 Dec 10 09:01 raw4
crw-rw---- 1 dmdba dinstall 162, 3 Dec 10 09:01 raw3
crw-rw---- 1 dmdba dinstall 162, 1 Dec 10 09:01 raw1
crw-rw---- 1 dmdba dinstall 162, 2 Dec 10 09:01 raw2

可以通过blockdev –getsize64 /dev/raw/raw1命令查看裸设备大小

[root@dm8rac3 ~]# blockdev --getsize64 /dev/raw/raw1
2147483648
[root@dm8rac3 ~]# blockdev --getsize64 /dev/raw/raw2
2147483648
[root@dm8rac3 ~]# blockdev --getsize64 /dev/raw/raw3
10737418240
[root@dm8rac3 ~]# blockdev --getsize64 /dev/raw/raw4
10737418240
[root@dm8rac3 ~]# blockdev --getsize64 /dev/raw/raw5
10737418240
[root@dm8rac3 ~]# blockdev --getsize64 /dev/raw/raw6
10737418240

四. 操作流程
1. 在10.10.13.201机器上使用DMASMCMD工具export出备份dmdcr_cfg_bak.ini

[dmdba@dm8rac1 ~]$ dmasmcmd
DMASMCMD V8
ASM>export dcrdisk '/dev/raw/raw1' to '/dm8/data/dmdcr_cfg_bak.ini'
ASMCMD export DCRDISK success.
Used time: 59.153(ms).

2. 为新增节点准备日志文件
1) 使用DIsql登录任意一个节点执行添加日志文件操作:
至少两个日志文件,路径必须是ASM文件格式,大小可以参考其他两个活动节点。

SQL> alter database add node logfile '+DMLOG/log/rac2_log01.log' size 256,'+DMLOG/log/rac2_log02.log' size 256;
executed successfully
used time: 00:00:01.419. Execute id is 208.

2)使用dmctlcvt工具将dm.ctl转换为文本文件dmctl.txt,查看dmctl.txt,新增节点的日志文件信息已经添加进dm.ctl。

[dmdba@dm8rac1 data]$ dmctlcvt TYPE=1 SRC=+DMDATA/data/rac/dm.ctl DEST=/dm8/data/dmctl.txt DCR_INI=/dm8/data/dmdcr.ini
DMCTLCVT V8
convert ctl to txt success!
[dmdba@dm8rac1 data]$ ls -lrt
total 28
-rw-r--r-- 1 dmdba dinstall  956 Dec  8 09:24 dmdcr_cfg.ini
-rw-r--r-- 1 dmdba dinstall  143 Dec  8 09:29 dmasvrmal.ini
-rw-r--r-- 1 dmdba dinstall  328 Dec  8 09:37 dmdcr.ini
-rw-r--r-- 1 dmdba dinstall  864 Dec  8 10:13 dminit.ini
drwxr-xr-x 2 dmdba dinstall   55 Dec  8 10:17 rac1_config
drwxr-xr-x 3 dmdba dinstall  100 Dec  8 10:36 rac0_config
-rw-r--r-- 1 dmdba dinstall 1647 Dec 10 09:06 dmdcr_cfg_bak.ini
-rw-r--r-- 1 dmdba dinstall 8158 Dec 10 09:23 dmctl.txt

[dmdba@dm8rac1 data]$ more dmctl.txt
# file path
fil_path=+DMLOG/log/rac2_log01.log
# mirror path
mirror_path=
# file id
fil_id=0
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-10 9:20:50'
# file modify time
fil_modify_time=DATETIME '2021-12-10 9:20:50'
# the max size of file
fil_max_size=0
# next size of file
fil_next_size=0

# file path
fil_path=+DMLOG/log/rac2_log02.log
# mirror path
mirror_path=
# file id
fil_id=1
# whether the file is auto extend
autoextend=1
# file create time
fil_create_time=DATETIME '2021-12-10 9:20:50'
# file modify time
fil_modify_time=DATETIME '2021-12-10 9:20:50'
# the max size of file

3)使用dmasmtool工具登录ASM文件系统,也可以看到新增的节点日志文件

[dmdba@dm8rac1 ~]$ dmasmtool DCR_INI=/dm8/data/dmdcr.ini
DMASMTOOL V8
ASM>ls  +DMLOG/log
        file : rac0_log01.log
        file : rac0_log02.log
        file : rac1_log01.log
        file : rac1_log02.log
        file : rac2_log01.log
        file : rac2_log02.log
total count 6.
Used time: 6.598(ms).

3. 为新增节点准备config_path
将10.10.13.201机器/dm8/data/rac0_config目录拷贝到10.10.13.203机器相同目录下,修改名字为/dm8/data/rac2_config。

[dmdba@dm8rac1 data]$ scp -r rac0_config 10.10.13.203:`pwd`
The authenticity of host '10.10.13.203 (10.10.13.203)' can't be established.
ECDSA key fingerprint is SHA256:6O8c9WEeEYPbL4ncdRR1RsrjxxmfzPq9Tkq4/6uLSP4.
ECDSA key fingerprint is MD5:e1:73:3e:8d:79:be:5c:82:0f:c7:58:79:45:ad:df:86.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.13.203' (ECDSA) to the list of known hosts.
dmdba@10.10.13.203's password:
dmmal.ini                                                                                                                                                                                                100%  200     8.5KB/s   00:00
dminit20211208101727.log                                                                                                                                                                                 100% 1144    70.0KB/s   00:00
dm.ini                                                                                                                                                                                                   100%   53KB   3.2MB/s   00:00
sqllog.ini                                                                                                                                                                                               100%  481    19.3KB/s   00:00
[dmdba@dm8rac1 data]$

[dmdba@dm8rac3 data]$ mv rac0_config rac2_config
[dmdba@dm8rac3 data]$ ls -lrt
total 0
drwxr-xr-x 2 dmdba dinstall   6 Dec 10 09:54 trace
drwxr-xr-x 3 dmdba dinstall 100 Dec 10 09:56 rac2_config

修改dsc2_config文件夹下的配置文件:
1) 修改dm.ini

[dmdba@dm8rac3 rac2_config]$ vi dm.ini
CONFIG_PATH                     = /dm8/data/rac2_config            #config path

INSTANCE_NAME                   = RAC2              #Instance name

2) 如果打开了归档参数,修改dmarch.ini

4. 新建dmdcr.ini配置文件,保存到节点10.0.2.103的/dm8/data/目录下面注意设置dmdcr_seqo为2,修改dm.ini路径。

[dmdba@dm8rac3 data]$ vi dmdcr.ini
DMDCR_PATH = /dev/raw/raw1
DMDCR_MAL_PATH =/dm8/data/dmasvrmal.ini
DMDCR_SEQNO = 2

#ASM
DMDCR_ASM_RESTART_INTERVAL = 0
DMDCR_ASM_STARTUP_CMD = /dm8/bin/dmasmsvr dcr_ini=/dm8/data/dmdcr.ini

#DB
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD = /dm8/bin/dmserver path=/dm8/data/rac2_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini

5. 修改当前环境的MAL配置文件
直接修改当前环境的dmasvrmal.ini文件,添加新增节点信息,使用DMASM的所有节点都要配置,内容完全一样,并且将新增信息后的dmasvrmal.ini文件拷贝到节点10.10.13.203的/dm8/data目录下。

[dmdba@dm8rac1 data]$ vi dmasvrmal.ini
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 11.11.11.1
MAL_PORT = 7236

[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 11.11.11.2
MAL_PORT = 7236

[MAL_INST3]
MAL_INST_NAME = ASM2
MAL_HOST = 11.11.11.5
MAL_PORT = 7236

[dmdba@dm8rac2 data]$ vi dmasvrmal.ini
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 11.11.11.1
MAL_PORT = 7236

[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 11.11.11.2
MAL_PORT = 7236

[MAL_INST3]
MAL_INST_NAME = ASM2
MAL_HOST = 11.11.11.5
MAL_PORT = 7236

[dmdba@dm8rac3 data]$ vi dmasvrmal.ini
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 11.11.11.1
MAL_PORT = 7236

[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 11.11.11.2
MAL_PORT = 7236

[MAL_INST3]
MAL_INST_NAME = ASM2
MAL_HOST = 11.11.11.5
MAL_PORT = 7236

直接修改dmserver三个实例的dmmal.ini,添加新增节点信息,所有节点都要配置相同内容,保存到各自的rac_config目录下

[dmdba@dm8rac1 rac0_config]$ vi dmmal.ini
[mal_inst0]
    mal_inst_name  = RAC0
    mal_host       = 11.11.11.1
    mal_port       = 9340

[mal_inst1]
    mal_inst_name  = RAC1
    mal_host       = 11.11.11.2
    mal_port       = 9340

[mal_inst2]
    mal_inst_name  = RAC2
    mal_host       = 11.11.11.5
    mal_port       = 9340

[dmdba@dm8rac2 rac1_config]$ vi dmmal.ini
[mal_inst0]
    mal_inst_name  = RAC0
    mal_host       = 11.11.11.1
    mal_port       = 9340

[mal_inst1]
    mal_inst_name  = RAC1
    mal_host       = 11.11.11.2
    mal_port       = 9340

[mal_inst2]
    mal_inst_name  = RAC2
    mal_host       = 11.11.11.5
    mal_port       = 9340



[dmdba@dm8rac3 rac2_config]$ vi dmmal.ini
[mal_inst0]
    mal_inst_name  = RAC0
    mal_host       = 11.11.11.1
    mal_port       = 9340

[mal_inst1]
    mal_inst_name  = RAC1
    mal_host       = 11.11.11.2
    mal_port       = 9340

[mal_inst2]
    mal_inst_name  = RAC2
    mal_host       = 11.11.11.5
    mal_port       = 9340

后续实例会重新读MAL配置文件,更新内存信息。

6. 修改dmdcr_cfg_bak.ini,添加新增节点信息,CSS/ASMSVR/DB都要配置
所有组信息修改:

DCR_GRP_N_EP = 3
DCR_GRP_EP_ARR = {0,1,2}

每个组增加一个节点信息,注意DCR_EP_SHM_KEY、端口号不能冲突;各组信息要放在各自的后面,即[GRP_CSS]中CSS2放在CSS1后面,[GRP_ASM]中ASM2放在ASM1后面,RAC2放在RAC1后面。

[dmdba@dm8rac1 data]$ cat dmdcr_cfg_bak.ini
# the file is auto-created by system, self edit is invalid!
#DCR HDR
DCR_N_GRP              = 3
DCR_VTD_PATH           = /dev/raw/raw2
DCR_OGUID              = 63635

[GRP]
DCR_GRP_TYPE           = CSS
DCR_GRP_NAME           = GRP_CSS
DCR_GRP_N_EP           = 3
DCR_GRP_EP_ARR         = {0,1,2}
DCR_GRP_N_ERR_EP       = 0
DCR_GRP_ERR_EP_ARR     = {}
DCR_GRP_DSKCHK_CNT     = 60

[GRP]
DCR_GRP_TYPE           = ASM
DCR_GRP_NAME           = GRP_ASM
DCR_GRP_N_EP           = 3
DCR_GRP_EP_ARR         = {0,1,2}
DCR_GRP_N_ERR_EP       = 0
DCR_GRP_ERR_EP_ARR     = {}
DCR_GRP_DSKCHK_CNT     = 60

[GRP]
DCR_GRP_TYPE           = DB
DCR_GRP_NAME           = GRP_RAC
DCR_GRP_N_EP           = 3
DCR_GRP_EP_ARR         = {0,1,2}
DCR_GRP_N_ERR_EP       = 0
DCR_GRP_ERR_EP_ARR     = {}
DCR_GRP_DSKCHK_CNT     = 60

[GRP_CSS]
DCR_EP_NAME        = CSS0
DCR_EP_HOST        = 11.11.11.1
DCR_EP_PORT        = 9541

[GRP_CSS]
DCR_EP_NAME        = CSS1
DCR_EP_HOST        = 11.11.11.2
DCR_EP_PORT        = 9541

[GRP_CSS]
DCR_EP_NAME        = CSS2
DCR_EP_HOST        = 11.11.11.5
DCR_EP_PORT        = 9541

[GRP_ASM]
DCR_EP_NAME        = ASM0
DCR_EP_SHM_KEY     = 93360
DCR_EP_SHM_SIZE    = 10
DCR_EP_HOST        = 10.10.13.201
DCR_EP_PORT        = 9641
DCR_EP_ASM_LOAD_PATH  = /dev/raw

[GRP_ASM]
DCR_EP_NAME        = ASM1
DCR_EP_SHM_KEY     = 93361
DCR_EP_SHM_SIZE    = 10
DCR_EP_HOST        = 10.10.13.202
DCR_EP_PORT        = 9641
DCR_EP_ASM_LOAD_PATH  = /dev/raw

[GRP_ASM]
DCR_EP_NAME        = ASM2
DCR_EP_SHM_KEY     = 93362
DCR_EP_SHM_SIZE    = 10
DCR_EP_HOST        = 10.10.13.203
DCR_EP_PORT        = 9641
DCR_EP_ASM_LOAD_PATH  = /dev/raw

[GRP_RAC]
DCR_EP_NAME        = RAC0
DCR_EP_SEQNO       = 0
DCR_EP_PORT        = 5236
DCR_CHECK_PORT     = 9741

[GRP_RAC]
DCR_EP_NAME        = RAC1
DCR_EP_SEQNO       = 1
DCR_EP_PORT        = 5236
DCR_CHECK_PORT     = 9741

[GRP_RAC]
DCR_EP_NAME        = RAC2
DCR_EP_SEQNO       = 2
DCR_EP_PORT        = 5236
DCR_CHECK_PORT     = 9741

7. 使用DMASMCMD工具将新增节点信息写回磁盘,新增节点作为error节点

[dmdba@dm8rac1 ~]$ dmasmcmd
DMASMCMD V8
ASM>extend dcrdisk '/dev/raw/raw1' from '/dm8/data/dmdcr_cfg_bak.ini'
ASMCMD extend node for dcr disk success.
ASMCMD extend node for vote disk success.
Used time: 00:00:02.362.

8. 在dmcssm控制台执行扩展节点命令

先配置dmcssm.ini文件

[dmdba@dm8rac1 data]$ vi dmcssm.ini
CSSM_OGUID = 63635
#配置所有CSS的连接信息,
#和dmdcr_cfg.ini中CSS配置项的DCR_EP_HOST和DCR_EP_PORT保持一致
CSSM_CSS_IP = 11.11.11.1:9541
CSSM_CSS_IP = 11.11.11.2:9541
CSSM_CSS_IP = 11.11.11.5:9541
CSSM_LOG_PATH =/dm8/dmcssm/log #监视器日志文件存放路径
CSSM_LOG_FILE_SIZE = 32 #每个日志文件最大32M
CSSM_LOG_SPACE_LIMIT = 0 #不限定日志文件总占用空间

启动dmcssm监视器

[dmdba@dm8rac1 ~]$ dmcssm INI_PATH=/dm8/data/dmcssm.ini
[monitor]         2021-12-10 10:46:32: CSS MONITOR V8
[monitor]         2021-12-10 10:46:32: CSS MONITOR SYSTEM IS READY.

[monitor]         2021-12-10 10:46:32: Wait CSS Control Node choosed...
[monitor]         2021-12-10 10:46:33: Wait CSS Control Node choosed succeed.

show

monitor current time:2021-12-10 10:46:57, n_group:3
=================== group[name = GRP_CSS, seq = 0, type = CSS, Control Node = 0] ========================================

[CSS0] auto check = TRUE, global info:
[ASM0] auto restart = FALSE
[RAC0] auto restart = FALSE

[CSS1] auto check = TRUE, global info:
[ASM1] auto restart = FALSE
[RAC1] auto restart = FALSE


ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 10:46:57    CSS0          0         9541    Control Node OPEN               WORKING      OK           TRUE         738576474         738751954
        2021-12-10 10:46:57    CSS1          1         9541    Normal Node  OPEN               WORKING      OK           TRUE         738606319         738781682

=================== group[name = GRP_ASM, seq = 1, type = ASM, Control Node = 0] ========================================

n_ok_ep = 2
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 10:46:57    ASM0          0         9641    Control Node OPEN               WORKING      OK           TRUE         738588988         738764427
        2021-12-10 10:46:57    ASM1          1         9641    Normal Node  OPEN               WORKING      OK           TRUE         738624010         738799326

=================== group[name = GRP_RAC, seq = 2, type = DB, Control Node = 0] ========================================

n_ok_ep = 2
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 10:46:57    RAC0          0         5236    Control Node OPEN               WORKING      OK           TRUE         2383210041        2383382787
        2021-12-10 10:46:57    RAC1          1         5236    Normal Node  OPEN               WORKING      OK           TRUE         2383231629        2383404339

==================================================================================================================

extend node
[monitor]         2021-12-10 10:47:13: Extend node

[monitor]         2021-12-10 10:47:15: Notify current active CSS to do clear
[monitor]         2021-12-10 10:47:16: Clean request of CSS(0) success
[monitor]         2021-12-10 10:47:17: Clean request of CSS(1) success
[monitor]         2021-12-10 10:47:17: Command EXTENT NODE  execute success

show

monitor current time:2021-12-10 10:47:22, n_group:3
=================== group[name = GRP_CSS, seq = 0, type = CSS, Control Node = 0] ========================================

[CSS0] auto check = TRUE, global info:
[ASM0] auto restart = FALSE
[RAC0] auto restart = FALSE

[CSS1] auto check = TRUE, global info:
[ASM1] auto restart = FALSE
[RAC1] auto restart = FALSE

[CSS2] auto check = FALSE, global info:
Connect to [CSS2] failed, please check the network or the CSSM_CSS_IP config in [/dm8/data/dmcssm.ini] .

ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 10:47:22    CSS0          0         9541    Control Node OPEN               WORKING      OK           TRUE         738576474         738751979
        2021-12-10 10:47:22    CSS1          1         9541    Normal Node  OPEN               WORKING      OK           TRUE         738606319         738781707
        2021-12-10 10:47:22    CSS2          2         9541    Normal Node  SHUTDOWN           UNKNOWN      OK           FALSE        0                 0

=================== group[name = GRP_ASM, seq = 1, type = ASM, Control Node = 0] ========================================

n_ok_ep = 2
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 10:47:22    ASM0          0         9641    Control Node OPEN               WORKING      OK           TRUE         738588988         738764452
        2021-12-10 10:47:22    ASM1          1         9641    Normal Node  OPEN               WORKING      OK           TRUE         738624010         738799351
        2021-12-10 10:47:22    ASM2          2         9641    Normal Node  SHUTDOWN           UNKNOWN      ERROR        FALSE        0                 0

=================== group[name = GRP_RAC, seq = 2, type = DB, Control Node = 0] ========================================

n_ok_ep = 2
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 10:47:22    RAC0          0         5236    Control Node OPEN               WORKING      OK           TRUE         2383210041        2383382812
        2021-12-10 10:47:22    RAC1          1         5236    Normal Node  OPEN               WORKING      OK           TRUE         2383231629        2383404364
        2021-12-10 10:47:22    RAC2          2         5236    Normal Node  SHUTDOWN           UNKNOWN      ERROR        FALSE        0                 0

==================================================================================================================

程序会通知所有实例(CSS/ASMSVR/dmserver)更新信息,在CSS控制台执行SHOW命令,能看到新增节点信息,ASMSVR/dmserver是error节点,程序会通知ASMSVR/dmserver更新MAL信息。

注意:如果由于配置文件错误,动态扩展节点失败,只能停掉所有实例,重新init dcr磁盘,不影响dmserver数据

9. 启动新的DMCSS、DMASM服务程序
在10.10.13.203节点启动dmcss、dmasmsvr程序。
手动启动新的dmcss,dcr_ini指向新的dmdcr.ini文件:

[/opt/dmdbms/bin]# ./dmcss DCR_INI=/home/data/dmdcr.ini

手动启动新的dmasmsvr,dcr_ini指向新的dmdcr.ini文件,asmsvr启动故障重加入流程:

[/opt/dmdbms/bin]# ./dmasmsvr DCR_INI=/home/data/dmdcr.ini

如果DMCSS配置有自动拉起dmasmsvr的功能,可以等待DMCSS自动拉起dmasmsvr程序,不需要手动启动。

我这里将服务注册成服务

[root@dm8rac3 system]# /dm8/script/root/dm_service_installer.sh -t dmcss -dcr_ini /dm8/data/dmdcr.ini -p rac3
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServicerac3.service to /usr/lib/systemd/system/DmCSSServicerac3.service.
Finished to create the service (DmCSSServicerac3)
[root@dm8rac3 system]# /dm8/script/root/dm_service_installer.sh -t dmasmsvr -dcr_ini /dm8/data/dmdcr.ini -p rac3 -y DmCSSServicerac3
Created symlink from /etc/systemd/system/multi-user.target.wants/DmASMSvrServicerac3.service to /usr/lib/systemd/system/DmASMSvrServicerac3.service.
Finished to create the service (DmASMSvrServicerac3)
[root@dm8rac3 system]#
[root@dm8rac3 system]# service DmCSSServicerac3 start
Redirecting to /bin/systemctl start DmCSSServicerac3.service
[root@dm8rac3 system]# service DmCSSServicerac3 status
Redirecting to /bin/systemctl status DmCSSServicerac3.service
   DmCSSServicerac3.service - DM Cluster Synchronization Services Service(DmCSSServicerac3).
   Loaded: loaded (/usr/lib/systemd/system/DmCSSServicerac3.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-12-10 10:59:41 CST; 19s ago
  Process: 4340 ExecStart=/dm8/bin/DmCSSServicerac3 start (code=exited, status=0/SUCCESS)
 Main PID: 4368 (dmcss)
    Tasks: 12
   CGroup: /system.slice/DmCSSServicerac3.service
           └─4368 /dm8/bin/dmcss dcr_ini=/dm8/data/dmdcr.ini

Dec 10 10:59:26 dm8rac3 systemd[1]: Starting DM Cluster Synchronization Services Service(DmCSSServicerac3)....
Dec 10 10:59:41 dm8rac3 DmCSSServicerac3[4340]: [38B blob data]
Dec 10 10:59:41 dm8rac3 systemd[1]: Started DM Cluster Synchronization Services Service(DmCSSServicerac3)..
[root@dm8rac3 system]# service DmASMSvrServicerac3 start
Redirecting to /bin/systemctl start DmASMSvrServicerac3.service
[root@dm8rac3 system]# service DmASMSvrServicerac3 status
Redirecting to /bin/systemctl status DmASMSvrServicerac3.service
   DmASMSvrServicerac3.service - DM Auto Storage Manager Service(DmASMSvrServicerac3).
   Loaded: loaded (/usr/lib/systemd/system/DmASMSvrServicerac3.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-12-10 11:00:23 CST; 7s ago
  Process: 4441 ExecStart=/dm8/bin/DmASMSvrServicerac3 start (code=exited, status=0/SUCCESS)
 Main PID: 4467 (dmasmsvr)
    Tasks: 18
   CGroup: /system.slice/DmASMSvrServicerac3.service
           └─4467 /dm8/bin/dmasmsvr dcr_ini=/dm8/data/dmdcr.ini

Dec 10 11:00:08 dm8rac3 systemd[1]: Starting DM Auto Storage Manager Service(DmASMSvrServicerac3)....
Dec 10 11:00:23 dm8rac3 DmASMSvrServicerac3[4441]: [41B blob data]
Dec 10 11:00:23 dm8rac3 systemd[1]: Started DM Auto Storage Manager Service(DmASMSvrServicerac3)..

show

monitor current time:2021-12-10 11:01:08, n_group:3
=================== group[name = GRP_CSS, seq = 0, type = CSS, Control Node = 0] ========================================

[CSS0] auto check = TRUE, global info:
[ASM0] auto restart = FALSE
[RAC0] auto restart = FALSE

[CSS1] auto check = TRUE, global info:
[ASM1] auto restart = FALSE
[RAC1] auto restart = FALSE

[CSS2] auto check = TRUE, global info:
[ASM2] auto restart = FALSE
[RAC2] auto restart = FALSE


ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 11:01:08    CSS0          0         9541    Control Node OPEN               WORKING      OK           TRUE         738576474         738752802
        2021-12-10 11:01:08    CSS1          1         9541    Normal Node  OPEN               WORKING      OK           TRUE         738606319         738782529
        2021-12-10 11:01:08    CSS2          2         9541    Normal Node  OPEN               WORKING      OK           TRUE         790591989         790592089

=================== group[name = GRP_ASM, seq = 1, type = ASM, Control Node = 0] ========================================

n_ok_ep = 3
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)
(2, 2)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 11:01:08    ASM0          0         9641    Control Node OPEN               WORKING      OK           TRUE         738588988         738765275
        2021-12-10 11:01:08    ASM1          1         9641    Normal Node  OPEN               WORKING      OK           TRUE         738624010         738800174
        2021-12-10 11:01:08    ASM2          2         9641    Normal Node  OPEN               WORKING      OK           TRUE         790605125         790605178

=================== group[name = GRP_RAC, seq = 2, type = DB, Control Node = 0] ========================================

n_ok_ep = 2
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 11:01:08    RAC0          0         5236    Control Node OPEN               WORKING      OK           TRUE         2383210041        2383383635
        2021-12-10 11:01:08    RAC1          1         5236    Normal Node  OPEN               WORKING      OK           TRUE         2383231629        2383405186
        2021-12-10 11:01:08    RAC2          2         5236    Normal Node  SHUTDOWN           UNKNOWN      ERROR        FALSE        0                 0

==================================================================================================================

10. 启动新的数据库服务器
如果DMCSS配置有自动拉起dmserver的功能,可以等待DMCSS自动拉起实例,不需要手动启动。
如果需要手动启动,可参考下面的操作步骤:
10.10.13.203机器:

./dmserver /home/data/dsc2_config/dm.ini dcr_ini=/home/data/dmdcr.ini

我这里注册成服务来启动数据库

[root@dm8rac3 system]# /dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /dm8/data/rac2_config/dm.ini -dcr_ini /dm8/data/dmdcr.ini -p rac3 -y DmASMSvrServicerac3
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicerac3.service to /usr/lib/systemd/system/DmServicerac3.service.
Finished to create the service (DmServicerac3)
[root@dm8rac3 system]# service DmServicerac3 start
Redirecting to /bin/systemctl start DmServicerac3.service
[root@dm8rac3 system]# service DmServicerac3 status
Redirecting to /bin/systemctl status DmServicerac3.service
   DmServicerac3.service - DM Instance Service(DmServicerac3).
   Loaded: loaded (/usr/lib/systemd/system/DmServicerac3.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2021-12-10 11:05:56 CST; 7s ago
  Process: 4673 ExecStart=/dm8/bin/DmServicerac3 start (code=exited, status=0/SUCCESS)
 Main PID: 4704 (dmserver)
    Tasks: 105
   CGroup: /system.slice/DmServicerac3.service
           └─4704 /dm8/bin/dmserver path=/dm8/data/rac2_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini -noconsole

Dec 10 11:05:40 dm8rac3 systemd[1]: Starting DM Instance Service(DmServicerac3)....
Dec 10 11:05:41 dm8rac3 DmServicerac3[4673]: Starting DmServicerac3: connnect dmasmtool successfully.
Dec 10 11:05:56 dm8rac3 DmServicerac3[4673]: [11B blob data]
Dec 10 11:05:56 dm8rac3 systemd[1]: Started DM Instance Service(DmServicerac3)..

show

monitor current time:2021-12-10 11:06:09, n_group:3
=================== group[name = GRP_CSS, seq = 0, type = CSS, Control Node = 0] ========================================

[CSS0] auto check = TRUE, global info:
[ASM0] auto restart = FALSE
[RAC0] auto restart = FALSE

[CSS1] auto check = TRUE, global info:
[ASM1] auto restart = FALSE
[RAC1] auto restart = FALSE

[CSS2] auto check = TRUE, global info:
[ASM2] auto restart = FALSE
[RAC2] auto restart = FALSE


ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 11:06:09    CSS0          0         9541    Control Node OPEN               WORKING      OK           TRUE         738576474         738753101
        2021-12-10 11:06:09    CSS1          1         9541    Normal Node  OPEN               WORKING      OK           TRUE         738606319         738782829
        2021-12-10 11:06:09    CSS2          2         9541    Normal Node  OPEN               WORKING      OK           TRUE         790591989         790592389

=================== group[name = GRP_ASM, seq = 1, type = ASM, Control Node = 0] ========================================

n_ok_ep = 3
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)
(2, 2)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 11:06:09    ASM0          0         9641    Control Node OPEN               WORKING      OK           TRUE         738588988         738765574
        2021-12-10 11:06:09    ASM1          1         9641    Normal Node  OPEN               WORKING      OK           TRUE         738624010         738800474
        2021-12-10 11:06:09    ASM2          2         9641    Normal Node  OPEN               WORKING      OK           TRUE         790605125         790605478

=================== group[name = GRP_RAC, seq = 2, type = DB, Control Node = 0] ========================================

n_ok_ep = 3
ok_ep_arr(index, seqno):
(0, 0)
(1, 1)
(2, 2)

sta = OPEN, sub_sta = STARTUP
break ep = NULL
recover ep = NULL

crash process over flag is TRUE
ep:     css_time               inst_name     seqno     port    mode         inst_status        vtd_status   is_ok        active       guid              ts
        2021-12-10 11:06:09    RAC0          0         5236    Control Node OPEN               WORKING      OK           TRUE         2383210041        2383383934
        2021-12-10 11:06:09    RAC1          1         5236    Normal Node  OPEN               WORKING      OK           TRUE         2383231629        2383405486
        2021-12-10 11:06:09    RAC2          2         5236    Normal Node  OPEN               WORKING      OK           TRUE         2557760476        2557760496

==================================================================================================================

五.注意事项
1. 扩展节点前由用户保证所有dmcss/dmasmsvr/dmserver节点都是OK的,且都是活动的;
2. 每次扩展节点只能扩一个节点,扩展完成后可以再继续扩展节点;
3. 扩展节点的过程中不能出现修改实例状态或模式的操作;
4. 扩展节点的过程中,如果发生dmcss/dmasmsvr/dmserver实例故障,会导致扩展失败;
5. 扩展过程中操作失误(比如未修改dmmal.ini、asmsvrmal.ini,未增加日志文件),会导致扩展失败;
6. 执行完extend node命令,用户需要查看log文件,确认扩展操作是否成功;
7. 扩展失败可能会导致集群环境异常,需要退出所有dmcss/dmasmsvr/dmserver,重新init dcr磁盘。

DM8 使用裸设备搭建DMRAC

使用裸设备搭建DMRAC
一、操作环境

主机	IP地址(对外服务)	        IP地址(内部通信)	       实例名	操作系统
dm8dsc1	10.10.13.205	        11.11.11.3	        dsc0	Redhat 7.8
dm8dsc2	10.10.13.206	        11.11.11.4	        dsc1	Redhat 7.8

共享存储

/dev/sdb	/dev/raw/raw1	dcr disk	2G
/dev/sdc	/dev/raw/raw2	voting disk	2G
/dev/sdd1	/dev/raw/raw3	log disk1	2G
/dev/sdd2	/dev/raw/raw4	log disk2	2G
/dev/sdd3	/dev/raw/raw5	log disk3	2G
/dev/sdd5	/dev/raw/raw6	log disk4	2G
/dev/sde1	/dev/raw/raw7	data disk1	5G
/dev/sde2	/dev/raw/raw8	data disk2	5G
/dev/sdf1	/dev/raw/raw9	data disk3	5G
/dev/sdf2	/dev/raw/raw10	data disk4	5G
/dev/sdg1	/dev/raw/raw11	data disk5	5G
/dev/sdg2	/dev/raw/raw12	data disk6	5G

二、操作系统配置
1、关闭防火墙和SELINUX

[root@gbase ~]# systemctl stop firewalld
[root@gbase ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@gbase ~]# systemctl status firewalld
 firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 08 10:57:13 gbase systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 08 10:57:17 gbase systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 08 14:46:41 gbase systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 08 14:46:42 gbase systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@gbase ~]# setenforce 0
[root@gbase ~]# sed -i s:^SELINUX=.*$:SELINUX=disabled:g /etc/selinux/config
[root@gbase ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


[root@gbase ~]# systemctl stop firewalld
[root@gbase ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@gbase ~]# systemctl status firewalld
 firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Dec 08 10:57:19 gbase systemd[1]: Starting firewalld - dynamic firewall daemon...
Dec 08 10:57:21 gbase systemd[1]: Started firewalld - dynamic firewall daemon.
Dec 08 14:46:45 gbase systemd[1]: Stopping firewalld - dynamic firewall daemon...
Dec 08 14:46:46 gbase systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@gbase ~]# setenforce 0
[root@gbase ~]# sed -i s:^SELINUX=.*$:SELINUX=disabled:g /etc/selinux/config
[root@gbase ~]# cat /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

2、修改主机名

[root@gbase ~]# hostnamectl set-hostname dm8dsc1
[root@gbase ~]# sed -i s:^HOSTNAME=.*$:HOSTNAME=dm8dsc1:g /etc/sysconfig/network
[root@gbase ~]# echo "
> 10.10.13.205   dm8dsc1
> 10.10.13.206   dm8dsc2" >> /etc/hosts
[root@gbase ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.13.205   dm8dsc1
10.10.13.206   dm8dsc2


[root@gbase ~]# hostnamectl set-hostname dm8dsc2
[root@gbase ~]# sed -i s:^HOSTNAME=.*$:HOSTNAME=dm8dsc2:g /etc/sysconfig/network
[root@gbase ~]# echo "
> 10.10.13.205   dm8dsc1
> 10.10.13.206   dm8dsc2" >> /etc/hosts
[root@gbase ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

10.10.13.205   dm8dsc1
10.10.13.206   dm8dsc2

三、 安装达梦软件

3.1检查Linux(Unix)系统信息

[root@dm8dsc1 ~]# getconf LONG_BIT
64

[root@dm8dsc2 ~]# getconf LONG_BIT
64

查询操作系统release信息

[root@dm8dsc1 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 Beta (Maipo)


[root@dm8dsc2 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 Beta (Maipo)

3.2创建安装用户
为了减少对操作系统的影响,用户不应该以root系统用户来安装和运行DM。用户可以在安装之前为DM创建一个专用的系统用户。
1. 创建安装用户组dinstall。

[root@dm8dsc1 ~]# groupadd dinstall

[root@dm8dsc2 ~]# groupadd dinstall

2. 创建安装用户dmdba。

[root@dm8dsc1 ~]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

[root@dm8dsc2 ~]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

3. 初始化用户密码。

[root@dm8dsc1 ~]# passwd dmdba
Changing password for user dmdba.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.


[root@dm8dsc2 ~]# passwd dmdba
Changing password for user dmdba.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

3.3 Linux(Unix)下检查操作系统限制
在Linux(Unix)系统中,因为ulimit命令的存在,会对程序使用操作系统资源进行限制。为了使DM能够正常运行,建议用户检查当前安装用户的ulimit参数。

运行ulimit -a进行查询。如下图所示:

[root@dm8dsc1 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31152
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

[root@dm8dsc2 ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31152
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

参数使用限制:
1.data seg size
data seg size (kbytes, -d)
建议用户设置为1048576(即1GB)以上或unlimited(无限制),此参数过小将导致数据库启动失败。
2. file size
file size(blocks, -f)
建议用户设置为unlimited(无限制),此参数过小将导致数据库安装或初始化失败。
3. open files
open files(-n)
建议用户设置为65536以上或unlimited(无限制)。
4.virtual memory
virtual memory (kbytes, -v)
建议用户设置为1048576(即1GB)以上或unlimited(无限制),此参数过小将导致数据库启动失败。

如果用户需要为当前安装用户更改ulimit的资源限制,请修改文件/etc/security/limits.conf。

root@dm8dsc1 ~]# vi /etc/security/limits.conf
dmdba soft data unlimited
dmdba hard data unlimited
dmdba soft fsize unlimited
dmdba hard fsize unlimited
dmdba soft nofile 65536
dmdba hard nofile 65536

[root@dm8dsc2 ~]# vi /etc/security/limits.conf
dmdba soft data unlimited
dmdba hard data unlimited
dmdba soft fsize unlimited
dmdba hard fsize unlimited
dmdba soft nofile 65536
dmdba hard nofile 65536

[root@dm8dsc1 ~]# su - dmdba
[dmdba@dm8dsc1 ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

[root@dm8dsc2 ~]# su - dmdba
[dmdba@dm8dsc2 ~]$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31152
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 4096
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

3.4.检查系统内存与存储空间
1.检查内存
为了保证DM的正确安装和运行,要尽量保证操作系统至少1GB的可用内存(RAM)。如果可用内存过少,可能导致DM安装或启动失败。用户可以使用以下命令检查操作内存:

#获取内存总大小
[root@dm8dsc1 ~]# grep MemTotal /proc/meminfo
MemTotal:        8009068 kB

[root@dm8dsc2 ~]# grep MemTotal /proc/meminfo
MemTotal:        8009068 kB

#获取交换分区大小
[root@dm8dsc1 ~]# grep SwapTotal /proc/meminfo
SwapTotal:       8257532 kB

[root@dm8dsc2 ~]# grep SwapTotal /proc/meminfo
SwapTotal:       8257532 kB

#获取内存使用详情
[root@dm8dsc1 ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           6
Swap:             7           0           7

[root@dm8dsc2 ~]# free -g
              total        used        free      shared  buff/cache   available
Mem:              7           0           6           0           0           6
Swap:             7           0           7

2.检查存储空间
1) DM完全安装需要1GB的存储空间,用户需要提前规划好安装目录,预留足够的存储空间。用户在DM安装前也应该为数据库实例预留足够的存储空间,规划好数据路径和备份路径。用户可使用以下命令检查存储空间:

#查询目录/dm8可用空间
[root@dm8dsc1 ~]# mkdir /dm8
[root@dm8dsc1 ~]# chown -R dmdba:dinstall /dm8
[root@dm8dsc1 ~]# chmod -R 775 /dm8

[root@dm8dsc2 ~]# mkdir /dm8
[root@dm8dsc2 ~]# chown -R dmdba:dinstall /dm8
[root@dm8dsc2 ~]# chmod -R 775 /dm8

[root@dm8dsc1 ~]# df -h /dm8
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

[root@dm8dsc2 ~]# df -h /dm8
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

2) DM安装程序在安装时将产生临时文件,临时文件需要1GB的存储空间,临时文件目录默认为/tmp。用户可以使用以下命令检查存储空间。
如下图所示:

[root@dm8dsc1 ~]# df -h /tmp
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

[root@dm8dsc2 ~]# df -h /tmp
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root   48G  5.6G   43G  12% /

3.5.安装DM
创建目录/soft/dmsoft用来存储挂载iso文件后来显示软件包中的文

[root@dm8dsc1 ~]# cd /soft
[root@dm8dsc1 soft]# unzip dm8_20211021_x86_rh6_64_ent.zip
Archive:  dm8_20211021_x86_rh6_64_ent.zip
   creating: dm8_20211021_x86_rh6_64_ent/
  inflating: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso
 extracting: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso_SHA256.txt
 extracting: dm8_20211021_x86_rh6_64_ent/verinfo.txt
[root@dm8dsc1 soft]# ls -lrt
total 778320
drwxr-xr-x. 2 root root       132 Nov 12 13:43 dm8_20211021_x86_rh6_64_ent
-rw-r--r--. 1 root root 796998047 Nov 29 10:25 dm8_20211021_x86_rh6_64_ent.zip
[root@dm8dsc1 soft]# mv dm8_20211021_x86_rh6_64_ent dm8
[root@dm8dsc1 soft]# mkdir dmsoft
[root@dm8dsc1 soft]# mount -t iso9660 -o loop dm8/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso  /soft/dmsoft
mount: /dev/loop0 is write-protected, mounting read-only
[root@dm8dsc1 soft]# cd dmsoft
[root@dm8dsc1 dmsoft]# ls -lrt
total 790160
-r-xr-xr-x. 1 root root   2802503 Oct 21 14:04 DM8 Install.pdf
-r-xr-xr-x. 1 root root 806320703 Oct 21 14:11 DMInstall.bin


[root@dm8dsc2 ~]# cd /soft
[root@dm8dsc2 soft]# unzip dm8_20211021_x86_rh6_64_ent.zip
Archive:  dm8_20211021_x86_rh6_64_ent.zip
   creating: dm8_20211021_x86_rh6_64_ent/
  inflating: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso
 extracting: dm8_20211021_x86_rh6_64_ent/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso_SHA256.txt
 extracting: dm8_20211021_x86_rh6_64_ent/verinfo.txt
[root@dm8dsc2 soft]# ls -lrt
total 778320
drwxr-xr-x. 2 root root       132 Nov 12 13:43 dm8_20211021_x86_rh6_64_ent
-rw-r--r--. 1 root root 796998047 Nov 29 10:25 dm8_20211021_x86_rh6_64_ent.zip
[root@dm8dsc2 soft]# mv dm8_20211021_x86_rh6_64_ent dm8
[root@dm8dsc2 soft]# mkdir dmsoft
[root@dm8dsc2 soft]# mount -t iso9660 -o loop dm8/dm8_20211021_x86_rh6_64_ent_8.1.2.84.iso  /soft/dmsoft
mount: /dev/loop0 is write-protected, mounting read-only
[root@dm8dsc2 soft]# cd dmsoft
[root@dm8dsc2 dmsoft]# ls -lrt
total 790160
-r-xr-xr-x. 1 root root   2802503 Oct 21 14:04 DM8 Install.pdf
-r-xr-xr-x. 1 root root 806320703 Oct 21 14:11 DMInstall.bin

在/soft/dmsoft目录下存在DMInstall.bin文件, DMInstall.bin文件就是DM的安装程序。在运行安装程序前,需要赋予DMInstall.bin文件执行权限。具体命令如下所示:

[root@dm8dsc1 dmsoft]# chmod 755  DMInstall.bin
chmod: changing permissions of ‘DMInstall.bin’: Read-only file system

[root@dm8dsc2 dmsoft]# chmod 755  DMInstall.bin
chmod: changing permissions of ‘DMInstall.bin’: Read-only file system

在现实中,许多Linux(Unix)操作系统上是没有图形化界面的,为了使DM能够在这些操作系统上顺利安装,DM提供了命令行的安装方式。在终端进入到安装程序所在文件夹,执行以下命令进行命令行安装:

[dmdba@dm8dsc1 dmsoft]$ ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:e
Extract install files.........
Welcome to DM DBMS Installer

Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n

Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:21

Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:4
1 Server component
2 Client component
  2.1 Manager
  2.2 Monitor
  2.3 DTS
  2.4 Console
  2.5 Analyzer
  2.6 DISQL
3 DM Drivers
4 Manual component
5 DBMS Service
  5.1 Realtime Audit Service
  5.2 Job Service
  5.3 Instance Monitor Service
  5.4 Assistant Plug-In Service
Please Input the number of the Installation Type [1 2 3 4 5]:1 2 3 4 5
Require Space: 1242M

Please Input the install path [/home/dmdba/dmdbms]:/dm8
Available Space:39G
Please Confirm the install path(/dm8)? (Y/y:Yes N/n:No) [Y/y]:y

Pre-Installation Summary
Installation Location: /dm8
Require Space: 1242M
Available Space: 39G
Version Information:
Expire Date:
Installation Type: Custom
Confirm to Install? (Y/y:Yes N/n:No):y
2021-12-08 15:24:33
[INFO] Installing DM DBMS...
2021-12-08 15:24:34
[INFO] Installing BASE Module...
2021-12-08 15:24:36
[INFO] Installing SERVER Module...
2021-12-08 15:24:36
[INFO] Installing CLIENT Module...
2021-12-08 15:24:37
[INFO] Installing DRIVERS Module...
2021-12-08 15:24:37
[INFO] Installing MANUAL Module...
2021-12-08 15:24:37
[INFO] Installing SERVICE Module...
2021-12-08 15:24:43
[INFO] Move log file to log directory.
2021-12-08 15:24:45
[INFO] Installed DM DBMS completely.

Please execute the commands by root:
/dm8/script/root/root_installer.sh

End

以root用户来执行上面的脚本

[root@dm8dsc1 dmsoft]# /dm8/script/root/root_installer.sh
Move /dm8/bin/dm_svc.conf to /etc
Modify the files' mode of DM Server

[root@dm8dsc1 dmsoft]# su - dmdba
Last login: Wed Dec  8 15:22:23 CST 2021 on pts/2
[dmdba@dm8dsc1 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
[dmdba@dm8dsc1 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
export PATH=$PATH:$LD_LIBRARY_PATH



[dmdba@dm8dsc2 dmsoft]$ ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:e
Extract install files.........
Welcome to DM DBMS Installer

Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n

Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:21

Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:4
1 Server component
2 Client component
  2.1 Manager
  2.2 Monitor
  2.3 DTS
  2.4 Console
  2.5 Analyzer
  2.6 DISQL
3 DM Drivers
4 Manual component
5 DBMS Service
  5.1 Realtime Audit Service
  5.2 Job Service
  5.3 Instance Monitor Service
  5.4 Assistant Plug-In Service
Please Input the number of the Installation Type [1 2 3 4 5]:1 2 3 4 5
Require Space: 1242M

Please Input the install path [/home/dmdba/dmdbms]:/dm8
Available Space:39G
Please Confirm the install path(/dm8)? (Y/y:Yes N/n:No) [Y/y]:y

Pre-Installation Summary
Installation Location: /dm8
Require Space: 1242M
Available Space: 39G
Version Information:
Expire Date:
Installation Type: Custom
Confirm to Install? (Y/y:Yes N/n:No):y
2021-12-08 15:26:51
[INFO] Installing DM DBMS...
2021-12-08 15:26:51
[INFO] Installing BASE Module...
2021-12-08 15:26:54
[INFO] Installing SERVER Module...
2021-12-08 15:26:55
[INFO] Installing CLIENT Module...
2021-12-08 15:27:03
[INFO] Installing DRIVERS Module...
2021-12-08 15:27:03
[INFO] Installing MANUAL Module...
2021-12-08 15:27:03
[INFO] Installing SERVICE Module...
2021-12-08 15:27:10
[INFO] Move log file to log directory.
2021-12-08 15:27:15
[INFO] Installed DM DBMS completely.

Please execute the commands by root:
/dm8/script/root/root_installer.sh

End

以root用户来执行上面的脚本

[root@dm8dsc2 dmsoft]# /dm8/script/root/root_installer.sh
Move /dm8/bin/dm_svc.conf to /etc
Modify the files' mode of DM Server

[root@dm8dsc2 dmsoft]# su - dmdba
Last login: Wed Dec  8 15:22:48 CST 2021 on pts/2
[dmdba@dm8dsc2 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
[dmdba@dm8dsc2 ~]$ vi .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm8/bin"
export DM_HOME="/dm8"
export PATH=$PATH:$LD_LIBRARY_PATH

四、绑定UDEV
编辑/etc/udev/rules.d/99-dm-devices.rules文件

[root@dm8dsc1 dmsoft]# cd /etc/udev/rules.d/
[root@dm8dsc1 rules.d]# vi 99-dm-devices.rules
ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdd2", RUN+="/bin/raw /dev/raw/raw4 %N"

ACTION=="add", KERNEL=="sdd3", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdd4", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw7 %N"
ACTION=="add", KERNEL=="sde2", RUN+="/bin/raw /dev/raw/raw8 %N"

ACTION=="add", KERNEL=="sdf1", RUN+="/bin/raw /dev/raw/raw9 %N"
ACTION=="add", KERNEL=="sdf2", RUN+="/bin/raw /dev/raw/raw10 %N"
ACTION=="add", KERNEL=="sdg1", RUN+="/bin/raw /dev/raw/raw11 %N"
ACTION=="add", KERNEL=="sdg2", RUN+="/bin/raw /dev/raw/raw12 %N"



ACTION=="add", KERNEL=="raw[1-12]", OWNER="dmdba", GROUP="dinstall", MODE="660"


[root@dm8dsc2 dmsoft]# cd /etc/udev/rules.d/
[root@dm8dsc2 rules.d]# vi 99-dm-devices.rules
ACTION=="add", KERNEL=="sdb", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdd2", RUN+="/bin/raw /dev/raw/raw4 %N"

ACTION=="add", KERNEL=="sdd3", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdd4", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw7 %N"
ACTION=="add", KERNEL=="sde2", RUN+="/bin/raw /dev/raw/raw8 %N"

ACTION=="add", KERNEL=="sdf1", RUN+="/bin/raw /dev/raw/raw9 %N"
ACTION=="add", KERNEL=="sdf2", RUN+="/bin/raw /dev/raw/raw10 %N"
ACTION=="add", KERNEL=="sdg1", RUN+="/bin/raw /dev/raw/raw11 %N"
ACTION=="add", KERNEL=="sdg2", RUN+="/bin/raw /dev/raw/raw12 %N"



ACTION=="add", KERNEL=="raw[1-12]", OWNER="dmdba", GROUP="dinstall", MODE="660"
~

[root@dm8dsc1 rules.d]# /sbin/udevadm trigger --type=devices --action=change
[root@dm8dsc1 rules.d]# ls -lrt /dev/raw
total 0
crw-rw----. 1 root disk 162, 0 Dec  8 15:37 rawctl

[root@dm8dsc2 rules.d]# /sbin/udevadm trigger --type=devices --action=change
[root@dm8dsc2 rules.d]# ls -lrt /dev/raw
total 0
crw-rw----. 1 root disk 162, 0 Dec  8 15:37 rawctl

如果不能正常显示就重启操作系统

[root@dm8dsc1 ~]# ls -lrt /dev/raw
total 0
crw-rw---- 1 root  disk     162,  0 Dec  8 15:38 rawctl
crw-rw---- 1 root  disk     162,  5 Dec  8 15:38 raw5
crw-rw---- 1 root  disk     162,  4 Dec  8 15:38 raw4
crw-rw---- 1 root  disk     162,  3 Dec  8 15:38 raw3
crw-rw---- 1 dmdba dinstall 162,  2 Dec  8 15:38 raw2
crw-rw---- 1 dmdba dinstall 162,  1 Dec  8 15:38 raw1
crw-rw---- 1 root  disk     162,  9 Dec  8 15:38 raw9
crw-rw---- 1 root  disk     162,  8 Dec  8 15:38 raw8
crw-rw---- 1 root  disk     162,  7 Dec  8 15:38 raw7
crw-rw---- 1 root  disk     162,  6 Dec  8 15:38 raw6
crw-rw---- 1 root  disk     162, 12 Dec  8 15:38 raw12
crw-rw---- 1 root  disk     162, 11 Dec  8 15:38 raw11
crw-rw---- 1 root  disk     162, 10 Dec  8 15:38 raw10

[root@dm8dsc2 ~]# ls -lrt /dev/raw
total 0
crw-rw---- 1 root  disk     162,  0 Dec  8 15:38 rawctl
crw-rw---- 1 root  disk     162,  7 Dec  8 15:38 raw7
crw-rw---- 1 dmdba dinstall 162,  2 Dec  8 15:38 raw2
crw-rw---- 1 dmdba dinstall 162,  1 Dec  8 15:38 raw1
crw-rw---- 1 root  disk     162,  9 Dec  8 15:38 raw9
crw-rw---- 1 root  disk     162,  8 Dec  8 15:38 raw8
crw-rw---- 1 root  disk     162,  5 Dec  8 15:38 raw5
crw-rw---- 1 root  disk     162,  4 Dec  8 15:38 raw4
crw-rw---- 1 root  disk     162,  3 Dec  8 15:38 raw3
crw-rw---- 1 root  disk     162, 11 Dec  8 15:38 raw11
crw-rw---- 1 root  disk     162, 10 Dec  8 15:38 raw10
crw-rw---- 1 root  disk     162,  6 Dec  8 15:38 raw6
crw-rw---- 1 root  disk     162, 12 Dec  8 15:38 raw12

[root@dm8dsc1 ~]# vi /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
chown dmdba:dinstall /dev/raw/raw[1-12]
chmod 660 /dev/raw/raw[1-12]


[root@dm8dsc1 ~]# vi /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
chown dmdba:dinstall /dev/raw/raw[1-12]
chmod 660 /dev/raw/raw[1-12]

修改裸设备的权限防止因为重启权限不正确导致dmasmcmd不能识别

[root@dm8dsc1 ~]# ls -lrt /dev/raw/
total 0
crw-rw---- 1 root  disk     162,  0 Dec  8 16:27 rawctl
crw-rw---- 1 dmdba dinstall 162,  9 Dec  8 16:27 raw9
crw-rw---- 1 dmdba dinstall 162, 10 Dec  8 16:27 raw10
crw-rw---- 1 dmdba dinstall 162,  6 Dec  8 16:27 raw6
crw-rw---- 1 dmdba dinstall 162,  5 Dec  8 16:27 raw5
crw-rw---- 1 dmdba dinstall 162,  3 Dec  8 16:27 raw3
crw-rw---- 1 dmdba dinstall 162,  2 Dec  8 16:27 raw2
crw-rw---- 1 dmdba dinstall 162,  1 Dec  8 16:27 raw1
crw-rw---- 1 dmdba dinstall 162,  8 Dec  8 16:27 raw8
crw-rw---- 1 dmdba dinstall 162,  7 Dec  8 16:27 raw7
crw-rw---- 1 dmdba dinstall 162,  4 Dec  8 16:27 raw4
crw-rw---- 1 dmdba dinstall 162, 12 Dec  8 16:27 raw12
crw-rw---- 1 dmdba dinstall 162, 11 Dec  8 16:27 raw11


[root@dm8dsc2 ~]# ls -lrt /dev/raw/
total 0
crw-rw---- 1 root  disk     162,  0 Dec  8 16:26 rawctl
crw-rw---- 1 dmdba dinstall 162,  1 Dec  8 16:26 raw1
crw-rw---- 1 dmdba dinstall 162,  5 Dec  8 16:26 raw5
crw-rw---- 1 dmdba dinstall 162,  2 Dec  8 16:26 raw2
crw-rw---- 1 dmdba dinstall 162,  8 Dec  8 16:26 raw8
crw-rw---- 1 dmdba dinstall 162,  7 Dec  8 16:26 raw7
crw-rw---- 1 dmdba dinstall 162,  6 Dec  8 16:26 raw6
crw-rw---- 1 dmdba dinstall 162,  4 Dec  8 16:26 raw4
crw-rw---- 1 dmdba dinstall 162,  3 Dec  8 16:26 raw3
crw-rw---- 1 dmdba dinstall 162, 11 Dec  8 16:26 raw11
crw-rw---- 1 dmdba dinstall 162,  9 Dec  8 16:26 raw9
crw-rw---- 1 dmdba dinstall 162, 12 Dec  8 16:26 raw12
crw-rw---- 1 dmdba dinstall 162, 10 Dec  8 16:26 raw10


可以通过blockdev –getsize64 /dev/raw/raw1命令查看裸设备大小

[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw1
2147483648
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw2
2147483648
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw3
2147483648
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw4
2147483648
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw5
2147483648
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw6
2147483648
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw7
5368709120
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw8
5367660544
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw9
5368709120
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw10
5367660544
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw11
5368709120
[root@dm8dsc1 ~]# blockdev --getsize64 /dev/raw/raw12
5367660544


[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw1
2147483648
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw2
2147483648
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw3
2147483648
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw4
2147483648
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw5
2147483648
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw6
2147483648
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw7
5368709120
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw8
5367660544
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw9
5368709120
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw10
5367660544
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw11
5368709120
[root@dm8dsc2 ~]# blockdev --getsize64 /dev/raw/raw12
5367660544

五.配置dmdcr_cfg.ini文件
在2个节点的/dm8/data目录下创建配置文件dmdcr_cfg.ini,在文件中添加如下内容:

[root@dm8dsc1 ~]# su - dmdba
Last login: Wed Dec  8 15:27:56 CST 2021 on pts/1
[dmdba@dm8dsc1 ~]$ mkdir /dm8/data

[root@dm8dsc2 ~]# su - dmdba
Last login: Wed Dec  8 15:27:32 CST 2021 on pts/1
[dmdba@dm8dsc2 ~]$ mkdir /dm8/data

[dmdba@dm8dsc1 ~]$ cd /dm8/data
[dmdba@dm8dsc1 data]$ vi dmdcr_cfg.ini
DCR_N_GRP = 2
DCR_VTD_PATH = /dev/raw/raw2
DCR_OGUID = 63635

[GRP]
DCR_GRP_TYPE = CSS
DCR_GRP_NAME = GRP_CSS
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_CSS]
DCR_EP_NAME = CSS0
DCR_EP_HOST = 11.11.11.3
DCR_EP_PORT = 9541
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 11.11.11.4
DCR_EP_PORT = 9541



[GRP]
DCR_GRP_TYPE = DB
DCR_GRP_NAME = GRP_DSC
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_DSC]
DCR_EP_NAME = DSC0
DCR_EP_SEQNO = 0
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741
[GRP_DSC]
DCR_EP_NAME = DSC1
DCR_EP_SEQNO = 1
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741

[dmdba@dm8dsc2 ~]$ cd /dm8/data
[dmdba@dm8dsc2 data]$ vi dmdcr_cfg.ini
DCR_N_GRP = 2
DCR_VTD_PATH = /dev/raw/raw2
DCR_OGUID = 63635

[GRP]
DCR_GRP_TYPE = CSS
DCR_GRP_NAME = GRP_CSS
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_CSS]
DCR_EP_NAME = CSS0
DCR_EP_HOST = 11.11.11.3
DCR_EP_PORT = 9541
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 11.11.11.4
DCR_EP_PORT = 9541



[GRP]
DCR_GRP_TYPE = DB
DCR_GRP_NAME = GRP_DSC
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_DSC]
DCR_EP_NAME = DSC0
DCR_EP_SEQNO = 0
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741
[GRP_DSC]
DCR_EP_NAME = DSC1
DCR_EP_SEQNO = 1
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741

六、使用 DMASMCMD 工具初始化(任意一节点执行)

[dmdba@dm8dsc1 ~]$ dmasmcmd
DMASMCMD V8
ASM>create dcrdisk '/dev/raw/raw1' 'dcr'
[Trace]The ASM initialize dcrdisk /dev/raw/raw1 to name DMASMdcr
Used time: 269.118(ms).
ASM>create votedisk '/dev/raw/raw2' 'vote'
[Trace]The ASM initialize votedisk /dev/raw/raw2 to name DMASMvote
Used time: 108.701(ms).

ASM>init dcrdisk '/dev/raw/raw1' from '/dm8/data/dmdcr_cfg.ini' identified by 'dameng123'
[Trace]DG 126 alloc one extent for inodes, addr(disk_id, disk_auno, extent_no):(0,0,1).
[Trace]DG 126 allocate 4 extents for file 0xfe000002.
[Trace]DG 126 alloc 4 extents for 0xfe000002, addr(disk_id, disk_auno, extent_no):(0, 0, 2)->(0, 0, 5), need_init = 1.
Used time: 00:00:02.244.
ASM>init votedisk '/dev/raw/raw2' from '/dm8/data/dmdcr_cfg.ini'
[Trace]DG 125 alloc one extent for inodes, addr(disk_id, disk_auno, extent_no):(0,0,1).
[Trace]DG 125 allocate 4 extents for file 0xfd000002.
[Trace]DG 125 alloc 4 extents for 0xfd000002, addr(disk_id, disk_auno, extent_no):(0, 0, 2)->(0, 0, 5), need_init = 1.
Used time: 431.131(ms).

七.准备dmdcr.ini 配置文件
dmdcr.ini 是 dmcss、dmasmsvr、dmasmtool 工具的输入参数。记录了当前节点序列号以及 DCR 磁盘路径。在2个节点的/dm8/data目录下创建dmdcr.ini 配置文件,dmdcr_path 相同,dmasvrmal.ini 文件内容也相同,dmdcr_seqo 分别为 0 和 1。
节点 1:

[dmdba@dm8dsc1 data]$ vi dmdcr.ini
DMDCR_PATH = /dev/raw/raw1
DMDCR_SEQNO = 0



#DB
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD = /dm8/bin/dmserver path=/dm8/data/dsc0_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini

节点2:

[dmdba@dm8dsc2 data]$ vi dmdcr.ini
DMDCR_PATH = /dev/raw/raw1
DMDCR_SEQNO = 1



#DB
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD = /dm8/bin/dmserver path=/dm8/data/dsc1_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini

八.启动DMCSS服务程序
1、注册 DMCSS
节点一:

[root@dm8dsc1 ~]# /dm8/script/root/dm_service_installer.sh -t dmcss -dcr_ini /dm8/data/dmdcr.ini -p dsc1
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServicedsc1.service to /usr/lib/systemd/system/DmCSSServicedsc1.service.
Finished to create the service (DmCSSServicedsc1)

节点二:

[root@dm8dsc2 ~]# /dm8/script/root/dm_service_installer.sh -t dmcss -dcr_ini /dm8/data/dmdcr.ini -p dsc2
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServicedsc2.service to /usr/lib/systemd/system/DmCSSServicedsc2.service.
Finished to create the service (DmCSSServicedsc2)

2、启动DMCSS 服务
节点一:

[root@dm8dsc1 ~]# service DmCSSServicedsc1 start
Redirecting to /bin/systemctl start DmCSSServicedsc1.service
[root@dm8dsc1 ~]# service DmCSSServicedsc1 status
Redirecting to /bin/systemctl status DmCSSServicedsc1.service
 DmCSSServicedsc1.service - DM Cluster Synchronization Services Service(DmCSSServicedsc1).
   Loaded: loaded (/usr/lib/systemd/system/DmCSSServicedsc1.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-12-08 17:19:47 CST; 38s ago
  Process: 3776 ExecStart=/dm8/bin/DmCSSServicedsc1 start (code=exited, status=0/SUCCESS)
 Main PID: 3800 (dmcss)
    Tasks: 9
   CGroup: /system.slice/DmCSSServicedsc1.service
           └─3800 /dm8/bin/dmcss dcr_ini=/dm8/data/dmdcr.ini

Dec 08 17:19:32 dm8dsc1 systemd[1]: Starting DM Cluster Synchronization Services Service(DmCSSServicedsc1)....
Dec 08 17:19:47 dm8dsc1 DmCSSServicedsc1[3776]: [38B blob data]
Dec 08 17:19:47 dm8dsc1 systemd[1]: Started DM Cluster Synchronization Services Service(DmCSSServicedsc1)..

节点二:

[root@dm8dsc2 ~]# service DmCSSServicedsc2 start
Redirecting to /bin/systemctl start DmCSSServicedsc2.service
[root@dm8dsc2 ~]# service DmCSSServicedsc2 status
Redirecting to /bin/systemctl status DmCSSServicedsc2.service
 DmCSSServicedsc2.service - DM Cluster Synchronization Services Service(DmCSSServicedsc2).
   Loaded: loaded (/usr/lib/systemd/system/DmCSSServicedsc2.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-12-08 17:20:19 CST; 13s ago
  Process: 3546 ExecStart=/dm8/bin/DmCSSServicedsc2 start (code=exited, status=0/SUCCESS)
 Main PID: 3569 (dmcss)
    Tasks: 9
   CGroup: /system.slice/DmCSSServicedsc2.service
           └─3569 /dm8/bin/dmcss dcr_ini=/dm8/data/dmdcr.ini

Dec 08 17:20:04 dm8dsc2 systemd[1]: Starting DM Cluster Synchronization Services Service(DmCSSServicedsc2)....
Dec 08 17:20:19 dm8dsc2 DmCSSServicedsc2[3546]: [38B blob data]
Dec 08 17:20:19 dm8dsc2 systemd[1]: Started DM Cluster Synchronization Services Service(DmCSSServicedsc2)..

九.操作系统配置准备配置dminit.ini文件,存放在/dm8/data目录中(数据文件存储在/dev/raw/raw3-6裸设备上,日志文件存储在/dev/raw/raw7-10

[dmdba@dm8dsc1 data]$ vi dminit.ini
system_path = /dm8/data
db_name=dsc
main = /dev/raw/raw3
main_size = 128
roll = /dev/raw/raw4
roll_size = 128
system = /dev/raw/raw5
system_size = 128
ctl_path = /dev/raw/raw6
ctl_size = 8
dcr_path=/dev/raw/raw1
dcr_seqno=0

[dsc0]
config_path=/dm8/data/dsc0_config
port_num = 5236
mal_host = 11.11.11.3
mal_port = 9340
log_size = 256
log_path = /dev/raw/raw7
log_path = /dev/raw/raw8
[dsc1]
config_path=/dm8/data/dsc1_config
port_num = 5236
mal_host = 11.11.11.4
mal_port = 9341
log_size = 256
log_path = /dev/raw/raw9
log_path = /dev/raw/raw10

十、操作系统配置使用dminit初始化DB环境
在任意节点启动 dminit 工具初始化数据库。dminit 执行完成后,会在 config_path 目录(/dm8/data/dsc0_config 和/dm8/data/dsc1_config)下生成配置文件 dm.ini 和 dmmal.ini。

[dmdba@dm8dsc1 data]$ dminit control=/dm8/data/dminit.ini
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: /dev/raw/raw7


 log file path: /dev/raw/raw8


 log file path: /dev/raw/raw9


 log file path: /dev/raw/raw10

FILE "/dev/raw/raw5" has already existed
FILE "/dev/raw/raw4" has already existed
FILE "/dev/raw/raw3" has already existed
FILE "/dev/raw/raw6" has already existed
FILE "/dev/raw/raw7" has already existed
FILE "/dev/raw/raw8" has already existed
FILE "/dev/raw/raw9" has already existed
FILE "/dev/raw/raw10" has already existed
File "/dev/raw/raw5" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw4" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw3" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw6" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw7" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw8" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw9" has already existed,
whether overwrite(y/n, 1/0): y
File "/dev/raw/raw10" has already existed,
whether overwrite(y/n, 1/0): y
write to dir [/dm8/data/dsc].
create dm database success. 2021-12-08 17:30:36
[dmdba@dm8dsc1 data]$ ls -lrt
total 12
-rw-r--r-- 1 dmdba dinstall 563 Dec  8 16:49 dmdcr_cfg.ini
-rw-r--r-- 1 dmdba dinstall 182 Dec  8 17:05 dmdcr.ini
-rw-r--r-- 1 dmdba dinstall 546 Dec  8 17:28 dminit.ini
drwxr-xr-x 2 dmdba dinstall  87 Dec  8 17:30 dsc0_config
drwxr-xr-x 2 dmdba dinstall  55 Dec  8 17:30 dsc1_config
drwxr-xr-x 5 dmdba dinstall  70 Dec  8 17:30 dsc

将节点一的配置文件复制到节点二:

[dmdba@dm8dsc1 data]$ scp -r dsc1_config 10.10.13.206:`pwd`
The authenticity of host '10.10.13.206 (10.10.13.206)' can't be established.
ECDSA key fingerprint is SHA256:6O8c9WEeEYPbL4ncdRR1RsrjxxmfzPq9Tkq4/6uLSP4.
ECDSA key fingerprint is MD5:e1:73:3e:8d:79:be:5c:82:0f:c7:58:79:45:ad:df:86.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.10.13.206' (ECDSA) to the list of known hosts.
dmdba@10.10.13.206's password:
dmmal.ini                                                                                                                                                                                                100%  200    17.0KB/s   00:00
dm.ini                                                                                                                                                                                                   100%   52KB   2.2MB/s   00:00
sqllog.ini                                                                                                                                                                                               100%  481    53.4KB/s   00:00

一定要将节点一/dm8/data/目录中生成的dsc目录复制到节点二的/dm8/data目录中,否则在节点二中启动数据库时会出现以下错误,原因就是因为使用裸设备时生成的dsc目录及其文件不是存储在共享存储中可以让集群节点都能访问。

Starting DmServicerac2: [ FAILED ]
file dm.key not found, use default license!
Read ini warning, default dm.ctl backup path [/dm8/data/dsc/ctl_bak] does not exist.
Read ini error, name:SYSTEM_PATH, value:/dm8/data/dsc
dmserver startup failed, code = -803 [Invalid ini config value]

将节点一/dm8/data/目录中生成的dsc目录复制到节点二的/dm8/data目录

[dmdba@dm8dsc1 data]$ scp -r dsc  10.10.13.206:`pwd`
dmdba@10.10.13.206's password:
dm_20211208173029_111982.ctl                                                                                                                                                                             100% 6144   493.8KB/s   00:00
dm_service.prikey                                                                                                                                                                                        100%  633    57.0KB/s   00:00

十一. 启动数据库服务器
1、在2个节点分别注册DM 数据库服务:
节点一:

[root@dm8dsc1 init.d]# /dm8/script/root/dm_service_installer.sh -t dmserver -dm_ini /dm8/data/dsc0_config/dm.ini -dcr_ini /dm8/data/dmdcr.ini -p dsc1
dmserver(RAC) need to be set the dependent service(dmasmsvr)!

提示需要依赖服务dmasmsvr,但使用裸设备没有配置dmasm实例,所以只能手动启动服务
手工启动命令如下,手工启动后窗口不能关闭

[dmdba@dm8dsc1 ~]$ dmserver /dm8/data/dsc0_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini &

[dmdba@dm8dsc2 ~]$ dmserver /dm8/data/dsc1_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini &

如果DMCSS配置有自动拉起dmserver的功能,可以等待DMCSS自动拉起实例,不需要手动启动。在dmdcr.ini文件中配置如下选项

#DB
DMDCR_DB_RESTART_INTERVAL = 10
DMDCR_DB_STARTUP_CMD = /dm8/bin/dmserver path=/dm8/data/dsc0_config/dm.ini dcr_ini=/dm8/data/dmdcr.ini

十二.连接数据库验证
1.配置服务名文件

[dmdba@dm8dsc1 ~]$ vi /etc/dm_svc.conf
TIME_ZONE=(480)
LANGUAGE=(en)
rac=(10.10.13.205:5236,10.10.13.206:5236)
SWITCH_TIME=(10000)
SWITCH_INTERVAL=(10)

[dmdba@dm8dsc2 ~]$ vi /etc/dm_svc.conf
TIME_ZONE=(480)
LANGUAGE=(en)
rac=(10.10.13.205:5236,10.10.13.206:5236)
SWITCH_TIME=(10000)
SWITCH_INTERVAL=(10)

2.连接RAC集群
节点一:

[dmdba@dm8dsc1 ~]$ disql SYSDBA/SYSDBA@rac

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

LINEID     NAME INSTANCE_NAME INSTANCE_NUMBER HOST_NAME SVR_VERSION                DB_VERSION          START_TIME          STATUS$ MODE$  OGUID       DSC_SEQNO   DSC_ROLE
---------- ---- ------------- --------------- --------- -------------------------- ------------------- ------------------- ------- ------ ----------- ----------- ------------
1          DSC0 DSC0          1               dm8dsc1   DM Database Server x64 V8  DB Version: 0x7000c 2021-12-09 12:56:06 OPEN    NORMAL 0           0           Control node

used time: 6.832(ms). Execute id is 400.
SQL> select * from v$dsc_ep_info;

LINEID     EP_NAME EP_SEQNO    EP_GUID              EP_TIMESTAMP         EP_MODE      EP_STATUS
---------- ------- ----------- -------------------- -------------------- ------------ ---------
1          DSC0    0           2477818562           2477826305           Control Node OK
2          DSC1    1           2477823752           2477831486           Normal Node  OK

used time: 1.221(ms). Execute id is 401.
SQL>

节点二:

[dmdba@dm8dsc2 ~]$ disql SYSDBA/SYSDBA@rac

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

LINEID     NAME INSTANCE_NAME INSTANCE_NUMBER HOST_NAME SVR_VERSION                DB_VERSION          START_TIME          STATUS$ MODE$  OGUID       DSC_SEQNO   DSC_ROLE
---------- ---- ------------- --------------- --------- -------------------------- ------------------- ------------------- ------- ------ ----------- ----------- ------------
1          DSC0 DSC0          1               dm8dsc1   DM Database Server x64 V8  DB Version: 0x7000c 2021-12-09 12:56:06 OPEN    NORMAL 0           0           Control node

used time: 5.261(ms). Execute id is 500.
SQL> select * from v$dsc_ep_info;

LINEID     EP_NAME EP_SEQNO    EP_GUID              EP_TIMESTAMP         EP_MODE      EP_STATUS
---------- ------- ----------- -------------------- -------------------- ------------ ---------
1          DSC0    0           2477818562           2477826342           Control Node OK
2          DSC1    1           2477823752           2477831523           Normal Node  OK

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

MySQL InnoDB File-Per-Table表空间

InnoDB File-Per-Table表空间
过去,所有InnoDB表和索引都存储在系统表空间中。这种整体的方法针对的是完全专用于数据库处理的机器,通过精心规划的数据增长,分配给MySQL的任何磁盘存储永远不会被用于其他用途。InnoDB的file-per-table表空间特性提供了一个更灵活的替代方案,每个InnoDB表及其索引都存储在一个单独的.ibd数据文件中。每个这样的.ibd数据文件代表一个单独的表空间。这个特性是由innodb_file_per_table配置选项控制的,在MySQL 5.6.6及更高版本中默认启用。

file-per-table表空间的优点
.当truncate或drop存储在file-per-table表空间中的表时,可以回收磁盘空间。truncate或drop存储在共享系统表空间中的表会在系统表空间数据文件(ibdata文件)内部创建空闲空间,这些空间只能用于新的InnoDB数据。

.在存储在file-per-table表空间文件中的表上运行TRUNCATE TABLE操作会更快。

.您可以将特定的表存储在单独的存储设备上,以实现I/O优化、空间管理或备份目的。在以前的版本中,您必须将整个数据库目录移动到其他驱动器,并在MySQL数据目录中创建符号链接。在MySQL 5.6.6及更高版本中,你可以使用
create table… data directory=absolute_path_to_directory。

.你可以运行OPTIMIZE TABLE来压缩或重新创建一个file-per-table表空间。当你运行一个OPTIMIZE TABLE时,InnoDB会创建一个新的.ibd文件,该文件带有一个临时名称,只使用存储实际数据所需的空间。当优化完成后,InnoDB会删除旧的.ibd文件,并用新文件替换它。如果以前的.ibd文件显著增长,但实际数据只占其大小的一部分,那么运行OPTIMIZE TABLE可以回收未使用的空间。

.你可以移动单个InnoDB表,而不是整个数据库

.你可以将InnoDB表从一个MySQL实例复制到另一个实例(称为可迁移表空间特性)。

.在file-per-table表空间中创建的表使用Barracuda文件格式。Barracuda文件格式支持压缩和动态行格式等特性

.可以使用动态行格式为具有大型BLOB或TEXT列的表启用更高效的存储。

.file-per-table表空间可以在发生损坏、服务器无法重启或备份和二进制日志不可用时提高成功恢复的机会并节省时间。

.在复制或备份表时,file-per-table表空间可以方便地报告每个表的状态。

.可以在文件系统级别监控表大小,而不需要访问MySQL。

.当innodb_flush_method设置为O_DIRECT时,普通的Linux文件系统不允许并发写入单个文件。因此,使用file-per-table表空间和innodb_flush_method可能会提高性能。

.系统表空间存储数据字典和undo日志,受InnoDB表空间大小限制。使用file-per_table表空间,每个表都有自己的表空间,这为增长提供了空间。

file-per-table表空间的潜在缺点
.使用file-per-table表空间,每个表可能有未使用的空间,这些空间只能由同一表的行使用。如果管理不当,可能会造成空间的浪费。

.fsync操作必须在每个打开的表上运行,而不是单个文件上。因为每个文件都有一个单独的fsync操作,所以对多个表的写操作不能合并成一个单独的I/O操作。这可能需要InnoDB执行更多的fsync操作。

.mysqld必须为每个表保留一个打开的文件句柄,如果在file-per-table表空间中有很多表,这可能会影响性能。

.使用了更多的文件描述符

.innodb_file_per_table在MySQL 5.6.6及更高版本中是默认启用的。如果向后兼容MySQL 5.5或5.1是一个问题,你可以考虑禁用它。禁用innodb_file_per_table功能可以防止在ALTER TABLE重新创建InnoDB表(ALGORITHM=COPY)时,阻止alter table将InnoDB表从系统表空间移动到单独的.ibd文件中。

例如,当重构InnoDB表的聚集索引时,表会使用innodb_file_per_table的当前设置重新创建。此行为在添加或删除InnoDB二级索引时不适用。当不重建表而创建二级索引时,无论当前的innodb_file_per_table设置是什么,索引都被存储在与表数据相同的文件中。此行为也不适用于使用CREATE TABLE…TABLESPACE或ALTER TABLE …TABLESPACE语法添加到系统表空间中的表。这些表不受innodb_file_per_table设置的影响。

.如果许多表都在增长,可能会出现更多的碎片,这可能会影响DROP TABLE和表扫描性能。但是,在管理碎片时,将文件放在它们自己的表空间中可以提高性能。

.在删除file-per-table表空间时会扫描缓冲池,对于大小为几十gb的缓冲池来说,这可能需要几秒钟的时间。扫描是用一个宽的内部锁执行的,这可能会延迟其他操作。系统表空间中的表不受影响。

.innodb_autoextend_increment变量定义了自动扩展的共享表空间文件满时的扩展大小(以MB为单位),但不适用于file-per-table表空间文件,不管是否设置了innodb_autoextend_increment,这些文件都是自动扩展的。最初的扩展是少量的,之后扩展以4MB的增量出现。

启用与禁用file-per-table表空间
innodb_file_per_table选项默认是启用的。

为了在启动时设置innodb_file_per_table选项,可以在启动服务时使用–innodb_file_per_table命令行选项或者在my.cnf文件中[mysqld]部分增加以下一行内容:

[mysqld]
innodb_file_per_table=1

你也可以在服务器运行时动态设置innodb_file_per_table:

mysql> SET GLOBAL innodb_file_per_table=1;
Query OK, 0 rows affected (0.00 sec)

启用innodb_file_per_table时,可以将InnoDB表存储在tbl_name.ibd文件。不像MyISAM存储引擎,它有单独的tbl_name.MYD和tbl_name.MYI文件用于索引和数据,InnoDB将数据和索引一起存储在一个.ibd文件中。仍然像往常一样创建tbl_name.frm文件。

如果在启动选项中禁用innodb_file_per_table并重启服务器或者使用set global命令来禁用它,除非你显式的使用create table … tablespace选项将表存放在file-per-table表空间或通用表空间否则innodb将在系统表空间创建新表。

你总是可以读取和写入任何InnoDB表,不管file-per-table设置情况。

如果要将表从系统表空间移动到自己的表空间,需要修改innodb_file_per_table的设置,然后重新创建表:

mysql> SET GLOBAL innodb_file_per_table=1;
mysql> ALTER TABLE table_name ENGINE=InnoDB;

使用CREATE TABLE…TABLESPACE或ALTER TABLE…TABLESPACE语法添加表到系统表空间不受innodb_file_per_table设置的影响。要将这些表从系统表空间移动到file-per-table表空间,必须使用ALTER TABLE…TABLESPACE语法。

InnoDB总是需要系统表空间,因为它把它的内部数据字典和undo日志放在那里。.ibd文件不够InnoDB操作。

当一个表从系统表空间移到它自己的.ibd文件时,组成系统表空间的数据文件保持相同的大小。InnoDB表以前占用的空间可以被新的InnoDB数据重用,但是不会被操作系统回收使用。当将较大的InnoDB表移出系统表空间(磁盘空间有限)时,你可能更喜欢启用innodb_file_per_table并使用mysqldump命令重新创建整个实例。如上所述,使用CREATE TABLE…TABLESPACE或者ALTER TABLE…表空间语法不受innodb_file_per_table设置的影响。这些桌子必须单独移动。

在数据目录外创建逐file-per-table表空间
要在MySQL数据目录之外的特定位置创建一个新的InnoDB file-per-table表空间,使用有data directory = absolute_path_to_directory子句的CREATE TABLE语句的来实现。

提前计划位置,因为您不能在ALTER TABLE语句中使用DATA DIRECTORY子句。您指定的目录可以位于具有特定性能或容量特征的另一个存储设备上,例如快速SSD或大容量HDD。

在目标目录中,MySQL创建一个与数据库名称对应的子目录,在该子目录中为新表创建一个.ibd文件。在MySQL DATADIR目录下的数据库目录中,MySQL创建了一个table_name.Isl文件包含表路径名。.isl文件被MySQL视为一个符号链接。(InnoDB表不支持使用实际的符号链接。)

下面的例子演示了如何在MySQL数据目录外创建一个file-per-table表空间。它显示了在指定目录中创建的.ibd,以及在MySQL数据目录下的数据库目录中创建的.isl。

mysql> use mysql
Database changed
mysql> show variables like 'innodb_file_per_table';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_file_per_table | ON    |
+-----------------------+-------+
1 row in set (0.01 sec)


mysql> create table t_cs(c1 int primary key) data directory='/data';
Query OK, 0 rows affected (0.22 sec)


[root@localhost mysql]# pwd
/data/mysql
[root@localhost mysql]# ls -lrt
总用量 96
-rw-r-----. 1 mysql mysql 98304 3月   8 16:09 t_cs.ibd

[root@localhost mysql]# ls -lrt t_cs*
-rw-r-----. 1 mysql mysql 8556 3月   8 16:09 t_cs.frm
-rw-r-----. 1 mysql mysql   20 3月   8 16:09 t_cs.isl

你也可以使用CREATE TABLE…TABLESPACE与DATA DIRECTORY子句结合,在MySQL数据目录之外创建一个file-per-table表空间。为此,你必须指定innodb_file_per_table作为表空间名。

mysql> create table t_cs_3(c1 int primary key) tablespace=innodb_file_per_table data directory='/data';
Query OK, 0 rows affected (0.28 sec)

[root@localhost mysql]# ls -lrt t_cs_2*
-rw-r-----. 1 mysql mysql 98304 3月   8 16:14 t_cs_2.ibd

[root@localhost mysql]# ls -lrt t_cs_2*
-rw-r-----. 1 mysql mysql 8556 3月   8 16:14 t_cs_2.frm
-rw-r-----. 1 mysql mysql   22 3月   8 16:14 t_cs_2.isl

使用这个方法时,你不需要启用innodb_file_per_table。

使用说明:
.MySQL最初保存的.ibd文件是打开的,防止您卸载设备,但如果服务器繁忙,可能最终会关闭表。小心不要在MySQL运行时意外地卸载外部设备,或者在设备断开连接时启动MySQL。当关联的.ibd文件丢失时,试图访问表会导致严重错误,需要重新启动服务器。

如果.ibd文件仍然不在预期的路径上,服务器重启可能会失败。在本例中,手动删除数据库目录中的table_name.isl文件重新启动后,执行DROPTABLE命令删除.frm文件,并从数据字典中删除该表的信息。

.在将表存放在NFS挂载的卷上之前,请查看在使用NFS和MySQL中列出的潜在问题。

.如果您使用LVM快照、文件复制或其他基于文件的机制来备份.ibd文件,请始终使用FLUSH TABLES…FOR EXPORT语句,以确保在备份发生之前将缓存在内存中的所有更改刷新到磁盘。

.DATA DIRECTORY子句是一种支持替代符号链接的方法,符号链接一直存在问题,从来没有被支持用于单独的InnoDB表。

MySQL 修改InnoDB重做日志文件的数量或大小

修改InnoDB重做日志文件的数量或大小
修改你的InnoDB重做日志文件的数量或大小,请执行以下步骤:
1.停止MySQL服务器,并确保它没有错误地关闭

mysql> show variables like 'innodb_log_file%';
+---------------------------+----------+
| Variable_name             | Value    |
+---------------------------+----------+
| innodb_log_file_size      | 50331648 |
| innodb_log_files_in_group | 2        |
+---------------------------+----------+
2 rows in set (0.00 sec)


[root@localhost ~]# service mysqld stop
Shutting down MySQL.... SUCCESS!

2.编辑my.cnf以更改日志文件配置。如果需要修改日志文件大小,请配置innodb_log_file_size。要增加日志文件的数量,可以配置

innodb_log_files_in_group。

[mysql@localhost mysql]$ vi my.cnf
....
innodb_log_file_size=100m
innodb_log_files_in_group=3

3.重新启动MySQL服务器
如果InnoDB检测到innodb_log_file_size大小与重做日志文件大小不同,它会写一个日志检查点,关闭并删除旧的日志文件,创建新的大小的志文件,并打开新的日志文件。

[root@localhost ~]# service mysqld start
Starting MySQL.................................. SUCCESS!


日志文件显示如下:

[mysql@localhost mysql]$ tail -f mysql.err
2022-03-02T02:44:15.775252Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2022-03-02T02:44:15.775476Z 0 [Note] /mysqlsoft/mysql/bin/mysqld (mysqld 5.7.26-log) starting as process 613 ...
2022-03-02T02:44:15.787224Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-03-02T02:44:15.787311Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-03-02T02:44:15.787376Z 0 [Note] InnoDB: Uses event mutexes
2022-03-02T02:44:15.787395Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-03-02T02:44:15.787411Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-03-02T02:44:15.788175Z 0 [Note] InnoDB: Number of pools: 1
2022-03-02T02:44:15.788515Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-03-02T02:44:15.793577Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-03-02T02:44:15.812360Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-03-02T02:44:15.817437Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-03-02T02:44:15.862640Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-03-02T02:44:16.043532Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*6400 pages, LSN=2494312
2022-03-02T02:44:16.169341Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2022-03-02T02:44:16.200462Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100 MB
2022-03-02T02:44:16.200745Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:26.280622Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 100 MB
2022-03-02T02:44:26.281005Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:37.028157Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 100 MB
2022-03-02T02:44:37.029053Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:47.532468Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-03-02T02:44:47.532675Z 0 [Warning] InnoDB: New log files created, LSN=2494312
2022-03-02T02:44:47.533502Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-03-02T02:44:47.533760Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-03-02T02:44:48.119249Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-03-02T02:44:48.121693Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-03-02T02:44:48.121740Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-03-02T02:44:48.122598Z 0 [Note] InnoDB: Waiting for purge to start
2022-03-02T02:44:48.172771Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 32356ms. The settings might not be optimal. (flushed=0 and evicted=0, during the time.)
2022-03-02T02:44:48.186082Z 0 [Note] InnoDB: 5.7.26 started; log sequence number 2494303
2022-03-02T02:44:48.186431Z 0 [Note] InnoDB: Loading buffer pool(s) from /mysqldata/mysql/ib_buffer_pool
2022-03-02T02:44:48.186776Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-03-02T02:44:48.366419Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2022-03-02T02:44:48.367248Z 0 [Warning] CA certificate ca.pem is self signed.
2022-03-02T02:44:48.369110Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2022-03-02T02:44:48.371083Z 0 [Note] IPv6 is available.
2022-03-02T02:44:48.371145Z 0 [Note]   - '::' resolves to '::';
2022-03-02T02:44:48.371213Z 0 [Note] Server socket created on IP: '::'.
2022-03-02T02:44:48.430720Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220302 10:44:48
2022-03-02T02:44:48.434777Z 0 [Note] Failed to start slave threads for channel ''
2022-03-02T02:44:48.452218Z 0 [Note] Event Scheduler: Loaded 0 events
2022-03-02T02:44:48.452566Z 0 [Note] /mysqlsoft/mysql/bin/mysqld: ready for connections.
Version: '5.7.26-log'  socket: '/mysqlsoft/mysql/mysql.sock'  port: 3306  Source distribution

其中以下部分显示了服务器重置日志文件的大小与数量

2022-03-02T02:44:16.043532Z 0 [Warning] InnoDB: Resizing redo log from 2*3072 to 3*6400 pages, LSN=2494312
2022-03-02T02:44:16.169341Z 0 [Warning] InnoDB: Starting to delete and rewrite log files.
2022-03-02T02:44:16.200462Z 0 [Note] InnoDB: Setting log file ./ib_logfile101 size to 100 MB
2022-03-02T02:44:16.200745Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:26.280622Z 0 [Note] InnoDB: Setting log file ./ib_logfile1 size to 100 MB
2022-03-02T02:44:26.281005Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:37.028157Z 0 [Note] InnoDB: Setting log file ./ib_logfile2 size to 100 MB
2022-03-02T02:44:37.029053Z 0 [Note] InnoDB: Progress in MB:
 100
2022-03-02T02:44:47.532468Z 0 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2022-03-02T02:44:47.532675Z 0 [Warning] InnoDB: New log files created, LSN=2494312


[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_log_file%';
+---------------------------+-----------+
| Variable_name             | Value     |
+---------------------------+-----------+
| innodb_log_file_size      | 104857600 |
| innodb_log_files_in_group | 3         |
+---------------------------+-----------+
2 rows in set (0.01 sec)

MySQL 减少InnoDB系统表空间的大小

减少InnoDB系统表空间的大小
不能从系统表空间中删除数据文件。若要减少系统表空间大小,请使用此过程:
1.使用mysqldump将所有的包括MySQL数据库中的InnoDB表dump出来,在5.6当前版本中,包括5张InnoDB表:

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------------------+
| Variable_name         | Value                              |
+-----------------------+------------------------------------+
| innodb_data_file_path | ibdata1:76M;ibdata2:50M:autoextend |
| innodb_data_home_dir  |                                    |
+-----------------------+------------------------------------+
2 rows in set (0.01 sec)

mysql> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql' and ENGINE='InnoDB';
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| engine_cost               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
+---------------------------+
19 rows in set (0.00 sec)



[mysql@localhost ~]$ mysqldump  -uroot -pxxzx7817600 --all-databases > all_db_dump_20220223.sql
mysqldump: [Warning] Using a password on the command line interface can be insecure.

2.停止MySQL服务器

[mysql@localhost ~]$ mysqladmin -uroot -pxxzx7817600 shutdown
mysqladmin: [Warning] Using a password on the command line interface can be insecure.

3.删除所有已经存在的表空间文件(*.ibd),包括ibdata和ib_log文件。不要忘记删除MySQL数据库中的*.ibd文件。

[mysql@localhost mysql]$ find ./mysql -name "*.ibd"
./mysql/plugin.ibd
./mysql/servers.ibd
./mysql/help_topic.ibd
./mysql/help_category.ibd
./mysql/help_relation.ibd
./mysql/help_keyword.ibd
./mysql/time_zone_name.ibd
./mysql/time_zone.ibd
./mysql/time_zone_transition.ibd
./mysql/time_zone_transition_type.ibd
./mysql/time_zone_leap_second.ibd
./mysql/innodb_table_stats.ibd
./mysql/innodb_index_stats.ibd
./mysql/slave_relay_log_info.ibd
./mysql/slave_master_info.ibd
./mysql/slave_worker_info.ibd
./mysql/gtid_executed.ibd
./mysql/server_cost.ibd
./mysql/engine_cost.ibd
[mysql@localhost mysql]$ find ./mysql -name "*.ibd"    | xargs -n 1 rm -f

[mysql@localhost mysql]$ rm -rf ibdata*
[mysql@localhost mysql]$ rm -rf ib_log*
[mysql@localhost mysql]$ ls -lrt ibdata*
ls: 无法访问ibdata*: 没有那个文件或目录
[mysql@localhost mysql]$ ls -lrt ib_log*
ls: 无法访问ib_log*: 没有那个文件或目录

4.删除InnoDB表的.frm文件

[mysql@localhost mysql]$ rm -rf mysql/plugin..frm
[mysql@localhost mysql]$ rm -rf mysql/servers..frm
[mysql@localhost mysql]$ rm -rf mysql/help_topic..frm
[mysql@localhost mysql]$ rm -rf mysql/help_category..frm
[mysql@localhost mysql]$ rm -rf mysql/help_relation.frm
[mysql@localhost mysql]$ rm -rf mysql/help_keyword.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_name.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_transition.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_transition_type.frm
[mysql@localhost mysql]$ rm -rf mysql/time_zone_leap_second.frm
[mysql@localhost mysql]$ rm -rf mysql/innodb_table_stats.frm
[mysql@localhost mysql]$ rm -rf mysql/innodb_index_stats.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_relay_log_info.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_master_info.frm
[mysql@localhost mysql]$ rm -rf mysql/slave_worker_info.frm
[mysql@localhost mysql]$ rm -rf mysql/gtid_executed.frm
[mysql@localhost mysql]$ rm -rf mysql/server_cost.frm
[mysql@localhost mysql]$ rm -rf mysql/engine_cost.frm

5.配置一个新表空间

[mysql@localhost mysql]$ vi my.cnf
.......
innodb_data_file_path = ibdata1:10M:autoextend

6.重启MySQL服务器

[root@localhost ~]# service mysqld start
Starting MySQL......... SUCCESS!

7.导入dump文件

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 < all_db_dump_20220223.sql
mysql: [Warning] Using a password on the command line interface can be insecure.

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:10M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.01 sec)

InnoDB系统表空间的文件变回原来的ibdata1了

mysql> SELECT TABLE_NAME from INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql' and ENGINE='InnoDB';
+---------------------------+
| TABLE_NAME                |
+---------------------------+
| engine_cost               |
| gtid_executed             |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| server_cost               |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
+---------------------------+
19 rows in set (0.01 sec)

注意:如果您的数据库只使用InnoDB引擎,那么可能更简单的方法是转储所有数据库,停止服务器,删除所有数据库和InnoDB日志文件,重新启动服务器,并导入转储文件。

MySQL 增加InnoDB系统表空间大小

增加InnoDB系统表空间大小
增加InnoDB系统表空间大小的最简单的方法是从一开始就配置为自动扩展。在表空间定义中为最后一个数据文件指定autoextend属性。当InnoDB用完空间时,会自动增加64MB的文件大小。可以通过设置innodb_autoextend_increment系统变量的值来更改增量大小,该变量以兆字节为单位度量。

mysql> show variables like 'innodb_autoextend_increment';
+-----------------------------+-------+
| Variable_name               | Value |
+-----------------------------+-------+
| innodb_autoextend_increment | 64    |
+-----------------------------+-------+
1 row in set (0.01 sec)

通过添加另一个数据文件,可以按定义的数量扩展系统表空间:
1.关闭MySQL服务器

2.如果上一个数据文件是用autoextend关键字定义的,那么根据它实际增长的大小,将其定义更改为使用固定大小。检查数据文件的大小,将其四舍四入到最接近的1024*1024字节(= 1MB)的倍数,并在innodb_data_file_path中显式指定这个四舍五入的大小。

3.在innodb_data_file_path的末尾添加一个新的数据文件,可以选择使该文件自动扩展。只有innodb_data_file_path中的最后一个数据文件可以被指定为自动扩展。

4.重新启动MySQL服务器。

例如,这个表空间只有一个自动扩展的数据文件ibdata1

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------+
| Variable_name         | Value                  |
+-----------------------+------------------------+
| innodb_data_file_path | ibdata1:12M:autoextend |
| innodb_data_home_dir  |                        |
+-----------------------+------------------------+
2 rows in set (0.00 sec)

假设这个数据文件随着时间的推移增长到76MB。下面是修改原始数据文件以使用固定大小并添加新的自动扩展数据文件后的配置行

innodb_data_home_dir =
innodb_data_file_path =  ibdata1:76M;ibdata2:50M:autoextend

当您向系统表空间配置添加一个新的数据文件时,请确保文件名没有引用现有的文件。当您重启服务器时,InnoDB会创建并初始化该文件

a.关闭MySQL服务器

[root@localhost ~]# service mysqld stop
Shutting down MySQL.. SUCCESS!

b.检查数据文件的大小

[mysql@localhost mysql]$ du -sh ibdata1
76M     ibdata1

c.在innodb_data_file_path的末尾添加一个新的数据文件,可以选择使该文件自动扩展。

innodb_data_file_path =  ibdata1:76M;ibdata2:50M:autoextend

d.重启MySQL服务器

[root@localhost ~]# service mysqld start
Starting MySQL..... SUCCESS!

[mysql@localhost ~]$ mysql -uroot -pxxzx7817600 mysql
mysql: [Warning] Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-log Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show variables like 'innodb_data%';
+-----------------------+------------------------------------+
| Variable_name         | Value                              |
+-----------------------+------------------------------------+
| innodb_data_file_path | ibdata1:76M;ibdata2:50M:autoextend |
| innodb_data_home_dir  |                                    |
+-----------------------+------------------------------------+
2 rows in set (0.01 sec)

[root@localhost mysql]# ls -lrt ibdata*
-rw-r-----. 1 mysql mysql 52428800 2月  23 11:13 ibdata2
-rwxr-xr-x. 1 mysql mysql 79691776 2月  23 11:13 ibdata1