注册
达梦数据守护集群搭建步骤详解
专栏/培训园地/ 文章详情 /

达梦数据守护集群搭建步骤详解

mio 2025/03/27 44 0 0
摘要

环境信息

本文描述的环境如下:
操作系统:Kylin Linux Advanced Server V10 (Sword)
数据库版本:DM Database Server 64 V8

28f84b022a9bf17d70e3b4ce80514fe.png

搭建数据守护集群步骤

1、关闭主库

[dmdba@dmnode1 bin]$ cd /dm8/bin
[dmdba@dmnode1 bin]$ ./DmServiceDMSERVER stop
Stopping DmServiceDMSERVER: [ OK ]

2、备份主库,并将备份传送到备机

[dmdba@dmnode1 bin]$ ./dmrman
dmrman V8
RMAN>backup database '/dm8/data/DAMENG/dm.ini' backupset '/dm8/bak';

[dmdba@dmnode1 bin]$ cd /dm8/bak
[dmdba@dmnode1 bak]$ ls
bak.bak bak.meta
[dmdba@dmnode1 bak]$ scp bak.* dmdba@192.168.183.102:/dm8/bak

3、配置主机MAL

[dmdba@dmnode1 DAMENG]$ pwd
/dm8/data/DAMENG
[dmdba@dmnode1 DAMENG]$ cat dmmal.ini
MAL_CHECK_INTERVAL= 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME =DMSERVER
MAL_HOST = 192.168.183.101
MAL_PORT = 15236
MAL_INST_HOST = 192.168.183.101
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSERVER2
MAL_HOST = 192.168.183.102
MAL_PORT = 15236
MAL_INST_HOST = 192.168.183.102
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT =45101

4、配置主机归档

[dmdba@dmnode1 DAMENG]$ cat dmarch.ini
#DaMeng Database Archive Configuration file
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER2
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

5、配置主机数据守护

[dmdba@dmnode1 DAMENG]$ cat 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/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

6、修改主机的dm.ini,将如下参数修改为对应值

MAL_INI = 1
ARCH_INI = 1
ALTER_MODE_STATUS= 0
ENABLE_OFFLINE_TS= 2

7、将主机数据库启动到mount状态

[dmdba@dmnode1 DAMENG]$ cd /dm8/bin
[dmdba@dmnode1 bin]$ ./dmserver /dm8/data/DAMENG/dm.ini mount

8、在备机上初始化备库的实例,还原恢复数据库

[dmdba@dmnode2 bin]$ ./dminit db_name=DAMENG instance_name=DMSERVER2 path=/dm8/data SYSDBA_PWD=Dameng123 SYSAUDITOR_PWD=Dameng123

[dmdba@dmnode2 bin]$ ./dmrman
dmrman V8
RMAN> restore database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/bak';

RMAN> recover database '/dm8/data/DAMENG/dm.ini' from backupset '/dm8/bak';

RMAN> recover database '/dm8/data/DAMENG/dm.ini' update db_magic;

9、配置备机MAL

[dmdba@dmnode2 DAMENG]$ pwd
/dm8/data/DAMENG
[dmdba@dmnode2 DAMENG]$ cat dmmal.ini
MAL_CHECK_INTERVAL= 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME =DMSERVER
MAL_HOST = 192.168.183.101
MAL_PORT = 15236
MAL_INST_HOST = 192.168.183.101
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSERVER2
MAL_HOST = 192.168.183.102
MAL_PORT = 15236
MAL_INST_HOST = 192.168.183.102
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT =45101

10、配置备机归档

[dmdba@dmnode2 DAMENG]$ cat dmarch.ini
#DaMeng Database Archive Configuration file
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

11、配置备机数据守护

[dmdba@dmnode2 DAMENG]$ cat 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/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

12、修改备机的dm.ini,将如下参数修改为对应值

MAL_INI = 1
ARCH_INI = 1
ALTER_MODE_STATUS= 0
ENABLE_OFFLINE_TS= 2

13、将备机数据库启动到mount状态

[dmdba@dmnode2 DAMENG]$ cd /dm8/bin
[dmdba@dmnode2 bin]$ ./dmserver /dm8/data/DAMENG/dm.ini mount

14、修改主库的 oguid 和修改数据库模式为主库

[dmdba@dmnode1 bin]$ ./disql sysdba/Dameng123
SQL> sp_set_oguid(8888);
SQL> alter database primary;

15、修改备库的 oguid 和修改数据库模式为备库

[dmdba@dmnode2 bin]$ ./disql sysdba/Dameng123
SQL> sp_set_oguid(8888);
SQL> alter database standby;

16、分别在主备机上启动守护进程

[dmdba@dmnode1 bin]$ ./dmwatcher /dm8/data/DAMENG/dmwatcher.ini

[dmdba@dmnode2 bin]$ ./dmwatcher /dm8/data/DAMENG/dmwatcher.ini

17、在监视器服务器上配置dmmonitor.ini

[dmdba@dmmonitor data]$ pwd
/dm8/data
[dmdba@dmmonitor data]$ cat 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.183.101:65101
MON_DW_IP = 192.168.183.102:65101

18、登录监视器,并查看主备库信息

[dmdba@dmmonitor data]$ ./dmmonitor /dm8/data/dmmonitor.ini
login
用户名:sysdba
密码:
show
image.png

19、在监视器中输入switchover回车,进行主备切换

image.png
image.png

20、注册备机数据库服务

以root用户执行:
[root@dmnode2 ~]# cd /dm8/script/root/
[root@dmnode2 root]# ./dm_service_installer.sh -t dmserver -p DMSERVER2 -dm_ini /dm8/data/DAMENG/dm.ini

21、给主机注册数据守护进程服务

[root@dmnode1 ~]# cd /dm8/script/root/
[root@dmnode1 root]# ./dm_service_installer.sh -t dmwatcher -p DMSERVER -watcher_ini /dm8/data/DAMENG/dmwatcher.ini

22、给备机注册数据守护进程服务

[root@dmnode2 ~]# cd /dm8/script/root/
[root@dmnode2 root]# ./dm_service_installer.sh -t dmwatcher -p DMSERVER2 -watcher_ini /dm8/data/DAMENG/dmwatcher.ini

23、给监视器服务器注册监视器服务

[root@dmmonitor ~]# cd /dm8/script/root/
[root@dmmonitor root]# ./dm_service_installer.sh -t dmmonitor -p MONITOR -monitor_ini /dm8/data/dmmonitor.ini

至此完成达梦数据守护集群的搭建!

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服