DM8达梦数据库主备模式

达梦数据库主备部署

安装数据库

  1. 安装前准备
    vim /etc/security/limits.conf
dmdba hard nofile 65536
dmdba soft nofile 65536
dmdba hard stack 32768
dmdba soft stack 16783
  1. 解压iso文件
    mount -o loop xxx.iso /mnt
    cp /mnt/* /opt/
    mv *.key /opt/dm.key

  2. 执行安装文件
    su - dmdba

DMInstall.bin -i				//命令行安装
C							//中文安装
Y							//是否输入key文件路径
/opt/dm.key					//key文件路径
Y							//是否设置时区
21							//中国时区
1							//典型安装
/data/dm8					//安装目录
Y							//确认安装路径
Y							//确认安装
  1. 实例化数据库(主备库)
    /data/dm8/bin/dminit path=/data/oadata

  2. 前台正常启动一次(初始化数据)
    /data/dm8/bin/dmserver /data/oadata/DAMENG/dm.ini
    exit //启动后正常退出

  3. 注册服务
    ./dm_service_install.sh -t dmserver -dm_ini /data/oadata/DAMENG/dm.ini -p DMSERVER

配置主库模式

脱机备份

  1. 配置权限
    chown -R dmdba.dinstall /data
    su - dmdba
    /data/dm8/bin/dmrman CTLSTMT="backup database '/data/oadata/DAMENG/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/data/backup';"

  2. 将备份集拷贝至备库
    scp -r /data/backup 192.168.0.8:/data/

修改主库配置文件
cd /data/oadata/DAMENG/

dm.ini

INSTANCE_NAME				=	GRP1_OA_01
PORT_NUM					=	5236
DW_INACTIVE_INTERVAL		=	60
ALTER_MODE_STATUS			=	0
ENABLE_OFFLINE_TS			=	2
MAL_INI						=	1
ARCH_INI						=	1
RLOG_SEND_APPLT_MON		=	64

//修改以上标黄部分配置即可,白色为默认

dmmal.ini


MAL_CHECK_INTERVAL			=	5
MAL_CONN_FAIL_INTERVAL		=	5

[MAL_INST1]
MAL_INST_NAME				=	GRP1_OA_01
MAL_HOST					=	192.168.0.7
MAL_PORT					=	61141
MAL_INST_HOST				=	192.168.0.7
MAL_INST_PORT				=	5236
MAL_DW_PORT				=	52141
MAL_INST_DW_PORT			=	33141

[MAL_INST2]
MAL_INST_NAME				=	GRP1_OA_02
MAL_HOST					=	192.168.0.8
MAL_PORT					=	61141
MAL_INST_HOST				=	192.168.0.8
MAL_INST_PORT				=	5236
MAL_DW_PORT				=	52141
MAL_INST_DW_PORT			=	33141

dmarch.ini


[ARCHIVE_REALTIME]
ARCH_TYPE					=	REALTIME
ARCH_DEST					=	GRP1_OA_02
[ARCHIVE_LOCAL1]
ARCH_TYPE					=	LOCAL
ARCH_DEST					=	/data/oadata/DAMENG/dmarch
ARCH_FILE_SIZE				=	1024
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						=	/data/oadata/DAMENG/dm.ini
INST_AUTO_RESTART			=	1
INST_STARTUP_CMD			=	/data/dm8/bin/dmserver
RLOG_SEND_THRESHOLD		=	0
RLOG_APPLY_THRESHOLD		=	0

进入mount状态修改主机模式

su - dmdba

nohup /data/dm8/bin/dmserver /data/oadata/DAMENG/dm.ini mount > /tmp/dm.out 2>&1 &

/data/dm8/bin/disql SYSDBA/SYSDBA -e "SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);"
/data/dm8/bin/disql SYSDBA/SYSDBA -e "sp_set_oguid(453331);"
/data/dm8/bin/disql SYSDBA/SYSDBA -e "alter database primary;"
/data/dm8/bin/disql SYSDBA/SYSDBA -e "SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);"

退出mount模式
ps -ef |grep dmserver
kill -9 ***

正常启动数据库(root)
systemctl start DmServiceDMSERVER

启动守护进程
nohup /data/dm8/bin/dmwatcher /data/oadata/DAMENG/dmwatcher.ini &

配置备库模式

脱机还原
systemctl stop DmServiceDMSERVER
su - dmdba

/data/dm8/bin/dmrman CTLSTMT="RESTORE DATABASE '/data/oadata/DAMENG/dm.ini' FROM BACKUPSET '/data/backup'"
/data/dm8/bin/dmrman CTLSTMT="recover database '/data/oadata/DAMENG/dm.ini' update DB_MAGIC;"
修改备库配置文件

cd /data/oadata/DAMENG/

dm.ini

INSTANCE_NAME				=	GRP1_OA_02
PORT_NUM					=	5236
DW_INACTIVE_INTERVAL		=	60
ALTER_MODE_STATUS			=	0
ENABLE_OFFLINE_TS			=	2
MAL_INI						=	1
ARCH_INI						=	1
RLOG_SEND_APPLT_MON		=	64

//修改以上标黄部分配置即可,白色为默认

dmmal.ini


MAL_CHECK_INTERVAL			=	5
MAL_CONN_FAIL_INTERVAL		=	5

[MAL_INST1]
MAL_INST_NAME				=	GRP1_OA_01
MAL_HOST					=	192.168.0.7
MAL_PORT					=	61141
MAL_INST_HOST				=	192.168.0.7
MAL_INST_PORT				=	5236
MAL_DW_PORT				=	52141
MAL_INST_DW_PORT			=	33141

[MAL_INST2]
MAL_INST_NAME				=	GRP1_OA_02
MAL_HOST					=	192.168.0.8
MAL_PORT					=	61141
MAL_INST_HOST				=	192.168.0.8
MAL_INST_PORT				=	5236
MAL_DW_PORT				=	52141
MAL_INST_DW_PORT			=	33141

dmarch.ini

[ARCHIVE_REALTIME]
ARCH_TYPE					=	REALTIME
ARCH_DEST					=	GRP1_OA_01
[ARCHIVE_LOCAL1]
ARCH_TYPE					=	LOCAL
ARCH_DEST					=	/data/oadata/DAMENG/dmarch
ARCH_FILE_SIZE				=	1024
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						=	/data/oadata/DAMENG/dm.ini
INST_AUTO_RESTART			=	1
INST_STARTUP_CMD			=	/data/dm8/bin/dmserver
RLOG_SEND_THRESHOLD		=	0
RLOG_APPLY_THRESHOLD		=	0

进入mount状态修改备机模式

nohup /data/dm8/bin/dmserver /data/oadata/DAMENG/dm.ini mount > /tmp/dm.out 2>&1 &

/data/dm8/bin/disql SYSDBA/SYSDBA -e "SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);"
/data/dm8/bin/disql SYSDBA/SYSDBA -e "sp_set_oguid(453331);"
/data/dm8/bin/disql SYSDBA/SYSDBA -e "alter database standby;"
/data/dm8/bin/disql SYSDBA/SYSDBA -e "SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);"

退出mount模式
ps -ef |grep dmserver
kill -9 ***

正常启动数据库(root)
systemctl start DmServiceDMSERVER

启动守护进程
nohup /data/dm8/bin/dmwatcher /data/oadata/DAMENG/dmwatcher.ini &

配置监视器

修改监视器配置文件

dmmonitor.ini


[GRP1]
MON_DWCONFIRM			=	1
MON_LOG_PATH				=	/data/oadata/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.0.7:52141
MON_DW_IP					=	192.168.0.8:52141

启动监视器进程
/data/dm8/bin/dmmonitor /data/oadata/DAMENG/dmmonitor.ini
收到两个守护进程信息并显示OPEN状态即可
image.png

测试手动主备切换
在监视器前台login SYSDBA/SYSDBA
switchover
image.png
查看切换后状态

image.png

# db 

评论

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×