三台虚拟机(主机、备机、监视器),情况如下:
主 机IP:192.168.88.110,安装达梦数据库及实例
备 机IP:192.168. 88.111,只安装达梦数据库即可
监视器IP:192.168. 88.112,只安装达梦数据库即可
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
DM01 DMSVR01 5236 45101 192.168.88.110 55101 65101
DM01 DMSVR02 5236 45121 192.168.88.111 55121 65121
搭建过程如下:
一、关闭主机、备机、监视器防火墙【root用户】
systemctl stop firewalld.service //停止防火墙
systemctl disable firewalld.service //设置服务不重新自启动
systemctl status firewalld.service //查看防火墙服务状态
二、数据库备份还原
1、设置归档(如已经设置归档,则跳过)
2、主库数据库备份【dmrman】注意:dm08前面的/不能忘记
backup database '/dm8/data/DM01/dm.ini’ backupset ’/dm8/ backup /fullbackup02’
3、拷贝主库备份文件到备库【scp命令】
scp -r fullbackup02 dmdba@192.168.88.111:/dm8/backup/fullbackup02
如备机中无相关目录,先建目录
4、备库数据库还原【dmrman】
RMAN>restore database to ‘/dm8/data/DM01’ from backupset ‘/dm8/backup/fullbackup02’;
RMAN>recover database ‘/dm8/data/DM01/dm.ini’ update db_magic;
三、配置主库【配置文件样例目录:/dm8/samples/ini_script/UTF-8】
1、dm.ini配置文件【/dm8/data/DM01/dm.ini】
INSTANCE_NAME = DMSVR01
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 配置文件【/dm8/data/DM01/ dmmal.ini】
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 192.168.88.110
MAL_PORT = 55101
MAL_INST_HOST = 192.168.88.110
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.88.111
MAL_PORT = 55121
MAL_INST_HOST = 192.168.88.111
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
3、dmarch.ini配置文件【/dm8/data/DM01/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
4、dmwatcher.ini 配置文件【/dm8/data/DM01/ dmwatcher.ini】
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 888888
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
5、主库启动及相关设置
1)主库启动到mount状态,dmdba用户
/dm8/bin/dmserver /dm8/data/DM01/dm.ini mount
2)设置数据库主库模式及修改OGUID,使用disql
SQL>alter database primary;
SQL>SP_SET_PARA_VALUE(1, ' ALTER_MODE_STATUS ' ,1) ;
SQL>sp_set_oguid(888888) ;
SQL> SP_SET_PARA_VALUE(1, ' ALTER_MODE_STATUS ' ,0) ;
修改主机的 OGUID 为 888888,并修改主机为 Primary 模式
四、拷贝主库配置文件到备库【dmdba用户,scp命令】
scp dm.ini dmdba@192.168.88.111:/dm8/data/DM01/dm.ini
scp dmmal.ini dmdba@192.168.88.111:/dm8/data/DM01/ dmmal.ini
scp dmarch.ini dmdba@192.168.88.111:/dm8/data/DM01/ dmarch.ini
scp dmwatcher.ini dmdba@192.168.88.111:/dm8/data/DM01/dmwatcher.ini
五、配置备库【需要修改的地方不多】
1、dm.ini配置文件
INSTANCE_NAME = DMSVR02 #【只需修改此处】
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 配置文件(与主库配置完全一样)
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL =
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 192.168.88.110
MAL_PORT = 55101
MAL_INST_HOST = 192.168.88.110
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.88.111
MAL_PORT = 55121
MAL_INST_HOST = 192.168.88.111
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
3、dmarch.ini配置文件【/dm8/data/DM01/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
4、dmwatcher.ini 配置文件(与主库配置完全一样)
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 888888
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
5、备库启动及相关设置
1)主机启动到mount状态,dmdba用户
/dm8/bin/dmserver /dm8/data/DM01/dm.ini mount
2)设置数据库主库模式及修改OGUID,使用disql
SQL>alter database standby;
SQL>SP_SET_PARA_VALUE(1, ' ALTER_MODE_STATUS ' ,1) ;
SQL>sp_set_oguid(888888) ;
SQL> SP_SET_PARA_VALUE(1, ' ALTER_MODE_STATUS ' ,0) ;
修改主机的 OGUID 为 888888,并修改主机为 standby模式
六、启动主库、备库守护进程
1、启动主库守护进程【dmdba用户】
/dm8/bin/dmwatcher /dm8/data/DM01/dmwatcher.ini
2、启动备库守护进程【dmdba用户】
/dm8/bin/dmwatcher /dm8/data/DM01/dmwatcher.ini
七、配置监视器
注意:监视器中的 OGUID 要与数据库设置的一致。
监视器命令:
Show --------------查看
login --------------登录
switchover --------------转换
1、配置dmmonitor.ini 【/dm8/data/dmmonitor.ini】
MON_DW_CONFIRM = 1 #1:确认监视器,0:非确认监视器
MON_LOG_PATH = /dm8/log #目录一定要存在
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 888888
MON_DW_IP = 192.168.88.110: 65101 #主库地址:MAL_PORT
MON_DW_IP = 192.168.88.111: 65121 #备库地址:MAL_PORT
2、新建/dm8/log目录
3、启动监视器:/dm8/bin/dmmonitor /dm8/data/dmmonitor.ini
show 显示监视情况
八、实时主备集群关闭顺序
1、关闭监视器:如果启动了确认监视器:确认监视器中exit即可
2、关闭主库守护进程:watch中,exit
3、关闭备库守护进程:watch中,exit
4、关闭主库实例:disql中,shutdown immediate;
5、关闭备库实例:disql中,shutdown immediate;
九、 主库、备库、监视器注册数据库守护、实例为 Linux 系统服务【需root用户】
1、主库
[root@KylinDCA02 root]# ./dm_service_installer.sh -t dmwatcher -p DW01 -watcher_ini
/dm8/data/DM01/dmwatcher.ini
2、备库
[root@KylinDCA02 root]# ./dm_service_installer.sh -t dmserver -p DMSVR02 -dm_ini /dm8/data/DM01/dm.ini
[root@KylinDCA02 root]# ./dm_service_installer.sh -t dmwatcher -p DW02 -watcher_ini
/dm8/data/DM01/dmwatcher.ini
3、监视器注册
[root@KylinDCA02 root]# ./dm_service_installer.sh -t dmmonitor -p DMMON -monitor_ini
/dm8/data/ dmmonitor.ini
文章
阅读量
获赞