达梦数据守护集群搭建全攻略(详细图文版)
一、引言
在高可用性数据库架构中,数据守护集群是保障业务连续性的核心方案。本文将基于达梦数据库 8.1 版本,详细讲解如何通过冷备 + 实时归档方式搭建主备守护集群,实现自动故障切换与数据同步。
二、环境准备
硬件要求
2 台物理服务器(主库:192.168.240.101,备库:192.168.240.102,监视器:182.168.240.103)
千兆网络连通性
统一时钟源(建议 NTP 同步)
软件安装
达梦数据库 8.1 企业版
操作系统:麒麟V10
三、核心配置步骤
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld
SQL> alter database mount;
SQL> alter database noarchivelog;
SQL> alter database open;
./DmServiceDMSERVER stop
./dmrman
RMAN> backup database '/dm8/data/DAMENG/dm.ini' backupset '/dm8/data/DAMENG/backup';
dmmal.ini(主备机通用配置)
ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSERVER
MAL_HOST = 192.168.240.101
MAL_PORT = 15236
MAL_INST_HOST = 192.168.240.101
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSERVER2
MAL_HOST = 192.168.240.102
MAL_PORT = 15236
MAL_INST_HOST = 192.168.240.102
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
dmarch.ini(主库专用)
ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER2
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
dmwatcher.ini(主备机通用)
ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 8888
INST_INI = /dm8/data/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
dm.ini(关键参数修改)
ini
MAL_INI = 1
ARCH_INI = 1
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
./dminit db_name=DAMENG instance_name=DMSERVER2 path=/dm8/data SYSDBA_PWD="Dameng123"
./dmrman
RMAN> restore database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/backup';
RMAN> recover database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/backup';
RMAN> recover database '/dm8/data/DAMENG/dm.ini' update db_magic;
dmarch.ini(备库专用)
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER
-- 主库执行
SQL> sp_set_oguid(8888);
SQL> alter database primary;
-- 备库执行
SQL> sp_set_oguid(8888);
SQL> alter database standby;
服务注册(root 用户)
/dm8/script/root/dm_service_installer.sh -t dmwatcher -p DMSERVER -watcher_ini /dm8/data/DAMENG/dmwatcher.ini
/dm8/script/root/dm_service_installer.sh -t dmwatcher -p DMSERVER2 -watcher_ini /dm8/data/DAMENG/dmwatcher.ini
/dm8/script/root/dm_service_installer.sh -t dmmonitor -p MONITOR -monitor_ini /dm8/data/dmmonitor.ini
systemctl start DmWatcherServiceDMSERVER
systemctl start DmWatcherServiceDMSERVER2
systemctl start DmMonitorServiceMONITOR
./dmmonitor /dm8/data/dmmonitor.ini
DMMONITOR> login sysdba/Dameng123
DMMONITOR> show
主库状态
SQL> select status$ from v$instance;
PRIMARY
备库状态
SQL> select status$ from v$instance;
STANDBY
检查 MAL 端口(15236)和守护端口(65101)是否开放
使用 telnet 验证节点间连通性
确保所有节点配置文件中的 INST_OGUID 一致
通过sp_set_oguid()动态修改
检查归档目录权限(建议属主为 dmdba:dinstall)
确认 dmarch.ini 配置正确
通过本文的步骤,您可以快速搭建达梦数据守护集群,实现自动故障切换和数据同步。建议定期进行故障演练,确保集群在生产环境中的高可用性。
文章
阅读量
获赞