数据库
首页 > 数据库> > 达梦8数据守护主备集群搭建(类似于Oracle的DataGuard)

达梦8数据守护主备集群搭建(类似于Oracle的DataGuard)

作者:互联网

一、环境
主机:192.168.190.128
备机:192.168.190.129
监视器:192.168.190.130

数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
DMDW DMDW01 5246 45101 192.168.190.128 55101 65101
DMDW DMDW02 5246 45121 192.168.190.129 55121 65121

要求:
1、数据名要求一样,实例名不一样
2、主备机的时间(监护器机器的时候最好也一致,否则监视的时候会出现问题)要求一致,不能超过5分钟
3、关闭SELINUX和防火墙


二、初始化实例
1、创建主备机的实例
$/dm8/tool/dbca

三、主库进行全备
#systemctl stop DmServiceDMDW01.service
#su - dmdba
$/dm8/bin/dmrman CTLSTMT="BACKUP DATABASE '/dm8/data/DMDW/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'"
$scp /dm8/backup/BACKUP_FILE_01/*.* 192.168.190.129:/dm8/backup

四、备库进行恢复
#systemctl stop DmServiceDMDW02.service
#su - dmdba
$/dm8/bin/dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/DMDW/dm.ini' FROM BACKUPSET '/dm8/backup'"
$/dm8/bin/dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DMDW/dm.ini' FROM BACKUPSET '/dm8/backup'"
$/dm8/bin/dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DMDW/dm.ini' UPDATE DB_MAGIC"

五、配置相关文件(/dm8/data/DMDW目录下)
修改dm.ini,并配置dmmal.ini、dmarch.ini、dmwatcher.ini文件

1、primary主机配置

dm.ini
------
INSTANCE_NAME = DMDW01
PORT_NUM = 5246
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64


dmmal.ini
---------
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMDW01
MAL_HOST = 192.168.190.128
MAL_PORT = 55101
MAL_INST_HOST = 192.168.190.128
MAL_INST_PORT = 5246
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMDW02
MAL_HOST = 192.168.190.129
MAL_PORT = 55121
MAL_INST_HOST = 192.168.190.129
MAL_INST_PORT = 5246
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121

dmarch.ini
----------
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMDW02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

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 = /dm8/data/DMDW/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

启动主库
$/dm8/bin/dmserver /dm8/data/DMDW/dm.ini mount

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);


2、standby备机配置
dm.ini
------
INSTANCE_NAME = DMDW02
PORT_NUM = 5246
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64

dmmal.ini
---------
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMDW01
MAL_HOST = 192.168.190.128
MAL_PORT = 55101
MAL_INST_HOST = 192.168.190.128
MAL_INST_PORT = 5246
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMDW02
MAL_HOST = 192.168.190.129
MAL_PORT = 55121
MAL_INST_HOST = 192.168.190.129
MAL_INST_PORT = 5246
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121

dmarch.ini
----------
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMDW01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

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 = /dm8/data/DMDW/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0

以 Mount 方式启动备库
$/dm8/bin/dmserver /dm8/data/DMDW/dm.ini mount
$/dm8/bin/disql sysdba/dameng123@localhost:5246
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>alter database standby;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);


3、分别启动主备机的监视进程,系统会自动把主备库修改到OPEN状态
$/dm8/bin/dmwatcher /dm8/data/DMDW/dmwatcher.ini

4、dmmonitor监视器配置(此机器只需要安装数据库软件,不需要初始化实例,只能有一个确认监视器,可以有多个非确认监视器)
$vi /dm8/dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.190.128:65101
MON_DW_IP = 192.168.190.129:65121

启动监视器
$/dm8/bin/dmmonitor /dm8/dmmonitor.ini
五、将实例服务、数据守护和监视服务注册到操作系统中(实现操作系统启动后自动启动)
#/dm8/script/root/dm_service_installer.sh -t dmserver -p DMDW01 -m mount -dm_ini /dm8/data/DMDW/dm.ini (主库若执行了实例创建则默认会注册此服务,不需要再注册此服务了)
#/dm8/script/root/dm_service_installer.sh -t dmserver -p DMDW02 -m mount -dm_ini /dm8/data/DMDW/dm.ini (备库若执行了实例创建则默认会注册此服务,不需要再注册此服务了)
#/dm8/script/root/dm_service_installer.sh -t dmwatcher -p DMWATCHER -watcher_ini /dm8/data/DMDW/dmwatcher.ini
#/dm8/script/root/dm_service_installer.sh -t dmmonitor -p DMMONITOR -monitor_ini /dm8/dmmonitor.ini


六、监视器常用命令(在监视器的控制台上输入)
show:查询基本信息
login:登录监视器(sysdba登录)
switchover:主备切换
exit:退出监视器

七、实时主备集群重启顺序:
1、关闭监视器
2、关闭主库守护进程
3、关闭备库守护进程
4、关闭主库实例
5、关闭备库实例
6、启动主库实例 (mount)
7、启动备库实例 (mount)
8、启动主库守护进程 (open)
9、启动备库守护进程 (open)
10、启动监视器
监视器:监控数据守护系统
管理数据守护系统
确认状态信息
发起故障自动接管命令----确认模式
监控模式: MON_DW_CONFIRM 参数的默认值是 0, 表示监控模式;
MON_DW_CONFIRM 参数值为 1 时, 表示监视器运行在确认模式下。


八、确认监视器注册为操作系统服务后监视问题
如果把确认监视器作为操作系统服务放在后台运行时,则看不到监视器的广播信息。可启动一个普通监视器来查看数据库状态信息。
$vi /dm8/dmmonitor2.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 = 453331
MON_DW_IP = 192.168.190.128:65101
MON_DW_IP = 192.168.190.129:65121

启动普通监视器
$/dm8/bin/dmmonitor /dm8/dmmonitor2.ini

标签:PORT,主备,ini,DataGuard,DW,dm8,INST,MAL,达梦
来源: https://www.cnblogs.com/nclly/p/16441482.html