注册
达梦数据库数据守护的搭建
专栏/培训园地/ 文章详情 /

达梦数据库数据守护的搭建

不会讲笑话 2024/09/27 442 0 0
摘要

环境准备
image.png
监视器只需要安装数据库软件,不需要初始化实例

达梦数据库软件安装部分忽略。

#初始化实例 DM01
cd /data/dm8/bin
./dminit path=/data/dm8/data PAGE_SIZE=16 EXTENT_SIZE=32 CASE_SENSITIVE=y DB_NAME=DM01 INSTANCE_NAME=DMSVR01 SYSDBA_PWD=DM01SYSDBA LOG_SIZE=500
#DM02
cd /data/dm8/bin
./dminit path=/data/dm8/data PAGE_SIZE=16 EXTENT_SIZE=32 CASE_SENSITIVE=y DB_NAME=DM02 INSTANCE_NAME=DMSVR02 SYSDBA_PWD=DM02SYSDBA LOG_SIZE=500

#注册服务
/data/dm8/script/root/dm_service_installer.sh -t dmserver -p DMSVR01 -dm_ini /data/dm8/data/DM01/dm.ini
/data/dm8/script/root/dm_service_installer.sh -t dmserver -p DMSVR02 -dm_ini /data/dm8/data/DM02/dm.ini

#主节点备份
./dmrman CTLSTMT="BACKUP DATABASE '/data/dm8/data/DM01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/data/dm8/backup/BACKUP_FILE_01'" ;
scp -r /data/dm8/backup/BACKUP_FILE_01 dmdba@10.122.182.141:/data/dm8/backup
#DM02上恢复
./dmrman CTLSTMT="RESTORE DATABASE '/data/dm8/data/DM02/dm.ini' FROM BACKUPSET '/data/dm8/backup/BACKUP_FILE_01'"
./dmrman CTLSTMT="RECOVER DATABASE '/data/dm8/data/DM02/dm.ini' FROM BACKUPSET '/data/dm8/backup/BACKUP_FILE_01'"
./dmrman CTLSTMT="RECOVER DATABASE '/data/dm8/data/DM02/dm.ini' FROM BACKUPSET '/data/dm8/backup/BACKUP_FILE_01'"

主库primary配置
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

dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 10.122.182.101
MAL_PORT = 55101
MAL_INST_HOST = 10.122.182.101
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 10.122.182.141
MAL_PORT = 55121
MAL_INST_HOST = 10.122.182.141
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121

dmarch.ini (注:arch_dest备机写主机实例,主机写备机实例)
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /data/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 = /data/dm8/data/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /data/dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

启动主库
./dmserver /data/dm8/data/DM01/dm.ini mount
或者
cd /dm8/bin
./DmServiceDMSVR01 start mount

修改主库的模式和设置oguid。
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);

备库standby配置
standby
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

dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 10.122.182.101
MAL_PORT = 55101
MAL_INST_HOST = 10.122.182.101
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 10.122.182.141
MAL_PORT = 55121
MAL_INST_HOST = 10.122.182.141
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121

dmarch.ini (注:arch_dest备机写主机实例,主机写备机实例)
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /data/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 = /data/dm8/data/DM02/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /data/dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

以 Mount 方式启动备库
./dmserver /data/dm8/data/DM02/dm.ini mount
或者
cd /dm8/bin
./DmServiceDMSVR02 start mount

设置备库模式和oguid值
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);

--启主备库的守护进程
启主库守护进程
./dmwatcher /data/dm8/data/DM01/dmwatcher.ini

启备库守护进程
./dmwatcher /data/dm8/data/DM02/dmwatcher.ini

monitor(10.122.182.162)
dmmonitor.ini

MON_DW_CONFIRM = 1
MON_LOG_PATH = /data/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 = 10.122.182.101:65101
MON_DW_IP = 10.122.182.141:65121

--注册监视器服务(也可以不注册)
/dm8/script/root/dm_service_installer.sh -t dmmonitor -p ITSM_DB -monitor_ini /dm8/dmmonitor.ini

-- 注意守护进程注册服务
注册主库的守护进程
[root@~]# /data/dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /data/dm8/data/DM01/dmwatcher.ini
注册备库的守护进程
[root@~]# /data/dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /data/dm8/data/DM02/dmwatcher.ini

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服