DM达梦实操+DMDSC共享存储集群+安装部署

前言

达梦DMDSC共享存储集群是达梦数据库的高可用技术,可以实现数据库的负载均衡和故障切换等功能,一个数据库可以对应多个实例。
DM达梦实操+DMDSC共享存储集群+安装部署_第1张图片

一、配置信息

1.1IP规划

主机名 公网IP 私网IP
DM8-H1 192.168.3.171 10.10.10.1
DM8-H2 192.168.3.172 10.10.10.2

1.2磁盘组规划

磁盘 大小 用途
dcr01 1g dcr disk
vote01 1g vote disk
redo01 10g log disk
data01 50g data disk
data02 50g data disk

二、操作系统安装

note:安装很简单,快速带过
DM达梦实操+DMDSC共享存储集群+安装部署_第2张图片
DM达梦实操+DMDSC共享存储集群+安装部署_第3张图片

DM达梦实操+DMDSC共享存储集群+安装部署_第4张图片

DM达梦实操+DMDSC共享存储集群+安装部署_第5张图片

DM达梦实操+DMDSC共享存储集群+安装部署_第6张图片

DM达梦实操+DMDSC共享存储集群+安装部署_第7张图片
DM达梦实操+DMDSC共享存储集群+安装部署_第8张图片

DM达梦实操+DMDSC共享存储集群+安装部署_第9张图片
DM达梦实操+DMDSC共享存储集群+安装部署_第10张图片

在这里插入图片描述
DM达梦实操+DMDSC共享存储集群+安装部署_第11张图片

DM达梦实操+DMDSC共享存储集群+安装部署_第12张图片
DM达梦实操+DMDSC共享存储集群+安装部署_第13张图片

三、操作系统配置

3.1依赖包安装

note:安装相关gcc开发环境

yum install -y gcc glibc* glibc-devel* libgcc* unixODBC

3.2关闭SElinux

note:中标麒麟默认安装是关闭状态

vi /etc/selinux/config
……
SELINUX=disabled
……

3.3关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

3.4修改主机名

vi /etc/hostname 

dm8-h1

3.5配置hosts文件

vi /etc/hosts

192.168.3.171  dm8-h1
192.168.3.172  dm8-h2

3.6创建用户

groupadd dinstall
useradd -g dinstall dmdba
passwd dmdba

3.7创建目录

mkdir -p /opt/dm8/dmdbms
chown dmdba.dinstall -R /opt/dm8
chmod 775 -R /opt/dm8

3.8配置环境变量

vi .bash_profile

export DM_HOME=/opt/dm8/dmdbms
export LD_LIBRARY_PATH=$DM_HOME/bin:$LD_LIBRARY_PATH
export PATH=$DM_HOME/bin:$PATH

3.9配置资源限制

vi /etc/security/limits.conf

dmdba hard nofile 65536
dmdba soft nofile 65536
dmdba hard stack 32768
dmdba soft stack 16384

3.10绑定裸设备

vi /etc/udev/rules.d/60-raw.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=="raw[1-5]", OWNER="dmdba", GROUP="dinstall", MODE="660"

重启udev

systemctl restart systemd-udev-trigger.service

查看大小,单位字节

blockdev --getsize64 /dev/raw/raw1

四、DM软件安装

命令行安装

[dmdba@dm8-h1 ~]$ ./DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:
Extract install files......... 
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31835
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 4096
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

The max number of open files is too little, suggest to set 65536 or more to number of open files.

Welcome to DM DBMS Installer

Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:
Please Input the Path of the Key File [dm.key]:
Please input the path of key file!
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]:
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)
[11]: GTM-02=Middle Atlantic
[13]: GTM=Greenwich Mean Time
Please Select the TimeZone [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]:
Require Space: 1075M

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

Pre-Installation Summary
Installation Location: /opt/dm8/dmdbms
Require Space: 1075M
Available Space: 85G
Version Information: 
Expire Date: 
Installation Type: Custom
Confirm to Install? (Y/y:Yes N/n:No):y
2021-02-26 12:10:53 
[INFO] Installing DM DBMS...
2021-02-26 12:10:54 
[INFO] Installing BASE Module...
2021-02-26 12:10:57 
[INFO] Installing SERVER Module...
2021-02-26 12:10:57 
[INFO] Installing CLIENT Module...
2021-02-26 12:10:59 
[INFO] Installing DRIVERS Module...
2021-02-26 12:10:59 
[INFO] Installing MANUAL Module...
2021-02-26 12:10:59 
[INFO] Installing SERVICE Module...
2021-02-26 12:11:01 
[INFO] Move ant log file to log directory.
2021-02-26 12:11:02 
[INFO] Installed DM DBMS completely.

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

End

运行root脚本

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

五、配置DMASM

5.1配置dmdcr_cfg.ini文件

创建目录

mkdir /opt/dm8/dmdbms/data

编辑配置文件

vi /opt/dm8/dmdbms/data/dmdcr_cfg.ini

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 = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_CSS]
DCR_EP_NAME = CSS0
DCR_EP_HOST = 10.10.10.1
DCR_EP_PORT = 9541
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 10.10.10.2
DCR_EP_PORT = 9542

[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 = 10
DCR_EP_HOST = 10.10.10.1
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.10.2
DCR_EP_PORT = 9642
DCR_EP_ASM_LOAD_PATH = /dev/raw

[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

5.2磁盘初始化

[dmdba@dm8-h1 data]$ dmasmcmd
DMASMCMD V8
ASM>create dcrdisk '/dev/raw/raw1' 'dcr01'
[Trace]The ASM initialize dcrdisk /dev/raw/raw1 to name DMASMdcr01
Used time: 29.813(ms).
ASM>create votedisk '/dev/raw/raw2' 'vote01'
create asmdisk '/dev/raw/raw3' 'REDO01'
create asmdisk '/dev/raw/raw4' 'DATA01'
create asmdisk '/dev/raw/raw5' 'DATA02'[Trace]The ASM initialize votedisk /dev/raw/raw2 to name DMASMvote01
Used time: 87.007(ms).
ASM>[Trace]The ASM initialize asmdisk /dev/raw/raw3 to name DMASMREDO01
Used time: 471.858(ms).
ASM>[Trace]The ASM initialize asmdisk /dev/raw/raw4 to name DMASMDATA01
Used time: 58.995(ms).
ASM>
[Trace]The ASM initialize asmdisk /dev/raw/raw5 to name DMASMDATA02
Used time: 34.306(ms).
ASM>
ASM>init dcrdisk '/dev/raw/raw1' from '/opt/dm8/dmdbms/data/dmdcr_cfg.ini' identified by 'dm1234'
[Trace]DG 126 allocate 4 extents for file 0xfe000002.
Used time: 00:00:01.071.
ASM>
ASM>init votedisk '/dev/raw/raw2' from '/opt/dm8/dmdbms/data/dmdcr_cfg.ini'
[Trace]DG 125 allocate 4 extents for file 0xfd000002.
Used time: 431.918(ms).
ASM>

5.3配置dmasvrmal.ini文件

note:所有节点配置

vi /opt/dm8/dmdbms/data/dmasvrmal.ini
------------------------------------------------------------------
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 10.10.10.1
MAL_PORT = 7236
[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 10.10.10.2
MAL_PORT = 7237

5.4配置dmdcr.ini文件

note:每个节点的序号需要改变

节点一:


vi /opt/dm8/dmdbms/data/dmdcr.ini

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

DMDCR_PATH = /dev/raw/raw1
DMDCR_MAL_PATH =/opt/dm8/dmdbms/data/dmasvrmal.ini
DMDCR_SEQNO = 0

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

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

节点二:

vi /opt/dm8/dmdbms/data/dmdcr.ini

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

DMDCR_PATH = /dev/raw/raw1
DMDCR_MAL_PATH =/opt/dm8/dmdbms/data/dmasvrmal.ini
DMDCR_SEQNO = 1

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

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

5.5配置DMCSS和DMASM服务

注册DMCSS服务

[root@dm8-h1 root]# /opt/dm8/dmdbms/script/root/dm_service_installer.sh -t dmcss -dcr_ini /opt/dm8/dmdbms/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@dm8-h1 root]# systemctl status DmCSSServicedsc1.service 
● DmCSSServicedsc1.service - Dameng CSS Service(DmCSSServicedsc1).
   Loaded: loaded (/usr/lib/systemd/system/DmCSSServicedsc1.service; enabled; vendor preset: disabled)
   Active: inactive (dead)

启动DMCSS服务

systemctl start DmCSSServicedsc1.service

注册DMASM服务

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

[root@dm8-h1 root]# systemctl status DmASMSvrServicedsc1.service 
● DmASMSvrServicedsc1.service - Dameng ASM Server Service(DmASMSvrServicedsc1).
   Loaded: loaded (/usr/lib/systemd/system/DmASMSvrServicedsc1.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
[root@dm8-h1 root]#

启动DMASM服务

systemctl start DmASMSvrServicedsc1.service

5.7创建DASM磁盘组

note:dmasm服务启动正常,即可创建磁盘组

dmasmtool DCR_INI=/opt/dm8/dmdbms/data/dmdcr.ini

create diskgroup 'DMREDO' asmdisk '/dev/raw/raw3'
create diskgroup 'DMDATA' asmdisk '/dev/raw/raw4'

六、配置数据库

6.1配置dminit.ini文件

vi /opt/dm8/dmdbms/data/dminit.ini

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

db_name = wldb
SYSDBA_PWD = dameng1234
SYSAUDITOR_PWD = dameng1234
system_path = +DMDATA/data
system = +DMDATA/wldb/datafile/system.dbf
system_size = 128
roll = +DMDATA/wldb/datafile/roll.dbf
roll_size = 128
main = +DMDATA/wldb/datafile/main.dbf
main_size = 128
ctl_path = +DMDATA/wldb/datafile/dm.ctl
ctl_size = 8
log_size = 256
dcr_path = /dev/raw/raw1
dcr_seqno = 0
auto_overwrite = 1

[DSC0]
config_path = /opt/dm8/dmdbms/data/dsc0_config
port_num = 5236
mal_host = 10.10.10.1
mal_port = 9340
log_path = +DMREDO/wldb/redolog/dsc0_log01.log
log_path = +DMREDO/wldb/redolog/dsc0_log02.log

[DSC1]
config_path = /opt/dm8/dmdbms/data/dsc1_config
port_num = 5236
mal_host = 10.10.10.2
mal_port = 9341
log_path = +DMREDO/wldb/redolog/dsc1_log01.log
log_path = +DMREDO/wldb/redolog/dsc1_log02.log

6.2初始化数据库

[dmdba@dm8-h1 data]$ dminit control=/opt/dm8/dmdbms/data/dminit.ini
initdb V8
db version: 0x7000b
file dm.key not found, use default license!
License will expire on 2021-09-04

 log file path: +DMREDO/wldb/redolog/dsc0_log01.log


 log file path: +DMREDO/wldb/redolog/dsc0_log02.log


 log file path: +DMREDO/wldb/redolog/dsc1_log01.log


 log file path: +DMREDO/wldb/redolog/dsc1_log02.log

write to dir [+DMDATA/data/wldb].
create dm database success. 2021-03-03 12:19:26

6.3启动数据库

注册服务,所有节点

/opt/dm8/dmdbms/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dm8/dmdbms/data/dsc0_config/dm.ini -dcr_ini /opt/dm8/dmdbms/data/dmdcr.ini -p dsc1 -y DmASMSvrServicedsc1.service
/opt/dm8/dmdbms/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dm8/dmdbms/data/dsc1_config/dm.ini -dcr_ini /opt/dm8/dmdbms/data/dmdcr.ini -p dsc2 -y DmASMSvrServicedsc2.service

启动服务,所有节点

systemctl status DmServicedsc1.service
systemctl start DmServicedsc1.service

6.4故障切换测试
负载均衡配置

vi /etc/dm_svc.conf

TIME_ZONE=(480)
LANGUAGE=(cn)
DSC=(192.168.3.171:5236,192.168.3.172:5236)

连接测试

disql SYSDBA/dameng1234@DSC
SQL> select * from v$dsc_ep_info;

LINEID     EP_NAME EP_SEQNO    EP_GUID              EP_TIMESTAMP         EP_MODE      EP_STATUS
---------- ------- ----------- -------------------- -------------------- ------------ ---------
1          DSC0    0           1491318494           1491319300           Control Node OK
2          DSC1    1           1491518737           1491519046           Normal Node  OK

used time: 11.952(ms). Execute id is 1.
SQL> select instance_name from v$instance;

LINEID     INSTANCE_NAME
---------- -------------
1          DSC1

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

模拟故障


[root@dm8-h2 ~]# ps -ef | grep dm.ini
dmdba    15410     1  1 12:40 ?        00:00:05 /opt/dm8/dmdbms/bin/dmserver /opt/dm8/dmdbms/data/dsc1_config/dm.ini DCR_INI=/opt/dm8/dmdbms/data/dmdcr.ini -noconsole
root     15858  8828  0 12:46 pts/0    00:00:00 grep --color=auto dm.ini
[root@dm8-h2 ~]# kill -9 15410
[root@dm8-h2 ~]# systemctl status DmServicedsc2.service 
● DmServicedsc2.service - Dameng Database Service(DmServicedsc2).
   Loaded: loaded (/usr/lib/systemd/system/DmServicedsc2.service; enabled; vendor preset: disabled)
   Active: failed (Result: signal) since Wed 2021-03-03 12:47:26 CST; 58s ago
  Process: 15895 ExecStop=/opt/dm8/dmdbms/bin/DmServicedsc2 stop (code=exited, status=0/SUCCESS)
  Process: 15376 ExecStart=/opt/dm8/dmdbms/bin/DmServicedsc2 start (code=exited, status=0/SUCCESS)
 Main PID: 15410 (code=killed, signal=KILL)

Mar 03 12:40:43 dm8-h2 systemd[1]: Starting Dameng Database Service(DmServicedsc2)....
Mar 03 12:40:45 dm8-h2 DmServicedsc2[15376]: Starting DmServicedsc2: connnect dmasmtool successfully.
Mar 03 12:41:00 dm8-h2 DmServicedsc2[15376]: [11B blob data]
Mar 03 12:41:00 dm8-h2 systemd[1]: Started Dameng Database Service(DmServicedsc2)..
Mar 03 12:47:26 dm8-h2 systemd[1]: DmServicedsc2.service: main process exited, code=killed, status=9/KILL
Mar 03 12:47:26 dm8-h2 DmServicedsc2[15895]: DmServicedsc2 service is stopped.
Mar 03 12:47:26 dm8-h2 systemd[1]: Unit DmServicedsc2.service entered failed state.
Mar 03 12:47:26 dm8-h2 systemd[1]: DmServicedsc2.service failed.

SQL> select instance_name from v$instance;
[-70065]:Connection exception, switch the current connection sucessful.

Server[192.168.3.171:5236]:mode is normal, state is open
SQL> select instance_name from v$instance;

LINEID     INSTANCE_NAME
---------- -------------
1          DSC0

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

LINEID     EP_NAME EP_SEQNO    EP_GUID              EP_TIMESTAMP         EP_MODE      EP_STATUS
---------- ------- ----------- -------------------- -------------------- ------------ ---------
1          DSC0    0           1491318494           1491319467           Control Node OK
2          DSC1    1           1491518737           1491519129           Normal Node  ERROR

used time: 5.379(ms). Execute id is 598.
SQL>

你可能感兴趣的:(国产数据库DM,数据库)