首先需要准备三个节点作为守护集群的主库、备库和监视器节点。
节点的基本信息如下:
用途 | IP | 操作系统 |
---|---|---|
主库节点 | 192.168.153.186 | KylinV10SP2 |
备库节点 | 192.168.153.198 | KylinV10SP2 |
监视器节点 | 192.168.153.200 | KylinV10SP2 |
我们需要在三节点上都安装达梦数据库软件,并在主库节点上初始化一个数据库实例,安装步骤如下:
1.关闭三台服务器防火墙:
systemctl status firewalld systemctl stop firewalld
2.关闭selinux
#临时关闭selinux
setenforce 0
#永久关闭selinux
vi /etc/selinux/config
#修改为SELINUX=disabled
#查看当前状态命令
getenforce
3.创建dmdba用户
# 创建用户组
groupadd dinstall
# 创建用户
useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
# 设置密码
passwd dmdba
4.创建达梦数据库软件安装路径
mkdir /dm8
# 更改文件夹所属
chown dmdba:dinstall /dm8
5.配置最大可打开文件数,不要小于65536
# 查看最大可打开文件数
ulimit -a
# 当前会话生效
ulimit -n 102400
# 永久生效
vi /etc/security/limits.conf
dmdba soft nofile 102400
dmdba hard nofile 102400
root soft nofile 102400
root hard nofile 102400
6.配置tmp目录空间大小不要小于3G
mount -o remount,size=3G /tmp
7.若为图形化机器,启用图形化
#root用户执行
xhost +
#切换dmdba用户执行
export DISPLAY=:0.0
8.安装达梦数据库软件和实例,注意搭建守护集群需要达梦数据库软件导入key文件,如果安装过程中没有key文件,后续导入key文件需要将key文件命名为dm.key传入安装目录的bin目录下
#dmdba用户执行
cd /mnt/dm
./DMInstall.bin
三个节点安装软件后,主节点需要安装一个数据库实例:选择安装目录,这里可以配置创建的/dm8目录,需要确保目录下为空:
配置数据库名和实例名:
配置数据库的页大小、簇大小等参数:
安装完数据库实例后,会提示需要使用root用户执行额外的命令启动数据库实例:
命令示例:
[root@localhost Desktop]# mv /home/dmdba/dmdbms/bin/DmServiceDMSERVER.service /usr/lib/systemd/system/DmServiceDMSERVER.service [root@localhost Desktop]# systemctl enable DmServiceDMSERVER.service Created symlink /etc/systemd/system/multi-user.target.wants/DmServiceDMSERVER.service \u2192 /usr/lib/systemd/system/DmServiceDMSERVER.service. [root@localhost Desktop]# systemctl start DmServiceDMSERVER.service [root@localhost Desktop]# systemctl restart DmServiceDMSERVER.service
9.安装数据守护集群
上面已经在主库节点安装了数据库DM01实例DMSVR01,接下来需要将主库数据库备份到备库机器上:
#dmdba用户主库上执行
./DmServiceDMSERVER stop
./dmrman
backup database '/dm8/data/DM01/dm.ini' backupset '/dm8/backup';
scp backup.* dmdba@192.168.153.198:/dm8/backup
如果在backup时提示,可能由于DMAP服务被停止了,需要先启动DMAP:
./DmAPService start
配置主库的dm.ini,dmmal.ini,dmwatcher.ini,dmarch.ini文件
# vi dmmal.ini
MAL_CHECK_INTERVAL= 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME =DMSVR01
MAL_HOST = 192.168.153.186
MAL_PORT = 15236
MAL_INST_HOST = 192.168.153.186
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.153.198
MAL_PORT = 15236
MAL_INST_HOST = 192.168.153.198
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT =45101
# vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
# vi dmwatcher.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/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
# vi dm.ini
#修改四个值
MAL_INI = 1
ARCH_INI = 1
ALTER_MODE_STATUS= 0
ENABLE_OFFLINE_TS= 2
将主库数据库启动到mount状态:
#dmdba用户执行
./dmserver /dm8/data/DAMENG/dm.ini mount
初始化备库实例:
#dmdba用户执行
./dminit db_name=DM01 instance_name=DMSVR02 path=/dm8/data SYSDBA_PWD=xxxxxx SYSAUDITOR_PWD=xxxxxx SYSSSO_PWD=xxxxxx
还原备库:
#dmdba用户执行
./dmrman
restore database '/dm8/data/DM01/dm.ini' from backupset'/dm8/backup';
recover database '/dm8/data/DM01/dm.ini' from backupset'/dm8/backup';
recover database '/dm8/data/DM01/dm.ini' update db_magic;
配置备库的dm.ini,dmmal.ini,dmwatcher.ini,dmarch.ini 文件
#vi dmmal.ini
MAL_CHECK_INTERVAL= 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME =DMSVR01
MAL_HOST = 192.168.153.186
MAL_PORT = 15236
MAL_INST_HOST = 192.168.153.186
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.153.198
MAL_PORT = 15236
MAL_INST_HOST = 192.168.153.198
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT =45101
#vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
#vi dmwatcher.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/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
#vi dm.ini
#修改如下四个配置
MAL_INI = 1
ARCH_INI = 1
ALTER_MODE_STATUS= 0
ENABLE_OFFLINE_TS= 2
启动备库到mount状态
#dmdba用户下执行
./dmserver /dm8/data/DM01/dm.ini mount
修改主库oguid和数据库模式为主库
#dmdba用户下执行
./disql
SQL> sp_set_oguid(8888);
SQL> alter database primary;
修改备库的oguid和修改数据库模式为备库
#dmdba用户下执行
./disql
SQL> sp_set_oguid(8888);
SQL> alter database standby;
启动主库和备库的守护进程
#dmdba用户下执行,主库备库节点都需要运行
./dmwatcher /dm8/data/DM01/dmwatcher.in
配置监视器
#vi dmmonitor.ini
MON_DW_CONFIRM = 0
MON_LOG_PATH = /dm8/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID= 8888
MON_DW_IP = 192.168.153.186:65101
MON_DW_IP = 192.168.153.198:65101
登录监视器
./dmmonitor /dm8/data/dmmonitor.ini
如果出现如下提示,需要手动重启一下数据库服务
将备库的数据库服务和守护进程注册到操作系统:
#root用户执行,备库
./dm_service_installer.sh -t dmserver -p DMSVR02 -dm_ini /dm8/data/DM01/dm.ini
#root用户执行,主库、备库
./dm_service_installer.sh -t dmwatcher -p DMSVR01 -watcher_ini /dm8/data/DM01/dmwatcher.ini
./dm_service_installer.sh -t dmwatcher -p DMSVR02 -watcher_ini /dm8/data/DM01/dmwatcher.ini
文章
阅读量
获赞