国产数据库-达梦
- 一、环境详情
- 二、Centos7 参数优化(所有节点)
- 三、创建用户(所有节点)
- 四、开始安装(所有节点)
- 五、服务注册启动
当前安装:在指定版本环境下 测试,仅供参考
- 官网描述:
达梦数据守护集群软件(DM Data Watch)是一种集成化的高可靠性解决方案,该方案基于数据库REDO日志,不依赖于第三方软件和存储,用于解决由于硬件故障、自然灾害等原因导致的数据库服务长时间中断问题,提供不间断数据库服务,可同时满足用户对数据安全性和高可用性的要求。数据守护包含的主要部件有:主数据库、备数据库、联机REDO日志系统、本地REDO日志归档服务、实时REDO日志归档服务、REDO日志重做服务、MAL系统、守护进程和监视器。其中,守护进程和监视器是两个独立的工具,其他部件集成在DM8数据库服务器DMSERVER中。- 实时监控:
达梦数据守护能够提供主备机切换、备机接管、应用自动重连、自动同步历史数据功能,通过监控工具DMWMON,可实时监控主、备数据库的状态和数据同步情况。
一、环境详情
-
软件版本
软件 版本 下载地址 Centos 7 CentOS Linux release 7.9.2009 (Core) x86 清华镜像站: link 达梦数据库 dm8_20230418_x86_rh6_64.zip 官网: link -
节点分配
如有需要还可以多配置一个副监视器(node4),部署方式和node3一致节点 IP 角色 数据库名 实例名 port mal inst_dw_port mal dw_port node1 192.168.162.221 主机 DM01 DMSERVER01 5236 45101 65101 node2 192.168.162.222 备机 DM01 DMSERVER02 5236 45101 65101 node3 192.168.162.223 主监视器
二、Centos7 参数优化(所有节点)
- 关闭防火墙
可以设置防火墙开放 5236 端口,或者直接关闭防火墙,这里选择直接关闭。
- 关闭防火墙:
systemctl stop firewalld
- 禁止开机自启:
systemctl disable firewalld
-
修改系统最大进程数和最大文件打开数
vim /etc/security/limits.conf修改以下内容: * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
-
修改进程数据限制
vim /etc/security/limits.d/90-nproc.conf 修改以下内容: * soft nproc 1024 * soft nproc 2048
查看优化信息
ulimit -a
三、创建用户(所有节点)
-
登录 root 创建 mss 用户
groupadd mss useradd -m -d /home/mss mss -g mss passwd mss123456
-
创建目录
登录 mss 用户# 创建安装目录 mkdir /home/mss/dm8 # 创建镜像目录 mkdir /home/mss/dm8/iso
四、开始安装(所有节点)
-
上传镜像
上传镜像文件(dm8_20230418_x86_rh6_64.iso)到 /home/mss/dm8 下 -
挂载镜像
切换 root 用户mount /home/mss/dm8/dm8_20230418_x86_rh6_64.iso /home/mss/dm8/iso/ # 查看是否挂载 df -h
授权 mss 用户目录权限
chown -R mss:mss /home/mss
-
创建其它文件夹
切换 mss 用户cd /home/mss/dm8 mkdir install
-
执行安装
cd /home/mss/dm8/iso ./DMInstall.bin -i
选择典型安装-1,安装路径 /home/mss/dm8/install
安装完成提示:
数据库安装完成后,需要切换至 root 用户执行上图中的命令 root_installer.sh 创建 DmAPService,否则会影响数据库备份。
su root cd /home/mss/dm8/install/script/root ./root_installer.sh
-
创建实例
切换 mss 用户
注: 关于这些参数说明可进入安装目录的bin下,执行./dminit help
case_sensitive :字符串比较大小写敏感,默认开启1(区分大小写),设置为 0 则不区分大小写在 node1 创建实例一:
cd /home/mss/dm8/install/bin ./dminit path=/home/mss/dm8/data DB_NAME=DM01 INSTANCE_NAME=DBSERVER01 CASE_SENSITIVE=0 PORT_NUM=5236 SYSDBA_PWD=casic123456 SYSAUDITOR_PWD=casic123456 PAGE_SIZE=32 EXTENT_SIZE=32 CHARSET=1 LOG_SIZE=500
在 node2 创建实例二:
cd /home/mss/dm8/install/bin ./dminit path=/home/mss/dm8/data DB_NAME=DM01 INSTANCE_NAME=DBSERVER02 CASE_SENSITIVE=0 PORT_NUM=5236 SYSDBA_PWD=casic123456 SYSAUDITOR_PWD=casic123456 PAGE_SIZE=32 EXTENT_SIZE=32 CHARSET=1 LOG_SIZE=500
在 node3 创建监视器:
cd /home/mss/dm8/install/bin ./dminit path=/home/mss/dm8/data DB_NAME=DM01
-
配置实例参数
切换 mss 用户配置 node1 实例一:------------------------------------------------------------------
cd /home/mss/dm8/data/DM01
(1)配置dm.ini
INSTANCE_NAME =DBSERVER01 PORT_NUM = 5236 DW_INACTIVE_INTERVAL = 60 #不允许手工方式修改实例模式/状态/OGUID ALTER_MODE_STATUS = 0 #不允许备库 OFFLINE 表空间 ENABLE_OFFLINE_TS = 2 #打开 MAL 系统 MAL_INI = 1 #打开归档配置 ARCH_INI = 1 #统计最近 64 次的日志重演信息 RLOG_SEND_APPLY_MON = 64
(2)新建dmmal.ini
#配置上端口规划中规划的各端口参数: #PORT_NUM、MAL_INST_DW_PORT、MAL_DW_PORT #[MAL_INST1]中填写主机的、 #[MAL_INST2]中填写备机的MAL_CHECK_INTERVAL = 5 MAL_CONN_FAIL_INTERVAL = 5[MAL_INST1] MAL_INST_NAME = DBSERVER01 MAL_HOST = 192.168.162.221 MAL_PORT = 55101 MAL_INST_HOST = 192.168.162.221 MAL_INST_PORT = 5236 MAL_DW_PORT = 65101 MAL_INST_DW_PORT = 45101[MAL_INST2] MAL_INST_NAME = DBSERVER02 MAL_HOST = 192.168.162.222 MAL_PORT = 55101 MAL_INST_HOST = 192.168.162.222 MAL_INST_PORT = 5236 MAL_DW_PORT = 65101 MAL_INST_DW_PORT = 45101
(3)新建dmarch.ini
[ARCHIVE_REALTIME] ARCH_TYPE = REALTIME ARCH_DEST =DBSERVER02[ARCHIVE_LOCAL1] ARCH_TYPE = LOCAL ARCH_DEST = /home/mss/dm8/data/DM01/arch ARCH_FILE_SIZE = 128 ARCH_SPACE_LIMIT = 0
(4)新建dmwatcher.ini
[GRP1] DW_TYPE = GLOBAL DW_MODE = AUTO DW_ERROR_TIME = 10 INST_RECOVER_TIME = 60 INST_ERROR_TIME = 10 INST_OGUID = 453331 INST_INI = /home/mss/dm8/data/DM01/dm.ini INST_AUTO_RESTART = 1 INST_STARTUP_CMD = /home/mss/dm8/install/bin/dmserver RLOG_SEND_THRESHOLD = 0 RLOG_APPLY_THRESHOLD = 0
配置 node2 实例二:------------------------------------------------------------------
cd /home/mss/dm8/data/DM01
(1)配置dm.ini
INSTANCE_NAME = DBSERVER02 PORT_NUM = 5236 DW_INACTIVE_INTERVAL = 60 ALTER_MODE_STATUS = 0 ENABLE_OFFLINE_TS = 2 MAL_INI = 1 ARCH_INI = 1 RLOG_SEND_APPLY_MON = 64
(2)新建dmmal.ini
#配置上端口规划中规划的各端口参数: #PORT_NUM、MAL_INST_DW_PORT、MAL_DW_PORT #[MAL_INST1]中填写主机的、 #[MAL_INST2]中填写备机的MAL_CHECK_INTERVAL = 5 MAL_CONN_FAIL_INTERVAL = 5[MAL_INST1] MAL_INST_NAME = DBSERVER01 MAL_HOST = 192.168.162.221 MAL_PORT = 55101 MAL_INST_HOST = 192.168.162.221 MAL_INST_PORT = 5236 MAL_DW_PORT = 65101 MAL_INST_DW_PORT = 45101[MAL_INST2] MAL_INST_NAME = DBSERVER02 MAL_HOST = 192.168.162.222 MAL_PORT = 55101 MAL_INST_HOST = 192.168.162.222 MAL_INST_PORT = 5236 MAL_DW_PORT = 65101 MAL_INST_DW_PORT = 45101
(3)新建dmarch.ini
[ARCHIVE_REALTIME] ARCH_TYPE = REALTIME ARCH_DEST =DBSERVER01[ARCHIVE_LOCAL1] ARCH_TYPE = LOCAL ARCH_DEST = /home/mss/dm8/data/DM01/arch ARCH_FILE_SIZE = 128 ARCH_SPACE_LIMIT = 0
(4)新建dmwatcher.ini
[GRP1] DW_TYPE = GLOBAL DW_MODE = AUTO DW_ERROR_TIME = 10 INST_RECOVER_TIME = 60 INST_ERROR_TIME = 10 INST_OGUID = 453331 INST_INI = /home/mss/dm8/data/DM01/dm.ini INST_AUTO_RESTART = 1 INST_STARTUP_CMD = /home/mss/dm8/install/bin/dmserver RLOG_SEND_THRESHOLD = 0 RLOG_APPLY_THRESHOLD = 0
配置 node3 监视器:------------------------------------------------------------------
cd /home/mss/dm8/data/DM01
(1)新建dmmonitor.ini
# 0表示普通监视器 ,最多配置8个,1 确认监视器模式 MON_DW_CONFIRM = 1 MON_LOG_PATH = /home/mss/dm8/install/log # 每隔 60s 定时记录系统信息到日志文件 MON_LOG_INTERVAL = 60 # 每个日志文件最大 32M MON_LOG_FILE_SIZE = 32 # 不限定日志文件总占用空间 MON_LOG_SPACE_LIMIT = 0[GRP1] #组 GRP1 的唯一OGUID 值 MON_INST_OGUID = 453331 ##dmmal.ini####MAL_HOST:MAL_DW_PORT################### MON_DW_IP = 192.168.162.221:65101 MON_DW_IP = 192.168.162.222:65101
-
**备份主机数据库 node1 **
登录 node1 服务器su mss cd /home/mss/dm8/install/bin/ # 初始化 ./dmserver /home/mss/dm8/data/DM01/dm.ini #如果dmap没启动执行以下命令 ./dmap#执行备份 ./dmrman CTLSTMT="BACKUP DATABASE '/home/mss/dm8/data/DM01/dm.ini' FULL TO fullbak01 BACKUPSET '/home/mss/dm8/backup/fullbak01'" 拷贝221备份文件到222 scp -r /home/mss/dm8/backup mss@192.168.162.222:/home/mss/dm8/
-
**在备份机还原数据库 node2 **
登录 node2 服务器su mss cd /home/mss/dm8/install/bin/#如果dmap没启动执行以下命令 ./dmap./dmrman CTLSTMT="RESTORE DATABASE '/home/mss/dm8/data/DM01/dm.ini' FROM BACKUPSET '/home/mss/dm8/backup/fullbak01'" ./dmrman CTLSTMT="RECOVER DATABASE '/home/mss/dm8/data/DM01/dm.ini' FROM BACKUPSET '/home/mss/dm8/backup/fullbak01'" ./dmrman CTLSTMT="RECOVER DATABASE '/home/mss/dm8/data/DM01/dm.ini' UPDATE DB_MAGIC"```
-
主机与备机分别以mount方式启动数据库
在 node1、node2 分别执行以下命令cd /home/mss/dm8/install/bin/ #如果dmap没启动执行以下命令 ./dmap ./dmserver /home/mss/dm8/data/DM01/dm.ini mount./disql SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1); SQL> SP_SET_OGUID(453331); SQL> ALTER DATABASE PRIMARY; SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
-
启动测试服务
(1) node1 221 机器:cd /home/mss/dm8/install/bin/ ./dmserver /home/mss/dm8/data/DM01/dm.ini mount ./dmwatcher /home/mss/dm8/data/DM01/dmwatcher.ini
(2) node1 222 机器:cd /home/mss/dm8/install/bin/ ./dmserver /home/mss/dm8/data/DM01/dm.ini mount ./dmwatcher /home/mss/dm8/data/DM01/dmwatcher.ini
(3) node3 223 机器:
cd /home/mss/dm8/install/bin/ ./dmmonitor /home/mss/dm8/data/DM01/dmmonitor.ini
五、服务注册启动
-
进行服务注册
切换 root 用户
(1)node1 221 机器 实例一su root cd /home/mss/dm8/install/script/root ./dm_service_installer.sh -p DMSERVER -t dmserver -dm_ini /home/mss/dm8/data/DM01/dm.ini ./dm_service_installer.sh -p dmwatcher -t dmwatcher -watcher_ini /home/mss/dm8/data/DM01/dmwatcher.ini
(2)node2 222 机器 实例二
su root cd /home/mss/dm8/install/script/root ./dm_service_installer.sh -p DMSERVER -t dmserver -dm_ini /home/mss/dm8/data/DM01/dm.ini ./dm_service_installer.sh -p dmwatcher -t dmwatcher -watcher_ini /home/mss/dm8/data/DM01/dmwatcher.ini
(3)node3 223 机器 监测
su root cd /home/mss/dm8/install/script/root ./dm_service_installer.sh -p dmmonitor -t dmmonitor -monitor_ini /home/mss/dm8/data/DM01/dmmonitor.ini
//注释: 此命令为删除服务:./dm_service_uninstaller.sh -n DmServiceDMSERVER
-
启停数据库命令
(1)node1 221 机器 实例一systemctl start DmServiceDMSERVER.service systemctl stop DmServiceDMSERVER.service systemctl restart DmServiceDMSERVER.service systemctl status DmServiceDMSERVER.service
(2)node2 222 机器 实例二
systemctl start DmServiceDMSERVER.service systemctl stop DmServiceDMSERVER.service systemctl restart DmServiceDMSERVER.service systemctl status DmServiceDMSERVER.service
(3)node3 223 机器 监视器
systemctl status DmMonitorServicedmmonitor.service systemctl start DmMonitorServicedmmonitor.service
-
连接数据库
账户:SYSDBA
密码:SYSDBA