文章目录

  • 前言
  • 一、搭建dsc作为dw的主库
    • 1.添加共享磁盘
    • 2.块设备绑定
    • 3.准备 dmdcr_cfg.ini 配置文件
    • 4.使用 DMASMCMD 工具初始化
    • 5.准备dmdcr.ini
    • 6.准备dmasvrmal.ini
    • 7.配置CSS服务并启动
    • 8.配置ASM服务并启动
    • 9.配置并启动监视器
    • 10.创建磁盘组,用与存放数据库数据文件和日志文件
    • 11.初始化库
    • 12.创建dmarch.ini
    • 13.配置数据库服务并启动数据库服务
    • 14.脱机备份DSC数据库
  • 二、搭建DW备库
    • 1.修改dsc实例配置文件
    • 2.修改dsc MAL系统配置文件
    • 3.修改dsc归档配置文件
    • 4.配置dsc数据守护配置文件
    • 5.备库创建实例
    • 6.配置备库归档配置文件
    • 7.配置备库MAL系统配置文件
    • 8.配置备库数据守护配置文件
    • 9.启动所有实例到mount状态
    • 10.修改主备库模式
    • 11.注册服务
    • 12.启动所有节点的守护进程
  • 三、配置监视器

前言

DMDSC达梦共享存储集群,允许多个数据库实例同时访问、操作同一数据库,具有高可用、高性能、负载均衡等特性。DMDSC支持故障自动切换和故障自动重加入,某一个数据库实例故障后,不会导致数据库服务无法提供。数据文件、控制文件在集群系统中只有一份,不论有几个节点,这些节点都平等地使用这文件,这些文件保存在共享存储上。每个节点有自己独立的联机日志和归档日志,其中联机日志保存在共享存储上,归档日志可以保存在本地存储上也可以保存在共享存储上

DMDW:达梦数据守护集群,用于解决由于硬件故障、自然灾害等原因导致的数据库服务长时间中断问题,提供不间断的数据库服务,可同时满足用户对数据安全性和高可用性的要求。它的实现原理是将主库(生产库)产生的Redo日志传输到备库,备库接收并重新应用 Redo 日志,从而实现备库与主库的数据同步


前置条件:
1.已安装达梦数据库软件(/dm8)
2.配置文件目录(/dm8/conf)
3.所有节点的防火墙都已关闭

集群环境:
达梦DSC+DW搭建-编程知识网

一、搭建dsc作为dw的主库

1.添加共享磁盘

磁盘规划:

磁盘 大小 用途
sdb 1G 存放dcr信息
sdc 1G 存放vote信息
sdd 5G 存放redo log
sde 5G 存放data

虚拟机磁盘配置:
达梦DSC+DW搭建-编程知识网

在两个虚拟机磁盘文件中(.vmx)中添加以下配置:

disk.locking="FALSE" 
scsi1:0.SharedBus="Virtual"
scsi1:1.SharedBus="Virtual"
scsi1:2.SharedBus="Virtual"
scsi1:3.SharedBus="Virtual"
disk.enableUUID="TRUE"    
disk.shared="TRUE"scsi1:0.deviceType = "disk"    
scsi1:1.deviceType = "disk"    
scsi1:2.deviceType = "disk"    
scsi1:3.deviceType = "disk"    diskLib.dataCacheMaxSize = "0"  
diskLib.dataCacheMaxReadAheadSize = "0"  
diskLib.DataCacheMinReadAheadSize = "0"  
diskLib.dataCachePageSize = "4096"  
diskLib.maxUnsyncedWrites = "0"  

2.块设备绑定

DSC1:

查看磁盘scsi_id

[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   50G  0 disk 
├─sda1            8:1    0  488M  0 part /boot
└─sda2            8:2    0 49.5G  0 part ├─centos-root 253:0    0 47.7G  0 lvm  /└─centos-swap 253:1    0  1.9G  0 lvm  [SWAP]
sdb               8:16   0    1G  0 disk 
sdc               8:32   0    1G  0 disk 
sdd               8:48   0    5G  0 disk 
sde               8:64   0    5G  0 disk 
sr0              11:0    1  4.4G  0 rom  /run/media/root/CentOS 7 x86_64[root@localhost ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb
36000c29c4227c5ea9376056e9f7b72e1
[root@localhost ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc
36000c2942c1748aec84381dc36c07091
[root@localhost ~]# /usr/lib/udev/scsi_id -g -u /dev/sdd
36000c29c098aad62e1465086477efcd4
[root@localhost ~]# /usr/lib/udev/scsi_id -g -u /dev/sde
36000c2964b91188b249ae63b06c593a1

配置/etc/udev/rules.d/66-dmasmdevices.rules

[root@localhost ~]# vim /etc/udev/rules.d/66-dmasmdevices.rules
KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29c4227c5ea9376056e9f7b72e1",SYMLINK+="DM_DCR", RUN+="/bin/sh -c 'chown -R test /dev/DM_DCR;chmod 0660 /dev/DM_DCR'"KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2942c1748aec84381dc36c07091",SYMLINK+="DM_VOTE", RUN+="/bin/sh -c 'chown -R test /dev/DM_VOTE; chmod 0660 /dev/DM_VOTE'"KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29c098aad62e1465086477efcd4",SYMLINK+="DM_LOG", RUN+="/bin/sh -c 'chown -R test /dev/DM_LOG; chmod 0660 /dev/DM_LOG'"KERNEL=="sd*",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2964b91188b249ae63b06c593a1",SYMLINK+="DM_DATA", RUN+="/bin/sh -c 'chown -R test /dev/DM_DATA; chmod 0660 /dev/DM_DATA'"[root@localhost ~]# partprobe 

查看绑定的块设备信息

[root@localhost ~]# ll /dev/DM_*
lrwxrwxrwx. 1 root root 3 923 14:35 /dev/DM_DATA -> sde
lrwxrwxrwx. 1 root root 3 923 14:35 /dev/DM_DCR -> sdb
lrwxrwxrwx. 1 root root 3 923 14:35 /dev/DM_LOG -> sdd
lrwxrwxrwx. 1 root root 3 923 14:35 /dev/DM_VOTE -> sdc

拷贝udev文件

[root@localhost ~]# scp /etc/udev/rules.d/66-dmasmdevices.rules 192.168.10.20:/etc/udev/rules.d/

创建文件夹/dev_DMDATA ,将固定盘符软连接到当前文件夹下

[root@localhost ~]# mkdir /dev_DMDATA
[root@localhost ~]# ln -s /dev/DM_DATA /dev_DMDATA/DM_DATA
[root@localhost ~]# ln -s /dev/DM_DCR /dev_DMDATA/DM_DCR
[root@localhost ~]# ln -s /dev/DM_LOG /dev_DMDATA/DM_LOG
[root@localhost ~]# ln -s /dev/DM_VOTE /dev_DMDATA/DM_VOTE

将软链接、块设备和块设备对应的磁盘的权限赋予数据库用户

[root@localhost ~]# chown -R dmdba /dev/DM_*
[root@localhost ~]# chown -R dmdba /dev_DMDATA/* 
[root@localhost ~]# chown -R dmdba /dev/sdb
[root@localhost ~]# chown -R dmdba /dev/sdc
[root@localhost ~]# chown -R dmdba /dev/sdd
[root@localhost ~]# chown -R dmdba /dev/sde

DSC2:

更新设备信息

[root@localhost ~]# partprobe 
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)/dev/sr0 已按照只读方式打开。
[root@localhost ~]# ll /dev/DM_*
lrwxrwxrwx. 1 root root 3 923 14:59 /dev/DM_DATA -> sde
lrwxrwxrwx. 1 root root 3 923 14:59 /dev/DM_DCR -> sdb
lrwxrwxrwx. 1 root root 3 923 14:59 /dev/DM_LOG -> sdd
lrwxrwxrwx. 1 root root 3 923 14:59 /dev/DM_VOTE -> sdc

创建文件夹/dev_DMDATA ,将固定盘符软连接到当前文件夹下

[root@localhost ~]# mkdir /dev_DMDATA
[root@localhost ~]# ln -s /dev/DM_DATA /dev_DMDATA/DM_DATA
[root@localhost ~]# ln -s /dev/DM_DCR /dev_DMDATA/DM_DCR
[root@localhost ~]# ln -s /dev/DM_LOG /dev_DMDATA/DM_LOG
[root@localhost ~]# ln -s /dev/DM_VOTE /dev_DMDATA/DM_VOTE

将软链接、块设备和块设备对应的磁盘的权限赋予数据库用户

[root@localhost ~]# chown -R dmdba /dev/DM_*
[root@localhost ~]# chown -R dmdba /dev_DMDATA/* 
[root@localhost ~]# chown -R dmdba /dev/sdb
[root@localhost ~]# chown -R dmdba /dev/sdc
[root@localhost ~]# chown -R dmdba /dev/sdd
[root@localhost ~]# chown -R dmdba /dev/sde

3.准备 dmdcr_cfg.ini 配置文件

DSC1和DSC2配置相同

[dmdba@localhost conf]$ pwd
/dm8/conf[dmdba@localhost ~]$ vim dmdcr_cfg.ini
DCR_N_GRP = 3                            #集群环境中包括多少个group
DCR_VTD_PATH = /dev_DMDATA/DM_VOTE       #Voting Disk路径
DCR_OGUID = 63635                        #消息标识, dmcssm 登录 dmcss 消息校验用[GRP]
DCR_GRP_TYPE = CSS                #组类型
DCR_GRP_NAME = GRP_CSS            #组名
DCR_GRP_N_EP = 2                  #组内节点数
DCR_GRP_DSKCHK_CNT = 60           #磁盘心跳机制,容错时间,单位s,缺省60
[GRP_CSS]
DCR_EP_NAME = CSS0                #节点名
DCR_EP_HOST = 192.168.10.10       #节点ip
DCR_EP_PORT = 9341                #节点TCP监听端口,范围:1024-65535
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 192.168.10.20
DCR_EP_PORT = 9343[GRP]
DCR_GRP_TYPE = ASM
DCR_GRP_NAME = GRP_ASM
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_ASM]
DCR_EP_NAME = ASM0
DCR_EP_SHM_KEY = 93360
DCR_EP_SHM_SIZE = 20
DCR_EP_HOST = 192.168.10.10
DCR_EP_PORT = 9349
DCR_EP_ASM_LOAD_PATH = /dev_DMDATA
[GRP_ASM]
DCR_EP_NAME = ASM1
DCR_EP_SHM_KEY = 93361
DCR_EP_SHM_SIZE = 20
DCR_EP_HOST = 192.168.10.20
DCR_EP_PORT = 9351
DCR_EP_ASM_LOAD_PATH = /dev_DMDATA[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 = 9742

4.使用 DMASMCMD 工具初始化

DSC1:

[dmdba@localhost bin]$ ./dmasmcmd 
DMASMCMD V8
ASM>create dcrdisk '/dev_DMDATA/DM_DCR' 'dcr'
[Trace]The ASM initialize dcrdisk /dev_DMDATA/DM_DCR to name DMASMdcr
Used time: 16.294(ms).ASM>create votedisk '/dev_DMDATA/DM_VOTE' 'vote'
[Trace]The ASM initialize votedisk /dev_DMDATA/DM_VOTE to name DMASMvote
Used time: 9.759(ms).ASM>create asmdisk '/dev_DMDATA/DM_DATA' 'DATA01'
[Trace]The ASM initialize asmdisk /dev/DM_DATA to name DMASMDATA01
Used time: 7.342(ms).
ASM>create asmdisk '/dev_DMDATA/DM_LOG' 'LOG01'
[Trace]The ASM initialize asmdisk /dev/DM_LOG to name DMASMLOG01
Used time: 4.531(ms).ASM>init dcrdisk '/dev_DMDATA/DM_DCR' from '/dm8/conf/dmdcr_cfg.ini' identified by 'admin1234'
[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: 84.899(ms).ASM>init votedisk '/dev_DMDATA/DM_VOTE' from '/dm8/conf/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: 36.464(ms).

5.准备dmdcr.ini

DSC1:

[dmdba@localhost conf]$ pwd
/dm8/conf
[dmdba@localhost dm8]$ vim dmdcr.ini 
DMDCR_PATH = /dev_DMDATA/DM_DCR
DMDCR_MAL_PATH = /dm8/conf/dmasvrmal.ini  #asmsvr使用
DMDCR_SEQNO = 0#ASM 重启参数,命令行方式启动
#DMDCR_ASM_RESTART_INTERVAL = 0
#DMDCR_ASM_STARTUP_CMD = /dm8/bin/dmasmsvr dcr_ini = /dm8/conf/dmdcr.ini#DB 重启参数,命令行方式启动
#DMDCR_DB_RESTART_INTERVAL = 0
#DMDCR_DB_STARTUP_CMD=/dm8/bin/dmserver path=/dm8/conf/hldb0_config/dm.ini dcr_ini=/dm8/conf/dmdcr.ini

DSC2:

[dmdba@localhost conf]$ pwd
/dm8/conf
[dmdba@localhost conf]$ cat dmdcr.ini  
DMDCR_PATH = /dev_DMDATA/DM_DCR
DMDCR_MAL_PATH = /dm8/conf/dmasvrmal.ini  #asmsvr使用
DMDCR_SEQNO = 1#ASM 重启参数,命令行方式启动
#DMDCR_ASM_RESTART_INTERVAL = 0
#DMDCR_ASM_STARTUP_CMD = /dm8/bin/dmasmsvr dcr_ini = /dm8/conf/dmdcr.ini#DB 重启参数,命令行方式启动
#DMDCR_DB_RESTART_INTERVAL = 0
#DMDCR_DB_STARTUP_CMD=/dm8/bin/dmserver path=/dm8/conf/hldb0_config/dm.ini dcr_ini=/dm8/conf/dmdcr.ini

6.准备dmasvrmal.ini

DSC1和DSC2配置相同

[dmdba@localhost conf]$ cat dmasvrmal.ini 
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 192.168.10.10
MAL_PORT = 5244
[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 192.168.10.20
MAL_PORT = 5244

7.配置CSS服务并启动

DSC1:

[dmdba@localhost bin]$ ./dmcss dcr_ini=/dm8/conf/dmdcr.ini[root@localhost root]# ./dm_service_installer.sh -t dmcss -dcr_ini /dm8/conf/dmdcr.ini -p CSS
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServiceCSS.service to /usr/lib/systemd/system/DmCSSServiceCSS.service.
创建服务(DmCSSServiceCSS)完成[dmdba@localhost bin]$ ./DmCSSServiceCSS start
Starting DmCSSServiceCSS:                                  [ OK ]

DSC2

[dmdba@localhost bin]$ ./dmcss dcr_ini=/dm8/conf/dmdcr.ini
[root@localhost root]# ./dm_service_installer.sh -t dmcss -dcr_ini /dm8/conf/dmdcr.ini -p CSS
Created symlink from /etc/systemd/system/multi-user.target.wants/DmCSSServiceCSS.service to /usr/lib/systemd/system/DmCSSServiceCSS.service.
创建服务(DmCSSServiceCSS)完成
[dmdba@localhost bin]$ ./DmCSSServiceCSS start
Starting DmCSSServiceCSS:                                  [ OK ]

8.配置ASM服务并启动

DSC1:

[dmdba@localhost bin]$ ./dmasmsvr dcr_ini=/dm8/conf/dmdcr.ini
[root@localhost root]# ./dm_service_installer.sh -t dmasmsvr -dcr_ini /dm8/conf/dmdcr.ini -y DmCSSServiceCSS.service -p ASM
[dmdba@localhost bin]$ ./DmASMSvrServiceASM start
Starting DmASMSvrServiceASM:                               [ OK ]

DSC2:

[dmdba@localhost bin]$ ./dmasmsvr dcr_ini=/dm8/conf/dmdcr.ini
[root@localhost root]# ./dm_service_installer.sh -t dmasmsvr -dcr_ini /dm8/conf/dmdcr.ini -y DmCSSServiceCSS.service -p ASM
[dmdba@localhost bin]$ ./DmASMSvrServiceASM start
Starting DmASMSvrServiceASM:                               [ OK ]

9.配置并启动监视器

DSC1和DSC2配置相同

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

达梦DSC+DW搭建-编程知识网

10.创建磁盘组,用与存放数据库数据文件和日志文件

DSC1:

[dmdba@localhost bin]$ ./dmasmtool dcr_ini=/dm8/conf/dmdcr.ini
DMASMTOOL V8
ASM>create diskgroup 'DMDATA' asmdisk '/dev_DMDATA/DM_DATA' 
Used time: 32.924(ms).
ASM>create diskgroup 'DMLOG' asmdisk '/dev_DMDATA/DM_LOG'
Used time: 36.661(ms).
ASM>exit

11.初始化库

DSC1:

[dmdba@localhost bin]$ cd /dm8/conf/
[dmdba@localhost conf]$ vim dminit.inidb_name                  = dscsystem_path              = +DMDATA/datamain                     = +DMDATA/data/dsc/main.dbfmain_size                = 128roll                     = +DMDATA/data/dsc/roll.dbfroll_size                = 128system                   = +DMDATA/data/dsc/system.dbfsystem_size              = 128ctl_path                 = +DMDATA/data/dsc/dm.ctlctl_size                 = 8log_size                 = 1024dcr_path                 = /dev_DMDATA/DM_DCRdcr_seqno                = 0auto_overwrite           = 1PAGE_SIZE                = 32CASE_SENSITIVE           = YCHARSET                  = 0[DSC0]config_path              = /dm8/conf/dsc0_configport_num                 = 5236mal_host                 = 192.168.10.10mal_port                 = 5736log_path                 = +DMLOG/log/dsc0_log01.loglog_path                 = +DMLOG/log/dsc0_log02.log
[DSC1]config_path              = /dm8/conf/dsc1_configport_num                 = 5236mal_host                 = 192.168.10.20mal_port                 = 5737log_path                 = +DMLOG/log/dsc1_log01.loglog_path                 = +DMLOG/log/dsc1_log02.log
[dmdba@localhost bin]$ ./dminit control=/dm8/conf/dminit.ini
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2023-08-12
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLLlog file path: +DMLOG/log/dsc0_log01.loglog file path: +DMLOG/log/dsc0_log02.loglog file path: +DMLOG/log/dsc1_log01.loglog file path: +DMLOG/log/dsc1_log02.logwrite to dir [+DMDATA/data/dsc].
create dm database success. 2022-09-29 11:20:16[dmdba@localhost bin]$ scp -r /dm8/conf/dsc1_config dmdba@192.168.10.20:/dm8/conf/

12.创建dmarch.ini

DSC1:

[dmdba@localhost bin]$ vim /dm8/conf/dsc0_config/dm.iniARCH_INI                 = 1
[dmdba@localhost bin]$ vim /dm8/conf/dsc0_config/dmarch.ini
[ARCHIVE_LOCAL]ARCH_TYPE                = LOCALARCH_DEST                = /dm8/dsc/arch_0ARCH_FILE_SIZE           = 1024ARCH_SPACE_LIMIT         = 51200
[ARCHIVE_REMOTE]ARCH_TYPE                = REMOTEARCH_DEST                = DSC1ARCH_INCOMING_PATH       = /dm8/dsc/arch_0_remoteARCH_FILE_SIZE           = 1024ARCH_SPACE_LIMIT         = 51200
[dmdba@localhost bin]$ ./dmserver /dm8/conf/dsc0_config/dm.ini  dcr_ini=/dm8/conf/dmdcr.ini

DSC2:

[dmdba@localhost bin]$ vim /dm8/conf/dsc1_config/dm.iniARCH_INI                 = 1
[dmdba@localhost bin]$ vim /dm8/conf/dsc1_config/dmarch.ini
[ARCHIVE_LOCAL]ARCH_TYPE                = LOCALARCH_DEST                = /dm8/dsc/arch_1ARCH_FILE_SIZE           = 1024ARCH_SPACE_LIMIT         = 51200
[ARCHIVE_REMOTE]ARCH_TYPE                = REMOTEARCH_DEST                = DSC0ARCH_INCOMING_PATH       = /dm8/dsc/arch_1_remoteARCH_FILE_SIZE           = 1024ARCH_SPACE_LIMIT         = 51200
[dmdba@localhost bin]$ ./dmserver /dm8/conf/dsc1_config/dm.ini  dcr_ini=/dm8/conf/dmdcr.ini

13.配置数据库服务并启动数据库服务

DSC1:

[root@localhost root]# ./dm_service_installer.sh -t dmserver -dm_ini /dm8/conf/dsc0_config/dm.ini -dcr_ini /dm8/conf/dmdcr.ini -y DmASMSvrServiceASM.service -p DSC0
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceDSC0.service to /usr/lib/systemd/system/DmServiceDSC0.service.
创建服务(DmServiceDSC0)完成
[dmdba@localhost bin]$ ./DmServiceDSC0 start
Starting DmServiceDSC0: connnect dmasmtool successfully.[ OK ]

DSC2:

[root@localhost root]# ./dm_service_installer.sh -t dmserver -dm_ini /dm8/conf/dsc1_config/dm.ini -dcr_ini /dm8/conf/dmdcr.ini -y DmASMSvrServiceASM.service -p DSC1
Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceDSC1.service to /usr/lib/systemd/system/DmServiceDSC1.service.
创建服务(DmServiceDSC1)完成
[dmdba@localhost bin]$ ./DmServiceDSC1 start
Starting DmServiceDSC1: connnect dmasmtool successfully.[ OK ]

成功启动后集群状态:
达梦DSC+DW搭建-编程知识网
分别在两个节点登录数据库:

[dmdba@localhost bin]$ ./disql SYSDBA/SYSDBA服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间 : 18.019(ms)
disql V8
SQL> 
SQL> 
[dmdba@localhost bin]$ ./disql SYSDBA/SYSDBA服务器[LOCALHOST:5236]:处于普通打开状态
登录使用时间 : 34.488(ms)
disql V8
SQL> 
SQL> 

14.脱机备份DSC数据库

在监视器中关闭数据库实例并备份数据库

[dmdba@loaclhost bin]$ ./dmcssmep stop grp_dsc[dmdba@loaclhost bin]$ ./dmrman use_ap=2 dcr_ini=/dm8/conf/dmdcr.ini
dmrman V8
RMAN> 
RMAN> backup database '/dm8/conf/dsc0_config/dm.ini' backupset '/dm8/dscfullbak';
backup database '/dm8/conf/dsc0_config/dm.ini' backupset '/dm8/dscfullbak';
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[43865], file_lsn[43865]
EP[1]'s cur_lsn[43877]
EP[0] adjust cur_lsn from [43865] to [43877]
Processing backupset /dm8/dscfullbak
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]                                 
backup successfully!
time used: 00:00:09.999备份文件拷贝到备库上(/dm8下)
[dmdba@loaclhost ~]$ cd /dm8/
[dmdba@loaclhost dm8]$ scp -r dscfullbak/ dmdba@10.12.21.78:/dm8/

二、搭建DW备库

1.修改dsc实例配置文件

DSC1:

[dmdba@loaclhost ~]$ vim /dm8/conf/dsc0_config/dm.ini
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间

DSC2:

[dmdba@loaclhost ~]$ vim /dm8/conf/dsc1_config/dm.ini 
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间

2.修改dsc MAL系统配置文件

DSC1:

[dmdba@loaclhost ~]$ vim /dm8/conf/dsc0_config/dmmal.ini
[mal_inst0]mal_inst_name  = DSC0mal_host       = 192.168.56.102mal_port       = 5736mal_inst_host  = 192.168.56.102mal_inst_port  = 5236mal_dw_port    = 3567mal_inst_dw_port = 4567[mal_inst1]mal_inst_name  = DSC1mal_host       = 192.168.56.101mal_port       = 5737mal_inst_host  = 192.168.56.101mal_inst_port  = 5236mal_dw_port    = 3568mal_inst_dw_port = 4568[mal_inst2]mal_inst_name = DSC_DWmal_host      = 192.168.56.103mal_port      = 5738mal_inst_host = 192.168.56.103mal_inst_port = 5236mal_dw_port   = 3569mal_inst_dw_port = 4569

DSC2:

[dmdba@loaclhost ~]$ vim /dm8/conf/dsc0_config/dmmal.ini
[mal_inst0]mal_inst_name  = DSC0mal_host       = 192.168.56.102mal_port       = 5736mal_inst_host  = 192.168.56.102mal_inst_port  = 5236mal_dw_port    = 3567mal_inst_dw_port = 4567[mal_inst1]mal_inst_name  = DSC1mal_host       = 192.168.56.101mal_port       = 5737mal_inst_host  = 192.168.56.101mal_inst_port  = 5236mal_dw_port    = 3568mal_inst_dw_port = 4568[mal_inst2]mal_inst_name = DSC_DWmal_host      = 192.168.56.103mal_port      = 5738mal_inst_host = 192.168.56.103mal_inst_port = 5236mal_dw_port   = 3569mal_inst_dw_port = 4569

3.修改dsc归档配置文件

DSC1:

[dmdba@loaclhost ~]$ vim /dm8/conf/dsc0_config/dmarch.ini 追加以下内容
[ARCHIVE_REALTIME]ARCH_TYPE                = REALTIMEARCH_DEST                = DSC_DW

DSC2:

[dmdba@loaclhost ~]$ vim /dm8/conf/dsc1_config/dmarch.ini
[ARCHIVE_REALTIME]ARCH_TYPE                = REALTIMEARCH_DEST                = DSC_DW

4.配置dsc数据守护配置文件

DSC1:

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

DSC2:

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

5.备库创建实例

[dmdba@loaclhost bin]$ pwd
/dm8/bin
[dmdba@loaclhost bin]$ ./dminit path=/dm8/data/ page_size=32 EXTENT_SIZE=32 charset=1 db_name=DSC_DW INSTANCE_NAME=DSC_DW//修改配置文件
[dmdba@loaclhost bin]$ vim /dm8/data/DSC_DW/dm.ini
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
ARCH_INI = 1 #开启归档模式
MAL_INI = 1 #开启MAL系统

使用备份还原数据库

[dmdba@loaclhost bin]$ ./dmrman use_ap=2 CTLSTMT="RESTORE DATABASE '/dm8/data/DSC_DW/dm.ini' FROM BACKUPSET '/dm8/dscfullbak/'"
[dmdba@loaclhost bin]$ ./dmrman use_ap=2 CTLSTMT="RECOVER DATABASE '/dm8/data/DSC_DW/dm.ini' FROM BACKUPSET '/dm8/dscfullbak/'"
[dmdba@loaclhost bin]$ ./dmrman use_ap=2 CTLSTMT="RECOVER DATABASE '/dm8/data/DSC_DW/dm.ini' UPDATE DB_MAGIC"

6.配置备库归档配置文件

[dmdba@loaclhost bin]$ vim /dm8/data/DSC_DW/dmarch.ini
[ARCHIVE_LOCAL1]
arch_type =local
arch_dest = /dm8/arch
arch_file_size = 64
arch_space_limit = 51200
[ARCHIVE_REALTIME]
arch_type = realtime
arch_dest = DSC0/DSC1

7.配置备库MAL系统配置文件

[dmdba@loaclhost bin]$ vim /dm8/data/DSC_DW/dmmal.ini
[mal_inst0]mal_inst_name  = DSC0mal_host       = 192.168.56.102mal_port       = 5736mal_inst_host  = 192.168.56.102mal_inst_port  = 5236mal_dw_port    = 3567mal_inst_dw_port = 4567[mal_inst1]mal_inst_name  = DSC1mal_host       = 192.168.56.101mal_port       = 5737mal_inst_host  = 192.168.56.101mal_inst_port  = 5236mal_dw_port    = 3568mal_inst_dw_port = 4568[mal_inst2]mal_inst_name = DSC_DWmal_host      = 192.168.56.103mal_port      = 5738mal_inst_host = 192.168.56.103mal_inst_port = 5236mal_dw_port   = 3569mal_inst_dw_port = 4569

8.配置备库数据守护配置文件

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

9.启动所有实例到mount状态

DSC1:

[dmdba@loaclhost bin]$ ./dmserver path=/dm8/conf/dsc0_config/dm.ini dcr_ini=/dm8/conf/dmdcr.ini mount

DSC2:

[dmdba@loaclhost bin]$ ./dmserver path=/dm8/conf/dsc1_config/dm.ini dcr_ini=/dm8/conf/dmdcr.ini mount

DSC_DW:

[dmdba@loaclhost bin]$ ./dmserver path=/dm8/data/DSC_DW/dm.ini[dmdba@loaclhost bin]$ ./dmserver path=/dm8/data/DSC_DW/dm.ini mount

10.修改主备库模式

DSC1:

[dmdba@loaclhost bin]$ ./disql SYSDBA/SYSDBA
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间 : 10.614(ms)
disql V8
SQL> sp_set_oguid(453331);
DMSQL 过程已成功完成
已用时间: 165.775(毫秒). 执行号:0.
SQL> alter database primary;
操作已执行
已用时间: 363.983(毫秒). 执行号:0.
SQL> exit

DSC_DW:

[dmdba@loaclhost bin]$ ./disql SYSDBA/SYSDBA
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间 : 10.401(ms)
disql V8
SQL> 
SQL> sp_set_oguid(453331);
DMSQL 过程已成功完成
已用时间: 19.921(毫秒). 执行号:0.
SQL> alter database standby;
操作已执行
已用时间: 39.812(毫秒). 执行号:0.
SQL> exit

11.注册服务

[root@loaclhost ~]# cd /dm8/script/root/
[root@loaclhost root]# ./dm_service_installer.sh -t dmwatcher -p dmwdsc0 -watcher_ini /dm8/conf/dsc0_config/dmwatcher.ini
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedmwdsc0.service to /usr/lib/systemd/system/DmWatcherServicedmwdsc0.service.
创建服务(DmWatcherServicedmwdsc0)完成
[root@loaclhost ~]# cd /dm8/script/root/
[root@loaclhost root]# ./dm_service_installer.sh -t dmwatcher -p dmwdsc0 -watcher_ini /dm8/conf/dsc1_config/dmwatcher.ini
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedmwdsc0.service to /usr/lib/systemd/system/DmWatcherServicedmwdsc0.service.
创建服务(DmWatcherServicedmwdsc0)完成
[root@loaclhost root]# ./dm_service_installer.sh -t dmwatcher -p dmwdscdw -watcher_ini /dm8/data/DSC_DW/dmwatcher.ini
Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServicedmwdscdw.service to /usr/lib/systemd/system/DmWatcherServicedmwdscdw.service.
创建服务(DmWatcherServicedmwdscdw)完成

12.启动所有节点的守护进程

[dmdba@loaclhost ~]$ cd /dm8/bin
[dmdba@loaclhost bin]$ ./DmWatcherServicedmwdsc0 start
Starting DmWatcherServicedmwdsc0:                          [ OK ]
[dmdba@loaclhost ~]$ cd /dm8/bin
[dmdba@loaclhost bin]$ ./DmWatcherServicedmwdsc1 start
Starting DmWatcherServicedmwdsc1:                          [ OK ]
[dmdba@loaclhost ~]$ cd /dm8/bin
[dmdba@loaclhost bin]$ ./DmWatcherServicedmwdscdw start
Starting DmWatcherServicedmwdscdw:                         [ OK ]

三、配置监视器

[dmdba@loaclhost bin]$ pwd
/dm8/bin
[dmdba@loaclhost bin]$ vim dmmonitor.ini 
MON_LOG_PATH = /dm8/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 64
MON_LOG_SPACE_LIMIT = 0
MON_DW_CONFIRM = 0
[GRP_DSC_DW]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.56.102:3567/192.168.56.101:3568  #watcher MAL_DW_PORT端口号
MON_DW_IP = 192.168.56.103:3569启动监视器
[dmdba@loaclhost bin]$ ./dmmonitor dmmonitor.ini

show查看集群状态
达梦DSC+DW搭建-编程知识网
注册服务

[root@loaclhost ~]# cd /dm8/script/root/
[root@loaclhost root]# ./dm_service_installer.sh -t dmmonitor -p Monitor -monitor_ini /dm8/bin/dmmonitor.ini
Created symlink from /etc/systemd/system/multi-user.target.wants/DmMonitorServiceMonitor.service to /usr/lib/systemd/system/DmMonitorServiceMonitor.service.
创建服务(DmMonitorServiceMonitor)完成

后台启动

[dmdba@loaclhost ~]$ cd /dm8/bin
[dmdba@loaclhost bin]$ ./DmMonitorServiceMonitor start