环境说明
- 操作系统 :CentOS-7-x86_64-DVD-1810
- 达梦数据库镜像: dm8_setup_rh7_64_ent_8.1.1.88_20200629
- 机器数量: 2台,一主一备
搭建步骤
主库
1、数据准备,配置dm.ini和dmarch.ini
[dmdba@loaclhost ~]$ cd /data/dmdbms/DAMENG/
[dmdba@loaclhost DAMENG]$ vi dm.ini
ARCH_INI = 1 #打开归档配置
[dmdba@loaclhost DAMENG]$ vi dmarch.ini
[ARCHIVE_LOCAL1]
ARCH_TYPE=LOCAL
ARCH_DEST=/data/dmdbms/DAMENG/arch
ARCH_FILE_SIZE=128
ARCH_SPACE_LIMIT=0
2、进行脱机备份,先关闭数据库再把备份传递给备份
[dmdba@loaclhost bin]$ cd /data/dmdbms/dmdbms/bin
[dmdba@loaclhost bin]$ ./DmService_5236 stop
[dmdba@loaclhost bin]$ ./dmrman CTLSTMT=“BACKUP DATABASE ‘/data/dmdbms/DAMENG/dm.ini’ full to backup_file1 backupset ‘/home/dmdba/backup’”
[dmdba@loaclhost bin]$ cd
[dmdba@loaclhost ~]$ ls -l
总用量 656640
drwxr-xr-x. 2 dmdba dinstall 43 8月 10 15:50 backup
-rwxrwxrwx. 1 dmdba dinstall 672397717 8月 10 14:52 DMInstall.bin
[dmdba@loaclhost ~]$ scp -r backup/ 10.12.21.18:/home/dmdba
备库
3、先关闭数据库进行脱机数据库还原
[dmdba@loaclhost ~]$ cd /data/dmdbms/dmdbms/bin
[dmdba@loaclhost bin]$ ./DmService_5236 stop
[dmdba@loaclhost bin]$ ./dmrman CTLSTMT=“RESTORE DATABASE ‘/data/dmdbms/DAMENG/dm.ini’ FROM BACKUPSET ‘/home/dmdba/backup’”
[dmdba@loaclhost bin]$ ./dmrman CTLSTMT=“RECOVER DATABASE ‘/data/dmdbms/DAMENG/dm.ini’ FROM BACKUPSET ‘/home/dmdba/backup’”
[dmdba@loaclhost bin]$ ./dmrman CTLSTMT=“RECOVER DATABASE ‘/data/dmdbms/DAMENG/dm.ini’ UPDATE DB_MAGIC”
主库
4、配置dm.ini
[dmdba@loaclhost DAMENG]$ vi dm.ini
INSTANCE_NAME = GRP1_RWW_01
PORT_NUM = 5236 #数据库实例监听端口
DW_INACTIVE_INTERVAL = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI = 1 #打开归档配置
RLOG_SEND_APPLY_MON = 64 #统计最近 64 次的日志发送信息
5、配置dmmal.ini
[dmdba@loaclhost DAMENG]$ vi dmmal.ini
MAL_CHECK_INTERVAL=5
MAL_CONN_FAIL_INTERVAL=5
[MAL_INST1]
MAL_INST_NAME=GRP1_RWW_01
MAL_HOST=10.12.21.17
MAL_PORT=61141
MAL_INST_HOST=10.12.21.17
MAL_INST_PORT=5236
MAL_DW_PORT=52141
MAL_INST_DW_PORT=33141
[MAL_INST2]
MAL_INST_NAME=GRP1_RWW_02
MAL_HOST=10.12.21.18
MAL_PORT=61142
MAL_INST_HOST=10.12.21.18
MAL_INST_PORT=5236
MAL_DW_PORT=52142
MAL_INST_DW_PORT=33142
6、配置dmarch.ini
[dmdba@loaclhost DAMENG]$ vi dmarch.ini
[ARCHIVE_LOCAL1]
ARCH_TYPE=LOCAL
ARCH_DEST=/data/dmdbms/DAMENG/arch
ARCH_FILE_SIZE=128
ARCH_SPACE_LIMIT=0
[ARCHIVE_TIMELY1]
ARCH_TYPE=TIMELY
ARCH_DEST=GRP1_RWW_02
7、配置dmwatcher.ini
[dmdba@loaclhost DAMENG]$ vi dmwatcher.ini
[GRP1]
DW_TYPE=GLOBAL
DW_MODE=AUTO
DW_ERROR_TIME=10
INST_RECOVER_TIME=60
INST_ERROR_TIME=10
INST_OGUID=453332
INST_INI=/data/dmdbms/DAMENG/dm.ini
INST_AUTO_RESTART=1
INST_STARTUP_CMD=/data/dmdbms/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD=0
RLOG_APPLY_THRESHOLD=0
8、以mount方式启动主库
[dmdba@loaclhost dmdbms]$ cd dmdbms/bin
[dmdba@loaclhost bin]$ ./dmserver /data/dmdbms/DAMENG/dm.ini mount
9、设置OGUID,修改数据库模式为primary
[dmdba@loaclhost bin]$ ./disql SYSDBA/SYSDBA@10.12.21.17:5236
SQL> SP_SET_PARA_VALUE(1,‘ALTER_MODE_STATUS’,1);
SQL> SP_SET_OGUID(453332);
SQL> SP_SET_PARA_VALUE(1,‘ALTER_MODE_STATUS’,0);
SQL> alter database primary;
备库
10、配置dm.ini
[dmdba@loaclhost DAMENG]$ vi dm.ini
INSTANCE_NAME = GRP1_RWW_02
PORT_NUM = 5236 #数据库实例监听端口
DW_INACTIVE_INTERVAL = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI = 1 #打开归档配置
RLOG_SEND_APPLY_MON = 64 #统计最近 64 次的日志重演信息
11、配置dmmal.ini (与主库完全一致,可以用scp命令传递也可进行编辑)
[dmdba@loaclhost DAMENG]$ vi dmmal.ini
MAL_CHECK_INTERVAL=5
MAL_CONN_FAIL_INTERVAL=5
[MAL_INST1]
MAL_INST_NAME=GRP1_RWW_01
MAL_HOST=10.12.21.17
MAL_PORT=61141
MAL_INST_HOST=10.12.21.17
MAL_INST_PORT=5236
MAL_DW_PORT=52141
MAL_INST_DW_PORT=33141
[MAL_INST2]
MAL_INST_NAME=GRP1_RWW_02
MAL_HOST=10.12.21.18
MAL_PORT=61142
MAL_INST_HOST=10.12.21.18
MAL_INST_PORT=5236
MAL_DW_PORT=52142
MAL_INST_DW_PORT=33142
12、配置dmarch.inni
[dmdba@loaclhost DAMENG]$ vi dmarch.ini
[ARCHIVE_LOCAL1]
ARCH_TYPE=LOCAL
ARCH_DEST=/data/dmdbms/DAMENG/arch
ARCH_FILE_SIZE=128
ARCH_SPACE_LIMIT=0
[ARCHIVE_TIMELY1]
ARCH_TYPE=TIMELY
ARCH_DEST=GRP1_RWW_01
13、配置dmwatcher.ini
[dmdba@loaclhost DAMENG]$ vi dmwatcher.ini
[GRP1]
DW_TYPE=GLOBAL
DW_MODE=AUTO
DW_ERROR_TIME=10
INST_RECOVER_TIME=60
INST_ERROR_TIME=10
INST_OGUID=453332
INST_INI=/data/dmdbms/DAMENG/dm.ini
INST_AUTO_RESTART=1
INST_STARTUP_CMD=/data/dmdbms/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD=0
RLOG_APPLY_THRESHOLD=0
14、以mount方式启动备库,设置OGUID
[dmdba@loaclhost bin]$ ./dmserver /data/dmdbms/DAMENG/dm.ini mount
[dmdba@loaclhost bin]$ ./disql SYSDBA/SYSDBA@10.12.21.18:5236
SQL> SP_SET_PARA_VALUE(1,‘ALTER_MODE_STATUS’,1);
SQL> SP_SET_OGUID(453332);
SQL> SP_SET_PARA_VALUE(1,‘ALTER_MODE_STATUS’,0);
15、修改备库数据库模式
SQL> SP_SET_PARA_VALUE(1,‘ALTER_MODE_STATUS’,1);
SQL> alter database standby;
SQL> SP_SET_PARA_VALUE(1,‘ALTER_MODE_STATUS’,0);
16、配置监视器(在备库设置,生产环境应在新机器上设置)
[dmdba@loaclhost DAMENG]$ cat dmmonitor.ini
MON_DW_CONFIRM=1
MON_LOG_PATH=/data/log
MON_LOG_INTERVAL=60
MON_LOG_FILE_SIZE=32
MON_LOG_SPACE_LIMIT=0
[GRP1]
MON_INST_OGUID=453332
MON_DW_IP=10.12.21.17:52141
MON_DW_IP=10.12.21.18:52142
17、先启动主库watcher,再启动备库watcher,最后启动monitor
主库
[dmdba@loaclhost DAMENG]$ cd /data/dmdbms/dmdbms/bin
[dmdba@loaclhost bin]$ ./dmwatcher /data/dmdbms/DAMENG/dmwatcher.ini
备库
[dmdba@loaclhost bin]$ ./dmwatcher /data/dmdbms/DAMENG/dmwatcher.ini
[dmdba@loaclhost bin]$ ./dmmonitor /data/dmdbms/DAMENG/dmmonitor.ini
18、关闭进程时,先关monitor, 再关备库watcher,最后关主库watcher。
先关主库再关备库