目前版本(2025 年第一季度版本 - 8.1.4.80)已经支持单机在线转变为主备集群。
机器 | 硬件类型 | 版本信息 | 备注 |
---|---|---|---|
主机 | IP | 192.168.40.134/135 | ip a |
CPU | x86_64 11th Gen Intel® Core™ i5-11300H @ 3.10GHz | lscpu | |
内存 | 2.8Gi 2.0Gi可用 | free -h | |
存储 | 34G 可用 | df -h fdisk -l | |
操作系统 | Kylin Linux Advanced Server V10 (Sword) | hostnamectl | |
达梦数据库 | dm8_20250423_x86_kylin10_64 |
实例名 | DM01 | DM02 |
---|---|---|
MAL_HOST | 192.168.40.134 | 192.168.40.135 |
MAL_PORT | 61141 | 61142 |
MAL_INST_HOST | 192.168.40.134 | 192.168.40.135 |
MAL_INST_PORT | 5236 | 5236 |
MAL_DW_PORT | 52141 | 52142 |
MAL_INST_DW_PORT | 33141 | 33142 |
select * from v$dm_arch_ini where ARCH_IS_VALID='Y';
若没有配置,则开启
ALTER DATABASE MOUNT;
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE ADD ARCHIVELOG 'DEST = /opt/dmdbms/data/DM01/arch, TYPE = local,FILE_SIZE = 1024, SPACE_LIMIT = 204800';
ALTER DATABASE OPEN;
在业务低峰操作
BACKUP DATABASE FULL BACKUPSET 'FULL_BAK_20250815' COMPRESSED LEVEL 1 PARALLEL 4;
CALL SF_MAL_INST_ADD_APPLY('MAL_INST','DM01','192.168.40.134',61141,'192.168.40.134',5236,52141,0,33141);
CALL SF_MAL_INST_ADD_APPLY('MAL_INST1','DM02','192.168.40.135',61142,'192.168.40.135',5236,52142,0,33142);
CALL SP_SET_PARA_VALUE(1,'MAL_INI',1);
ALTER DATABASE ADD ARCHIVELOG 'TYPE=REALTIME,DEST=DM02';
创建 dmwatcher.ini
文件
[DM01] #注意组
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 20250815
INST_INI = /opt/dmdbms/data/DM01/dm.ini # 注意路径
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /opt/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
修改主库oguid
以及数据库状态
./disql SYSDBA/'"Dameng@123"'
alter database primary force;
sp_set_oguid(20250815); # 注意oguid
SELECT BANNER FROM V$VERSION;
SELECT '数据库版本', CAST((select build_version from v$instance) AS VARCHAR(100))
UNION ALL
SELECT '授权类型', CAST((select server_type from v$license) AS VARCHAR(100))
UNION ALL
SELECT '文件序列号', CAST((SELECT SERIES_NO FROM V$LICENSE) AS VARCHAR(100))
UNION ALL
SELECT '服务器颁布类型', CAST((SELECT SERVER_SERIES FROM V$LICENSE) AS VARCHAR(100))
UNION ALL
SELECT '有效日期', CAST((SELECT EXPIRED_DATE FROM V$LICENSE) AS VARCHAR(100))
UNION ALL
SELECT '用户名称',
CAST((SELECT AUTHORIZED_CUSTOMER FROM V$LICENSE) AS VARCHAR(100))
UNION ALL
SELECT '授权用户数',
CAST((SELECT AUTHORIZED_USER_NUMBER FROM V$LICENSE) AS VARCHAR(100))
UNION ALL
SELECT '服务器版本号',
CAST((SELECT SVR_VERSION FROM V$INSTANCE) AS VARCHAR(100))
UNION ALL
SELECT '服务器启动时间',
CAST((SELECT START_TIME FROM V$INSTANCE) AS VARCHAR(100))
UNION ALL
SELECT '页大小',
CAST((SELECT PAGE()) AS VARCHAR(100))
UNION ALL
SELECT '簇大小',
CAST((SELECT SF_GET_EXTENT_SIZE()) AS VARCHAR(100))
UNION ALL
SELECT '大小写敏感',
CAST((SELECT CASE_SENSITIVE()) AS VARCHAR(100))
UNION ALL
SELECT '字符集',
CAST((SELECT UNICODE()) AS VARCHAR(100))
UNION ALL
SELECT '库状态',
CAST((SELECT STATUS$ FROM V$INSTANCE) AS VARCHAR(100))
UNION ALL
SELECT '当前节点的模式',
CAST((SELECT MODE$ FROM V$INSTANCE) AS VARCHAR(100));
./dminit db_name=DM02 instance_name=DM02 page_size=32 extent_size=32 case_sensitive=1 charset=0 SYSDBA_PWD=Dameng@123 SYSAUDITOR_PWD=Dameng@123 path=/opt/dmdbms/data/
主机:
scp -r /opt/dmdbms/data/DM01/bak/FULL_BAK_20250815 dmdba@192.168.40.135:/opt/dmdbms/data/DM02/bak/
备机:
./dmrman CTLSTMT="RESTORE DATABASE '/opt/dmdbms/data/DM02/dm.ini' FROM BACKUPSET '/opt/dmdbms/data/DM02/bak/FULL_BAK_20250815'"
./dmrman CTLSTMT="RECOVER DATABASE '/opt/dmdbms/data/DM02/dm.ini' FROM BACKUPSET '/opt/dmdbms/data/DM02/bak/FULL_BAK_20250815'"
./dmrman CTLSTMT="RECOVER DATABASE '/opt/dmdbms/data/DM02/dm.ini' UPDATE DB_MAGIC"
从主库传输dmmal.ini、dmarch.ini、dmwatcher.ini到备库
dm.ini 修改 MAL_INI = 1 ARCH_INI = 1
dmmal.ini 无需修改
dmarch.ini 修改 ARCH_DEST 和 ARCH_DEST
dmwatcher.ini 修改 INST_INI 路径
示例:
dmmal.ini
MAL_CHECK_INTERVAL = 30
MAL_COMBIN_BUF_SIZE = 0
MAL_SEND_THRESHOLD = 2048
MAL_CONN_FAIL_INTERVAL = 10
MAL_LOGIN_TIMEOUT = 15
MAL_BUF_SIZE = 100
MAL_SYS_BUF_SIZE = 0
MAL_VPOOL_SIZE = 128
MAL_COMPRESS_LEVEL = 0
MAL_TEMP_PATH =
[MAL_INST]
MAL_INST_NAME = DM01
MAL_HOST = 192.168.40.134
MAL_PORT = 61141
MAL_INST_HOST = 192.168.40.134
MAL_INST_PORT = 5236
MAL_DW_PORT = 52141
MAL_LINK_MAGIC = 0
MAL_INST_DW_PORT = 33141
[MAL_INST1]
MAL_INST_NAME = DM02
MAL_HOST = 192.168.40.135
MAL_PORT = 61142
MAL_INST_HOST = 192.168.40.135
MAL_INST_PORT = 5236
MAL_DW_PORT = 52142
MAL_LINK_MAGIC = 0
MAL_INST_DW_PORT = 33142
dmarch.ini
ARCH_WAIT_APPLY = 0
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /opt/dmdbms/data/DM02/arch
ARCH_FILE_SIZE = 2048
ARCH_SPACE_LIMIT = 102400
ARCH_FLUSH_BUF_SIZE = 2
ARCH_HANG_FLAG = 1
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = DM01 # 注意主库名称
WAIT_APPLY = 0
ARCH_FAILOVER = 0
dmwatcher.ini
[DM01]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 20250815
INST_INI = /opt/dmdbms/data/DM02/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /opt/dmdbms/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
/opt/dmdbms/bin/dmserver /opt/dmdbms/data/DM02/dm.ini mount
./disql SYSDBA/'"Dameng@123"'
alter database standby;
sp_set_oguid(20250815);
dmwatcher
./dmwatcher /opt/dmdbms/data/DM01/dmwatcher.ini
./dmwatcher /opt/dmdbms/data/DM02/dmwatcher.ini
vi /opt/dmdbms/data/DM02/dmmonitor.ini
MON_LOG_PATH = /opt/dmdbms/bin/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 2048
MON_DW_CONFIRM = 0 #0:非确认(故障手切) 1:确认(故障自切)
[DM01]
MON_INST_OGUID = 20250815
MON_DW_IP = 192.168.40.134:52141
MON_DW_IP = 192.168.40.135:52142
/opt/dmdbms/bin/dmmonitor /opt/dmdbms/data/DM02/dmmonitor_manual.ini
文章
阅读量
获赞