环境说明
操作系统
Kylin Linux Advanced Server V10(Sword)
达梦版本
DM8
配置说明
–2台服务器(主备机)
–1台服务器(监视器)
过程中错误说明
没有关闭防火墙,导致第一次配置失败。
端口规划
数据库名 | 实例名 | PORT_NUM | MAL_INST_DW_PORT | MAL_HOST | MAL_PORT | MAL_DW_PORT |
DM | DM_N1 | 5236 | 5240 | 192.168.10.41 | 5238 | 5239 |
DM | DM_N2 | 5236 | 5240 | 192.168.10.42 | 5238 | 5239 |
数据准备
主机初始化数据库:(使用图形界面创建,root用户./dmservice.sh停止实例服务)
[dmdba@localhost bin]$ ./dminit path=/dm8/data instance_name=DM_N1
注册服务需要自行总结
备机初始化数据库:(使用图形界面创建,root用户./dmservice.sh停止实例服务)
[dmdba@localhost bin]$ ./dminit path=/dm8/data instance_name=DM_N2 db_name=DM
实验时少了灰色部分造成数据库名不一致
主机做完全备份:
需要启动一次该实例,关闭
dmserver /dm8/data/DM/dm.ini
[dmdba@kslx2-01 DM]$ cd /dm8/bin
[dmdba@kslx2-01 bin]$ ./dmrman
dmrman V8
RMAN> backup database '/dm8/data/DM/dm.ini' backupset '/dm8/backupset'
backup database '/dm8/data/DM/dm.ini' backupset '/dm8/backupset'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[52121], file_lsn[52121]
Processing backupset /dm8/backupset
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
backup successfully!
time used: 00:00:03.262
主机备份传输到备机:
[dmdba@kslx2-01 backupset]$ scp -r /dm8/backupset/ dmdba@192.168.100.42:/dm8
The authenticity of host '192.168.100.42 (192.168.100.42)' can't be established.
ECDSA key fingerprint is SHA256:EUZ0qItmgr+ze2wuovdoFZesMVbCbisFmyDqGg8437U.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.100.42' (ECDSA) to the list of known hosts.
Authorized users only. All activities may be monitored and reported.
dmdba@192.168.100.42's password:
备机还原数据库:
[dmdba@kslx2-01 DM]$ cd /dm8/bin
[dmdba@kslx2-01 bin]$ ./dmrman
dmrman V8
RMAN> restore database '/dm8/data/DM/dm.ini' from backupset '/dm8/backupset'
restore database '/dm8/data/DM/dm.ini' from backupset '/dm8/backupset'
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
restore successfully.
time used: 00:00:02.456
备机恢复数据库:
RMAN> recover database '/dm8/data/DM/dm.ini' from backupset '/dm8/backupset'
recover database '/dm8/data/DM/dm.ini' update db_magic
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[52121], file_lsn[52121]
recover successfully!
time used: 995.922(ms)
更新数据库的魔数:
RMAN> recover database '/dm8/data/DM/dm.ini' update db_magic
recover database '/dm8/data/DM/dm.ini' update db_magic
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[52121], file_lsn[52121]
recover successfully!
time used: 994.933(ms)
主机配置
配置文件位置:
/dm8/data/DM
配置dm.ini:(需要查找修改)
INSTANCE_NAME = DM_N1
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 = DM_N1
MAL_HOST = 192.168.100.41
MAL_PORT = 5238
MAL_INST_HOST = 192.168.100.41
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5240
[MAL_INST2]
MAL_INST_NAME = DM_N2
MAL_HOST = 192.168.100.42
MAL_PORT = 5238
MAL_INST_HOST = 192.168.100.42
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5240
dmarch.ini配置:
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DM_N2
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /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 = /dm8/data/DM/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
启动到配置模式:
[dmdba@kslx2-01 tool]$ cd /dm8/bin
[dmdba@kslx2-01 bin]$ ./dmserver /dm8/data/DM/dm.ini mount
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
设置OGUID:SQL>sp_set_oguid(453331);
主机模式打开:SQL>alter database primary;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
备机配置
配置文件位置:
/dm8/data/DM
dm.ini配置:(需要查找修改)
INSTANCE_NAME = DM_N2
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 = DM_N1
MAL_HOST = 192.168.100.41
MAL_PORT = 5238
MAL_INST_HOST = 192.168.100.41
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5240
[MAL_INST2]
MAL_INST_NAME = DM_N2
MAL_HOST = 192.168.100.42
MAL_PORT = 5238
MAL_INST_HOST = 192.168.100.42
MAL_INST_PORT = 5236
MAL_DW_PORT = 5239
MAL_INST_DW_PORT = 5240
dmarch.ini配置:
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DM_N1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /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 = /dm8/data/DM/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0
启动到配置模式:
[dmdba@kslx2-01 tool]$ cd /dm8/bin
[dmdba@kslx2-01 bin]$ ./dmserver /dm8/data/DM/dm.ini mount
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
设置OGUID:SQL>sp_set_oguid(453331);
备机模式打开:SQL>alter database standby;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
启动数据守护进程
主机启动守护:
./dmwatcher /dm8/data/DM/dmwatcher.ini/dm8/bin
备机启动守护:
/dm8/bin
./dmwatcher /dm8/data/DM/dmwatcher.ini
监视器配置
dmmonitor.ini配置:
地址:
/dm8
内容:
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.100.41:5239
MON_DW_IP = 192.168.100.42:5239
启动监视器
地址:
/dm8/bin
内容:
./dmmonitor /dm8/dmmonitor.ini
主备切换
监视器中执行
Login
登录用户sysdba密码Dameng123
switchover GRP1.DM_N2
实时主备集群重启有顺序要求:
1、 关闭监视器
2、 关闭主库守护进程
3、 关闭备库守护进程
4、 关闭主库实例
5、 关闭备库实例
6、 启动主库实例 (mount)
7、 启动备库实例 (mount)
8、 启动主库守护进程 (open)
9、 启动备库守护进程 (open)
10、 启动监视器