主备集群的搭建
1.准备工作
关闭防火墙-主备和监视节点都要
systemctl stop firewalld
systemctl disable firewalld
检查运行资源限制
[root@PAI-I-01 ~]# vim /etc/security/limits.conf
添加参数
dmdba soft nproc 16384
dmdba hard nproc 16384
dmdba soft nofile 16384
dmdba hard nofile 65536
dmdba soft stack 16384
dmdba hard stack 32768
备库上添加目录(dmdba)
mkdir -p /dm8/backup/full2 /dm8/arch
2.在主备库上新建实例
./dminit path=/dm8/data db_name=DM01 instance_name=DMSVR02 port_num=5236 page_size=16 extent_size=32 log_size=500 sysdba_pwd=DM01SYSDBA sysauditor_pwd=DM01SYSDBA case_sensitive=y
3.主库停止服务
主库 dmrman备份
backup database '/dm8/data/DM01/dm.ini' backupset'/dm8/backup/'
把备份拷贝到备库
备库dmrman还原
restore database '/dm8/data/DM01/dm.ini' from backupset '/dm8/backup/'
recover database '/dm8/data/DM01/dm.ini' with archivedir '/dm8/arch'
recover database '/dm8/data/DM01/dm.ini' update db_magic;
4.修改主备dm.ini文件配置
ARCH_INI=1
MAL_INI=1
ALTER_MODE_STATUS=0
ENABLE_OFFLINE_TS=2
5.在/dm8/data/DM01下创建文件
dmarch.ini
主库添加
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR02
备库新建
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 1024
ARCH_SPACE_LIMIT = 0
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR01
dmmal.ini
主备一样
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 192.168.10.10
MAL_PORT = 55101
MAL_INST_HOST = 192.168.10.10
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.10.10
MAL_PORT = 55121
MAL_INST_HOST = 192.168.10.10
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
dmwatcher.ini
主备一样
[GRP1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = AUTO #自动切换模式
DW_ERROR_TIME = 10 #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #主库守护进程启动恢复的间隔时间
INST_ERROR_TIME = 10 #本地实例故障认定时间
INST_OGUID = 77777777 #守护系统唯一 OGUID 值(这里要和数据库的
OGUID 一致,OGUID 是写入控制文件的)
INST_INI = /dm8/data/DM01/dm.ini #dm.ini 配置文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /dm8/bin/dmserver #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阀值,默认关
闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阈值,默认关闭
在主库设置dmmonitor.ini
MON_LOG_PATH = /dm8/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 64
MON_LOG_SPACE_LIMIT = 0
MON_DW_CONFIRM = 1
[GRP1]
MON_INST_OGUID = 7777777
MON_DW_IP = 192.168.10.10:65101
MON_DW_IP = 192.168.10.10:65121
6.服务配置
Root下注册
主库
./dm_service_installer.sh -t dmserver -p DMSVR01 -dm_ini /dm8/data/DM01/dm.ini
./dm_service_installer.sh -t dmwatcher -p DMSVR01 -watcher_ini /dm8/data/DM01/dmwatcher.ini
备库
./dm_service_installer.sh -t dmserver -p DMSVR02 -dm_ini /dm8/data/DM01/dm.ini
./dm_service_installer.sh -t dmwatcher -p DMSVR02 -watcher_ini /dm8/data/DM01/dmwatcher.ini
7.主备启动服务
./dmserver /dm8/data/DM01/dm.ini mount
./dmserver /dm8/data/DM01/dm.ini mount
8.主备通过disql登录
./disql SYSDBA/DM01SYSDBA:5236
主库执行:
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',1);
sp_set_oguid(7777777);
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',0);
alter database primary;
备库执行:
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',1);
sp_set_oguid(7777777);
SP_SET_PARA_VALUE(1,'ALTER_MODE_STATUS',0);
alter database standby;
9.主备启动达梦守护
./DmWatcherServiceDMSVR01 start
./DmWatcherServiceDMSVR02 start
10.主节点启动监视器
./dmmonitor path=/dm8/data/DM01/dmmonitor.ini
11.先退出监视器再退出dmwatch,最后退出服务 ,先主后备
12.用后台方式启动服务,守护,先主后备
主
./DmServiceDMSVR01 start
./DmWatcherServiceDMSVR01 start
备
./DmServiceDMSVR02 start
./DmWatcherServiceDMSVR02 start
13.配置监视节点(和上面的一样)
mkdir -p /dm8/data/DM01 /dm8/log
MON_LOG_PATH = /dm8/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 64
MON_LOG_SPACE_LIMIT = 0
MON_DW_CONFIRM = 1
[GRP1]
MON_INST_OGUID = 20240801
MON_DW_IP = 192.168.10.10:65101
MON_DW_IP = 192.168.10.10:65121
在/dm8/bin下启动
./dmmonitor path=/dm8/data/DM01/dmmonitor.ini
14.主备切换
文章
阅读量
获赞