达梦数据库dw配置

DMSVR01p 10.9.193.248
DMSVR01s 10.9.193.204
DMSVR01m 172.253.63.94

数据库名 实例名 PORT_NUM MAL_INST_DMSVR01_PORT MAL_HOST MAL_PORT MAL_DMSVR01_PORT
DM01 DMSVR01 5236 45101 10.9.193.248 55101 65101
DM01 DMSVR02 5236 45121 10.9.193.204 55121 65121

初始化主备库

以主机 DMSVR01为读写分离主库,启动实例
dmserver /dm8/data/DM01/dm.ini

出现 system is ready 后输入 exit 停止数据库。

DMSVR01
./DmAPService start
dmrman use_ap=2
BACKUP DATABASE '/dm8/data/DM01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'

拷贝备份文件到备机
scp -r /dm8/backup/BACKUP_FILE_01 10.9.193.204:/dm8/backup/

DMSVR02
./DmAPService start
dmrman use_ap=2

RESTORE DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/backup/BACKUP_FILE_01'
RECOVER DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/backup/BACKUP_FILE_01'
RECOVER DATABASE '/dm8/data/DM01/dm.ini' UPDATE DB_MAGIC

primary

cd /dm8/data/DM01/

dm.ini

INSTANCE_NAME = DMSVR01
PORT_NUM = 5236
DMSVR01_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 = DMSVR01
MAL_HOST = 10.9.193.248
MAL_PORT = 55101
MAL_INST_HOST = 10.9.193.248
MAL_INST_PORT = 5236
MAL_DMSVR01_PORT = 65101
MAL_INST_DMSVR01_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 10.9.193.204
MAL_PORT = 55121
MAL_INST_HOST = 10.9.193.204
MAL_INST_PORT = 5236
MAL_DMSVR01_PORT = 65121
MAL_INST_DMSVR01_PORT = 45121

dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/data/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

dmwatcher.ini
[GRP1]
DMSVR01_TYPE = GLOBAL
DMSVR01_MODE = AUTO
DMSVR01_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dm8/data/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

启动主库
./dmserver /dm8/data/DM01/dm.ini mount

开启另一个窗口
如果是非5236端口,则要改个参数
sp_set_para_value(2,'ENABLE_ENCRYPT',0);
重启生效

./disql SYSDBA/@LOCALHOST:5236

[dmdba@YHKylin10 ~]$ cd /dm8/bin
[dmdba@YHKylin10 bin]$ ./disql SYSDBA/DM01SYSDBA

SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>alter database primary;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);

standby

cd /dm8/data/DM01/

dm.ini

INSTANCE_NAME = DMSVR02
PORT_NUM = 5236
DMSVR01_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 = DMSVR01
MAL_HOST = 10.9.193.248
MAL_PORT = 55101
MAL_INST_HOST = 10.9.193.248
MAL_INST_PORT = 5236
MAL_DMSVR01_PORT = 65101
MAL_INST_DMSVR01_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 10.9.193.204
MAL_PORT = 55121
MAL_INST_HOST = 10.9.193.204
MAL_INST_PORT = 5236
MAL_DMSVR01_PORT = 65121
MAL_INST_DMSVR01_PORT = 45121

dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/data/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0

dmwatcher.ini
[GRP1]
DMSVR01_TYPE = GLOBAL
DMSVR01_MODE = AUTO
DMSVR01_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dm8/data/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD == /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0

mkdir /dm8/data/arch
以 Mount 方式启动备库
./dmserver /dm8/data/DM01/dm.ini mount
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);

启动守护进程
dmdba 用户下,到数据库安装目录的 bin 下执行以下命令(主备库都执行):
dmwatcher /dmdata/dmdb/dmwatcher.ini
守护进程启动后,会将 Mount 的实例 Open。

注册服务
使用 root 用户,到数据库安装目录的 cd /dm8/script/root 下。
注册守护进程服务(主备库都执行)。
./dm_service_installer.sh -t dmwatcher -p DMSVR01 -watcher_ini /dm8/data/DM01/dmwatcher.ini
./dm_service_installer.sh -t dmwatcher -p DMSVR02 -watcher_ini /dm8/data/DM01/dmwatcher.ini
注册数据库实例服务(主备库都执行):
./dm_service_installer.sh -t dmserver -p DMSVR01 -dm_ini /dm8/data/DM01/dm.ini
./dm_service_installer.sh -t dmserver -p DMSVR02 -dm_ini /dm8/data/DM01/dm.ini

执行以下命令,启动数据库实例:达梦数据库

systemctl start DmServiceDMSVR01
执行以下命令,启动守护进程:
systemctl start DmWatcherServiceDMSVR01

--standby
systemctl start DmServiceDMSVR02
执行以下命令,启动守护进程:
systemctl start DmWatcherServiceDMSVR02

--监视器
cd /dm8/data

vi dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DMSVR01_IP = 10.9.193.248:65101
MON_DMSVR01_IP = 10.9.193.204:65121

执行以下命令,启动监视器:
cd /dm8/bin
./dmmonitor /dm8/data/dmmonitor.ini

--switch over
监视机器
SHOW
LOGIN
Switchover

关闭确认监视器:systemctl stop DmMonitorServiceconfirm
关闭主库守护进程:systemctl stop DmWatcherServiceDMSVR02
关闭备库守护进程:systemctl stop DmWatcherServiceDMSVR01
关闭主库实例:systemctl stop DmServiceDMSVR01
关闭备库实例:systemctl stop DmServiceDMSVR02

posted @ 2022-10-18 16:41  chinesern  阅读(141)  评论(0编辑  收藏  举报