本次环境采用VM虚机部署、准备3台测试虚拟机,01、02作为主备数据库,03作为监视器(dbmonitor)。
dmdw01(192.168.128.138)
dmdw02(192.168.128.139)
dmtest03(192.168.128.140)
主备库的配置规划如下,生产环境的 MAL_HOST 建议使用独立网段IP。
|
主 |
备 |
业务IP |
192.168.128.138 |
192.168.128.139 |
实例名 |
DMSERVER |
DMSERVER2 |
实例端口 |
5236 |
5236 |
MAL端口 |
5336 |
5336 |
MAL守护进程端口 |
5436 |
5436 |
守护进程端口 |
5536 |
5536 |
OGUID |
45331 |
|
守护组 |
GDW1 |
|
安装目录 |
/opt/dmdbms |
|
实例目录 |
/opt/dmdbms/data/ |
|
归档上限 |
51200 |
|
确认监视器IP |
192.168.128.140 |
--初始化实例
[dmdba@~]#/opt/dmdbms/bin/dminit PATH=/opt/dmdbms/data/ INSTANCE_NAME=DW1_01 PAGE_SIZE=32
LOG_SIZE=2048
--启动服务
[dmdba@~]#/opt/dmdbms/bin/dmserver /opt/dmdbms/data/DAMENG/dm.ini
--开启归档
[dmdba@~]#/opt/dmdbms/bin/disql SYSDBA/[email protected]:5236
SQL>ALTER DATABASE MOUNT;
SQL>ALTER DATABASE ARCHIVELOG;
SQL>ALTER DATABASE ADD ARCHIVELOG 'DEST=/opt/dmdbms/data/DAMENG/arch, TYPE=LOCAL,FILE_SIZE=1024, SPACE_LIMIT=51200';
SQL>ALTER DATABASE OPEN;
--备份数据
SQL>BACKUP DATABASE BACKUPSET '/opt/dmdbms/data/DAMENG/bak/BACKUP_FILE';
--修改dm.ini
SQL>SP_SET_PARA_VALUE (2,'PORT_NUM',5236);
SQL>SP_SET_PARA_VALUE (2,'DW_INACTIVE_INTERVAL',60);
SQL>SP_SET_PARA_VALUE (2,'ALTER_MODE_STATUS',0);
SQL>SP_SET_PARA_VALUE (2,'ENABLE_OFFLINE_TS',2);
SQL>SP_SET_PARA_VALUE (2,'MAL_INI',1);
SQL>SP_SET_PARA_VALUE (2,'RLOG_SEND_APPLY_MON',64);
关闭前台实例服务
[dmdba@~]#vi /opt/dmdbms/data/DAMENG/dmarch.ini
[ARCHIVE_LOCAL]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST =/opt/dmdbms/data/DAMENG/arch/ #本地归档存放路径
ARCH_FILE_SIZE = 1024 #单个归档大小,单位MB
ARCH_SPACE_LIMIT = 51200 #归档上限,单位MB
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME #实时归档类型
ARCH_DEST = DW1_01B #实时归档目标实例名
[dmdba@~]#vi /opt/dmdbms/data/DAMENG/dmmal.ini
MAL_CHECK_INTERVAL = 10 #MAL链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 10 #判定MAL链路断开的时间
MAL_TEMP_PATH = /opt/dmdbms/data/malpath/ #临时文件目录
MAL_BUF_SIZE = 512 #单个MAL缓存大小,单位MB
MAL_SYS_BUF_SIZE = 2048 #MAL总大小限制,单位MB
MAL_COMPRESS_LEVEL = 0 #MAL消息压缩等级,0表示不压缩
[MAL_INST1]
MAL_INST_NAME = SERVER #实例名,和 dm.ini的INSTANCE_NAME一致
MAL_HOST = 192.168.128.138 #MAL系统监听TCP连接的IP地址
MAL_PORT = 5336 #MAL系统监听TCP连接的端口
MAL_INST_HOST = 192.168.128.138 #实例的对外服务IP地址
MAL_INST_PORT = 5236 #实例对外服务端口,和dm.ini的PORT_NUM一致
MAL_DW_PORT = 5436 #实例对应的守护进程监听TCP连接的端口
MAL_INST_DW_PORT = 5536 #实例监听守护进程TCP连接的端口
[MAL_INST2]
MAL_INST_NAME = SERVER2
MAL_HOST = 192.168.128.139
MAL_PORT = 5336
MAL_INST_HOST = 192.168.128.139
MAL_INST_PORT = 5236
MAL_DW_PORT = 5436
MAL_INST_DW_PORT = 5536
[dmdba@~]#vi /opt/dmdbms/data/DAMENG/dmwatcher.ini
[GDW1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = MANUAL #故障手动切换模式
DW_ERROR_TIME = 20 #远程守护进程故障认定时间
INST_ERROR_TIME = 20 #本地实例故障认定时间
INST_RECOVER_TIME =60 #主库守护进程启动恢复的间隔时间
INST_OGUID = 45331 #守护系统唯一OGUID值
INST_INI =/opt/dmdbms/data/DAMENG/dm.ini #dm.ini文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /opt/dmdbms/bin/dmserver #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阈值,默认关闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阈值,默认关闭
[dmdba@~]#scp -r /opt/dmdbms/data/[email protected]:/opt/dmdbms/data/
[root@~]#/opt/dmdbms/script/root/dm_service_installer.sh -t dmserver -pSERVER-dm_ini /opt/dmdbms/data/DAMENG/dm.ini -m mount
[root@~]#/opt/dmdbms/script/root/dm_service_installer.sh -t dmwatcher -pWatcher -watcher_ini /opt/dmdbms/data/DAMENG/dmwatcher.ini
备注:删除自启
[root@~]#/opt/dmdbms/script/root/dm_service_uninstaller.sh -nDmServiceSERVER
[root@~]#/opt/dmdbms/script/root/dm_service_uninstaller.sh -nDmWatcherServiceWatcher
[dmdba@~]#vi /opt/dmdbms/data/DAMENG/dm.ini
INSTANCE_NAME = SERVER2 #数据库实例名
[dmdba@~]#vi /opt/dmdbms/data/DAMENG/dmarch.ini
[ARCHIVE_LOCAL]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST =/opt/dmdbms/data/DAMENG/arch/ #本地归档存放路径
ARCH_FILE_SIZE = 1024 #单个归档大小,单位MB
ARCH_SPACE_LIMIT = 51200 #归档上限,单位MB
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME #实时归档类型
ARCH_DEST = DW1_01 #实时归档目标实例名
与主库的dmmal.ini、dmwatcher.ini相同
[root@~]#/opt/dmdbms/script/root/dm_service_installer.sh -t dmserver -pSERVER2 -dm_ini /opt/dmdbms/data/DAMENG/dm.ini -m mount
[root@~]#/opt/dmdbms/script/root/dm_service_installer.sh -t dmwatcher -pWatcher -watcher_ini /opt/dmdbms/data/DAMENG/dmwatcher.ini
备注:删除自启
[root@~]#/opt/dmdbms/script/root/dm_service_uninstaller.sh -nSERVER2
[root@~]#/opt/dmdbms/script/root/dm_service_uninstaller.sh -nDmWatcherServiceWatcher
[dmdba@~]#/opt/dmdbms/bin/dmrman CTLSTMT="RESTORE DATABASE '/opt/dmdbms/data/DAMENG/dm.ini'
FROM BACKUPSET '/opt/dmdbms/data/DAMENG/bak/BACKUP_FILE'"
[dmdba@~]#/opt/dmdbms/bin/dmrman CTLSTMT="RECOVER DATABASE'/opt/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET'/opt/dmdbms/data/DAMENG/bak/BACKUP_FILE'"
[dmdba@~]#/opt/dmdbms/bin/dmrman CTLSTMT="RECOVER DATABASE'/opt/dmdbms/data/DAMENG/dm.ini' UPDATE DB_MAGIC"
1、在各节点数据库的bin目录中 存放非确认监视器配置文件。
2、在确认监视器机器上(非集群节点) 注册确认监视器自启服务。
[dmdba@~]#vi /opt/dmdbms/bin/dmmonitor.ini
MON_DW_CONFIRM = 0 #0为非确认,1为确认
MON_LOG_PATH = ../log #监视器日志文件存放路径
MON_LOG_INTERVAL = 60 #每隔 60s 定时记录系统信息到日志文件
MON_LOG_FILE_SIZE = 512 #单个日志大小,单位MB
MON_LOG_SPACE_LIMIT = 2048 #日志上限,单位MB
[GDW1]
MON_INST_OGUID = 45331 #组GDW1的唯一OGUID 值
MON_DW_IP = 192.168.128.138:5436 #IP对应MAL_HOST,PORT对应MAL_DW_PORT
MON_DW_IP = 192.168.128.139:5436
[root@~]#/opt/dmdbms/script/root/dm_service_installer.sh -t dmmonitor -pMonitor -monitor_ini /opt/dmdbms/bin/dmmonitor.ini
备注:删除自启
[root@~]#/opt/dmdbms/script/root/dm_service_uninstaller.sh -nDmMonitorServiceMonitor
主库
[dmdba@~]#/opt/dmdbms/bin/DmServiceSERVER start
[dmdba@~]#/opt/dmdbms/bin/disql SYSDBA/[email protected]:5236
SQL>SP_SET_OGUID(45331);
SQL>ALTER DATABASE PRIMARY;
备库
[dmdba@~]#/opt/dmdbms/bin/DmServiceSERVER2 start
[dmdba@~]#/opt/dmdbms/bin/disql SYSDBA/[email protected]:5236
SQL>SP_SET_OGUID(45331);
SQL>ALTER DATABASE STANDBY;
主备机器:[dmdba@~]#/opt/dmdbms/bin/DmWatcherServiceWatcher start
[dmdba@~]#/opt/dmdbms/bin/DmMonitorServiceMonitor start
前台启动:[dmdba@~]#/opt/dmdbms/bin/dmmonitor /opt/dmdbms/bin/dmmonitor.ini
启动:主备机器守护进程
主备机器:[dmdba@~]#/opt/dmdbms/bin/DmWatcherServiceWatcher start
停止:主备机器守护进程→主机器SERVER主库→备机器SERVER2备库
主备机器:[dmdba@~]#/opt/dmdbms/bin/DmWatcherServiceWatcher stop
主机器:[dmdba@~]#/opt/dmdbms/bin/DmServiceSERVER stop
备机器:[dmdba@~]#/opt/dmdbms/bin/DmServiceSERVER2 stop
达梦学习社区:https://eco.dameng.com