实时主备环境
类型 | 业务IP | 库名 | 实例名 | PORT_NUM | MAL_HOST | MAL_INST_DW_PORT | MAL_PORT | MAL_DW_PORT |
---|---|---|---|---|---|---|---|---|
主库dm8p | 192.168.1.223 | DAMENG | GRP1_RT_01 | 5236 | 10.0.0.223 | 45101 | 55101 | 65101 |
备库dm8s | 192.168.1.224 | DAMENG | GRP1_RT_02 | 5236 | 10.0.0.224 | 45121 | 55121 | 65121 |
监视器dwm | 192.168.1.225 | DAMENG | 10.0.0.225 |
新备机环境
新备机器安装数据库软件并初始化实例,数据库名称DAMENG,实例名GRP1_RT_03,这边省略实例的初始化步骤。。。。。
搭建配置
步骤1:登录主库进行联机备份
SQL> BACKUP DATABASE BACKUPSET '/home/dmdba/backup/BACKUP_FILE_01 ';
步骤2:备份文件传输到新的备库系统中
复制备份集到备库:scp -r BACKUP_FILE_01/ 192.168.1.116:/home/dmdba/
停止新备库实例: systemctl start DmServiceGRP1_RT_03.service
步骤3:新备库使用DMRMAN进行脱机还原
$ dmrman CTLSTMT="RESTORE DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET '/home/dmdba/BACKUP_FILE_01'"
$ dmrman CTLSTMT="RECOVER DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' FROM BACKUPSET '/home/dmdba/BACKUP_FILE_01'"
$ dmrman CTLSTMT="RECOVER DATABASE '/home/dmdba/dmdbms/data/DAMENG/dm.ini' UPDATE DB_MAGIC"
步骤4:新备库配置dm.ini
dm.ini
----------
INSTANCE_NAME = GRP1_RT_03
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
步骤5:新备库配置dmmal.ini
生产环境拷贝一份,新增备库内容即可。
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 10.0.0.223
MAL_PORT = 55101
MAL_INST_HOST = 192.168.1.223
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_02
MAL_HOST = 10.0.0.224
MAL_PORT = 55121
MAL_INST_HOST = 192.168.1.224
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121[MAL_INST3]
MAL_INST_NAME = GRP1_RT_03
MAL_HOST = 10.0.0.116
MAL_PORT = 55131
MAL_INST_HOST = 192.168.1.116
MAL_INST_PORT = 5236
MAL_DW_PORT = 65131
MAL_INST_DW_PORT = 45131
步骤6:新备库配置dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_01[ARCHIVE_REALTIME2]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /home/dmdba/dmdbms/data/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 10240
步骤7:新备库配置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 = /home/dmdba/dmdbms/data/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /home/dmdba/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
步骤8: 新备库已mount方式启动
/home/dmdba/dmdbms/bin/dmserver /home/dmdba/dmdbms/data/DAMENG/dm.ini mount
步骤9:登录新备库,设置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);
步骤10:主库、备库依次动态增加MAL配置
主库:GRP1_RT_01
SQL> SF_MAL_CONFIG(1,0);
SQL> SF_MAL_INST_ADD('MAL_INST3','GRP1_RT_03','10.0.0.116',55131,'192.168.1.116',5236,65131,0,45131);
SQL> SF_MAL_CONFIG_APPLY();
SQL> SF_MAL_CONFIG(0,0);
备库:GRP1_RT_02
SQL> SF_MAL_CONFIG(1,0);
SQL> SF_MAL_INST_ADD('MAL_INST3','GRP1_RT_03','10.0.0.116',55131,'192.168.1.116',5236,65131,0,45131);
SQL> SF_MAL_CONFIG_APPLY();
SQL> SF_MAL_CONFIG(0,0);
步骤11:主库、备库依次动态增加归档配置
#关闭原系统所有实例的守护进程和监视器
1)关闭监视器
2)关闭备库守护进程
[dmdba@dm8s bin]$ ./DmWatcherServicewatcher stop
Stopping DmWatcherServicewatcher: [ OK ]
3)关闭主库守护进程
[dmdba@dm8p bin]$ ./DmWatcherServicewatcher stop
Stopping DmWatcherServicewatcher: [ OK ]
#手工修改主备库状态为mount状态,必须先修改主库,在修改备库
主库:
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL> SP_SET_PARA_VALUE(1, 'DW_INACTIVE_INTERVAL', 0);
SQL> ALTER DATABASE MOUNT;
备库:
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL> SP_SET_PARA_VALUE(1, 'DW_INACTIVE_INTERVAL', 0);
SQL> ALTER DATABASE MOUNT;
##动态添加归档节点(依次主库、备库)
SQL> ALTER DATABASE ADD ARCHIVELOG 'DEST= GRP1_RT_03, TYPE= REALTIME';
##手工修改备库,主库所有实例OPEN,必须先修改备库,然后再修改主库。
备库:
SQL> ALTER DATABASE OPEN FORCE;
操作已执行
已用时间: 6.039(毫秒). 执行号:0.
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
DMSQL 过程已成功完成
已用时间: 12.340(毫秒). 执行号:1209.
SQL> SP_SET_PARA_VALUE(1, 'DW_INACTIVE_INTERVAL', 60);
DMSQL 过程已成功完成
已用时间: 13.468(毫秒). 执行号:1210.
主库:
SQL> ALTER DATABASE OPEN FORCE;
操作已执行
已用时间: 6.039(毫秒). 执行号:0.
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
DMSQL 过程已成功完成
已用时间: 12.340(毫秒). 执行号:1209.
SQL> SP_SET_PARA_VALUE(1, 'DW_INACTIVE_INTERVAL', 60);
DMSQL 过程已成功完成
已用时间: 13.468(毫秒). 执行号:1210.
步骤12:修改监视器配置dmmonitor.ini
新增GRP1_RT_03配置
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/dbms/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 10.0.0.223:65101
MON_DW_IP = 10.0.0.224:65121
MON_DW_IP = 10.0.0.116:65131
步骤13:启动所有守护进程和监视器
依次启动主库守护进程,备库守护进程,新备库守护进程,最后启动监视器。
[dmdba@dm8p bin]$ ./DmWatcherServicewatcher start
Starting DmWatcherServicewatcher: [ OK ][dmdba@dm8s bin]$ ./DmWatcherServicewatcher start
Starting DmWatcherServicewatcher: [ OK ][dmdba@dm116 bin]$ /home/dmdba/dmdbms/bin/dmwatcher /home/dmdba/dmdbms/data/DAMENG/dmwatcher.ini
DMWATCHER[4.0] V8
DMWATCHER[4.0] IS READY[dmdba@dwm ~]$ dmmonitor dmmonitor.ini
[monitor] 2023-02-23 12:12:49: DMMONITOR[4.0] V8
[monitor] 2023-02-23 12:12:49: DMMONITOR[4.0] IS READY.
步骤14:通过监视器检查集群状态
步骤15:注册新备库的守护进程服务
[root@dm116 root]# ./dm_service_installer.sh -t dmwatcher -p watcher -watcher_ini /home/dmdba/dmdbms/data/DAMENG/dmwatcher.ini
至此动态新增实时备库操作完毕。
达梦数据库 - 新一代大型通用关系型数据库 | 达梦在线服务平台