一、服务器配置
1.扩展基础盘
磁盘分区
/sbin/fdisk /dev/vda<<EOF &> /dev/null
p
n
4
p
w
EOF
硬盘刷新
partx -s /dev/vda
echo "Disk Partition /dev/vda4 Create OK!"
pvcreate /dev/vda4
rootlvname=`df -h|grep "\-root"|awk '{print $1}'`
vgname=`vgs|grep klas|awk '{print $1}'`
vgextend ${vgname} /dev/vda4
lvextend -L 94.5G ${rootlvname}
xfs_growfs ${rootlvname}
df -h
创建并挂载dmdata数据盘
bash
mkdir /dmdata
pvcreate /dev/vdb
pvs
和其他盘用一个VG
bash
vgextend klas_host* /dev/vdb
lvextend -L +199.99G /dev/mapper/klas_host*-root
xfs_growfs /dev/mapper/klas_host*-root
2.修改内核参数
添加以下内容
bash
cat >> /etc/sysctl.conf <<EOF
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
vm.dirty_ratio = 80
vm.dirty_expire_centisecs = 500
vm.dirty_writeback_centisecs = 100
kernel.core_pattern = /dmdata/core.%p
vm.swappiness=10
vm.dirty_background_ratio = 0
vm.min_free_kbytes = 2097152
EOF
配置使生效
bash
sysctl -p
3.配置时间同步
安装chrony
bash
yum install chrony -y
增加配置
bash
vi /etc/chrony.conf
#pool pool.ntp.org iburst # 注释掉这行
#pool 172.30.11.3 iburst
pool 10.224.198.137 iburst # 新增这行,这个ip是局里的ntp地址
启动chrony并加入开机启动
bash
systemctl enable chronyd.service
systemctl restart chronyd.service
systemctl status chronyd.service
关闭防火墙
bash
systemctl disable firewalld
systemctl stop firewalld
或者设置firewalld(因NTP使用123/UDP端口协议和chrony协议端口相同,所以允许NTP服务即可。)
firewall-cmd --add-service=ntp --permanent
firewall-cmd --reload
查看chronyd状态
bash
chronyc sources;systemctl status chronyd;
5.关闭swap
临时关闭 swap 分区,重启后失效
bash
swapoff -a
永久关闭 swap 分区
bash
sed -ri 's/.*swap.*/#&/' /etc/fstab
重启操作系统
bash
reboot
再次确认
bash
free -m
[回目录](# 目录)
二、达梦环境、软件初始化
1.环境配置
创建dinstall组跟dmdba用户
bash
groupadd dinstall -g 1049
useradd dmdba -u 1049 -g dinstall
echo "zjdj_zjj_123" | passwd dmdba --stdin > /dev/null 2>&1
echo "dmdba ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
修改用户资源限制
bash
cat >> /etc/security/limits.conf <<EOF
# 末尾添加
dmdba soft nice 0
dmdba hard nice 0
dmdba soft as unlimited
dmdba hard as unlimited
dmdba soft fsize unlimited
dmdba hard fsize unlimited
dmdba soft nproc 65536
dmdba hard nproc 65536
dmdba soft nofile 65536
dmdba hard nofile 65536
dmdba soft core unlimited
dmdba hard core unlimited
dmdba soft data unlimited
dmdba hard data unlimited
EOF
配置dmdba环境变量
bash
tee /home/dmdba/.bash_profil /home/dmdba/.bashrc <<EOF
export DM_HOME="/dm8"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/dm8/bin
export PATH=$PATH:$DM_HOME/bin:$DM_HOME/tool
EOF
2.达梦软件安装
创建达梦软件安装目录
bash
mkdir /dm8
chown dmdba.dinstall /dm8 /dmdata
上传达梦安装包和密钥到root目录下
两个节点分别安装
bash
mkdir -p /mnt/dmiso
mount -o loop /root/dm8_20230927_FTarm_kylin10_sp1_64.iso /mnt/dmiso
切换用户
bash
su - dmdba
cd /mnt/dmiso
执行安装
bash
./DMInstall.bin -i
- 选择安装程序的语言 1为中文,2为英文,默认回车选择安装语言为中文。
- 提示是否安装 key 文件,默认Y 同意。
- 请输入Key文件的路径地址 [dm.key]:
- /dmdata/dm06_1_政务应用.key
- /dmdata/dm06_2_政务应用.key
- 选择时区,默认21 即东 8 区。
- 选择安装类型,默认典型安装(包含所有内容)。
- 选择软件安装目录,默认安装在/home/dmdba/dmdbms,这里需要选择/dm8
- /dm8
- 确认安装。
安装完成提示使用root用户执行脚本
bash
exit
sh /dm8/script/root/root_installer.sh
[回目录](# 目录)
2.主备集群配置
切换dm用户
bash
su - dmdba
初始化实例
bash
cd /dm8/bin
./dminit path=/dmdata page_size=32 extent_size=32 charset=1 log_size=2048 db_name=dmdb instance_name=dmdb SYSDBA_PWD="Hn@dameng123" SYSAUDITOR_PWD="Hn@dameng123" SYSSSO_PWD="Hn@dameng123" SYSDBO_PWD="Hn@dameng123"
两个节点都要做,测试达梦机器能否手动开启
bash
dmserver /dmdata/dmdb/dm.ini
3.脱机备份数据库
在主机dmdb01上执行以下命令,确认主库 dmap 服务已启动
bash
ps -ef |grep dmap
若未启动,则先启动DMAP服务,dmdba用户到安装目录的bin下执行以下命令:
bash
./DmAPService start
3.1.主库
dmdba用户启动dmrman工具
bash
dmrman use_ap=2
执行 backup 全库
bash
backup database '/dmdata/dmdb/dm.ini' backupset '/dmdata/dmdb/bak/full_bak';
使用主库的备份还原备库,将备份的文件/home/dmdba/bakfull拷贝到备库服务器上。
bash
scp -r /dmdata/dmdb/bak/full_bak 10.76.18.200:/dmdata/dmdb/bak/
3.2.备库
使用dmrman工具还原备库,dmdba用户执行
bash
dmrman
进入dmrman工具交互界面,执行restore
bash
restore database '/dmdata/dmdb/dm.ini' from backupset '/dmdata/dmdb/bak/full_bak';
完成后执行recover
bash
recover database '/dmdata/dmdb/dm.ini' from backupset '/dmdata/dmdb/bak/full_bak';
最后执行recover update db_magic
bash
recover database '/dmdata/dmdb/dm.ini' update db_magic;
[回目录](# 目录)
4.达梦配置文件修改
4.1.主备库修改dm.ini
主库dmdb01上修改以下参数值:
bash
sed -i 's/\(INSTANCE_NAME\) *= [^ ]*/\1 = DM01/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(MAL_INI\) *= [^ ]*/\1 = 1/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ARCH_INI\) *= [^ ]*/\1 = 1/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ALTER_MODE_STATUS\) *= [^ ]*/\1 = 1/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ENABLE_OFFLINE_TS\) *= [^ ]*/\1 = 2/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ENABLE_ENCRYPT\) *= [^ ]*/\1 = 0/g' /dmdata/dmdb/dm.ini;
cat /dmdata/dmdb/dm.ini |grep 'INSTANCE_NAME\|MAL_INI\|ARCH_INI\|ENABLE_OFFLINE_TS\|ENABLE_ENCRYPT\|ALTER_MODE_STATUS'
bash
vi /dmdata/dmdb/dm.ini
INSTANCE_NAME = DM01
ENABLE_ENCRYPT = 0
ALTER_MODE_STATUS = 1
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
备库dmdb02上修改以下参数值:
bash
sed -i 's/\(INSTANCE_NAME\) *= [^ ]*/\1 = DM02/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(MAL_INI\) *= [^ ]*/\1 = 1/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ARCH_INI\) *= [^ ]*/\1 = 1/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ALTER_MODE_STATUS\) *= [^ ]*/\1 = 1/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ENABLE_OFFLINE_TS\) *= [^ ]*/\1 = 2/g' /dmdata/dmdb/dm.ini;
sed -i 's/\(ENABLE_ENCRYPT\) *= [^ ]*/\1 = 0/g' /dmdata/dmdb/dm.ini;
cat /dmdata/dmdb/dm.ini |grep 'INSTANCE_NAME\|MAL_INI\|ARCH_INI\|ENABLE_OFFLINE_TS\|ENABLE_ENCRYPT\|ALTER_MODE_STATUS'
bash
INSTANCE_NAME = DM02
ENABLE_ENCRYPT = 0
ALTER_MODE_STATUS = 1
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
4.2.主备库修改归档配置文件dmarch.ini
vi /dmdata/dmdb/dmarch.ini
主库dmdb01上添加以下内容:
bash
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = DM02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmdata/arch
ARCH_FILE_SIZE = 2048
ARCH_SPACE_LIMIT = 102400
备库dmdb02上添加以下内容
bash
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = DM01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmdata/arch
ARCH_FILE_SIZE = 2048
ARCH_SPACE_LIMIT = 102400
4.3.主备库配置MAL系统配置文件dmmal.ini
主备库2个节点文件内容要相同。
vi /dmdata/dmdb/dmmal.ini
bash
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 15
[MAL_INST1]
MAL_INST_NAME = DM01
MAL_HOST = 10.76.18.199
MAL_PORT = 7336
MAL_INST_HOST = 10.76.18.199
MAL_INST_PORT = 5236
MAL_DW_PORT = 7436
MAL_INST_DW_PORT = 7536
[MAL_INST2]
MAL_INST_NAME = DM02
MAL_HOST = 10.76.18.200
MAL_PORT = 7336
MAL_INST_HOST = 10.76.18.200
MAL_INST_PORT = 5236
MAL_DW_PORT = 7436
4.4.配置主备库守护进程配置文件dmwatcher.ini
vi /dmdata/dmdb/dmwatcher.ini
主备库2节点文件内容要相同。
bash
[GRP_DW]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 30
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 20
INST_OGUID = 453402
INST_INI = /dmdata/dmdb/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
4.5.配置主备库dmmonitor.ini
配置监视器(可以在主备任意节点配置,也可以主备节点都配置,局里主备库非自动切换模式,该进程手动启动)
新建非确认监视器配置文件 dmmonitor.ini,执行以下命令:
bash
cat > /dmdata/dmdb/dmmonitor.ini <<EOF
# 添加以下内容:
MON_DW_CONFIRM = 0
MON_LOG_PATH = /dm8/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 200
MON_LOG_SPACE_LIMIT = 1024
[GRP_DW]
MON_INST_OGUID = 453402
MON_DW_IP = 10.76.18.199:7436
MON_DW_IP = 10.76.18.200:7436
EOF
4.6.配置SQL日志
vi /dmdata/dmdb/sqllog.ini
bash
BUF_TOTAL_SIZE = 10240 #SQLs Log Buffer Total Size(K)(1024~1024000)
BUF_SIZE = 1024 #SQLs Log Buffer Size(K)(50~409600)
BUF_KEEP_CNT = 6 #SQLs Log buffer keeped count(1~100)
[SLOG_ALL]
FILE_PATH = ../log
PART_STOR = 1
SWITCH_MODE = 2
SWITCH_LIMIT = 512
ASYNC_FLUSH = 1
FILE_NUM = 5
ITEMS = 0
SQL_TRACE_MASK = 2:3:25:28
MIN_EXEC_TIME = 1500
USER_MODE = 0
USERS =
EXECTIME_PREC_FLAG = 0
[SLOG_ERROR]
SQL_TRACE_MASK = 23
FILE_PATH = ../log
[SLOG_DDL]
SQL_TRACE_MASK = 3
[SLOG_LONG_SQL]
SQL_TRACE_MASK = 25
MIN_EXEC_TIME = 60000
[回目录](# 目录)
5.手动启动数据库实例、dmwatcher和dmmonitor
5.1.手动启动数据库实例并进行初始化配置
以mount方式启动数据库实例,使用dmdba用户,执行以下命令(主备库都执行):
bash
dmserver /dmdata/dmdb/dm.ini mount
在新的终端使用 disql 工具连接数据库:
bash
disql sysdba/'"Hn@dameng123"'
主备库都修改 oguid,执行以下命令:
bash
sp_set_oguid(453402);
开启归档模式
bash
alter database archivelog;
主库dmdb01上修改数据库模式为 primary,执行以下命令:
bash
alter database primary;
备库dmdb02上修改数据库模式为 standby,执行以下命令:
bash
alter database standby;
查看oguid
bash
SELECT OGUID FROM V$INSTANCE;
6.手动启动dmwatcher
6.1.启动守护进程
dmdba 用户下,到数据库安装目录的bin下执行以下命令(主备库都执行):
bash
dmwatcher /dmdata/dmdb/dmwatcher.ini
守护进程启动后,会将 mount 状态的实例启动到 open状态。
6.2.手动启动dmmonitor
bash
vim /dmdata/dmdb/dmmonitor.ini
bash
[monitor] 2023-12-08 16:31:58: DMMONITOR[4.0] V8
[monitor] 2023-12-08 16:31:59: DMMONITOR[4.0] IS READY.
show global info
组(GRP_DW)中没有活动实例或者监视器还未收到守护进程消息
[monitor] 2023-12-08 16:34:11:
#--------------------------------------------------------------------------------#
GET MONITOR CONNECT INFO FROM DMWATCHER(DM01), THE FIRST LINE IS SELF INFO.
DW_CONN_TIME MON_CONFIRM MID MON_IP MON_VERSION
2023-12-08 16:34:11 FALSE 1508472236 ::ffff:10.76.18.199 DMMONITOR[4.0] V8
2023-12-08 16:34:11 FALSE 1385275602 ::ffff:10.76.18.200 DMMONITOR[4.0] V8
#--------------------------------------------------------------------------------#
[monitor] 2023-12-08 16:34:11: 收到守护进程(DM01)消息
[monitor] 2023-12-08 16:35:37: 收到守护进程(DM02)消息
[monitor] 2023-12-08 16:36:06: 守护进程(DM02)状态切换 [STARTUP-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:36:06 OPEN OK DM02 OPEN STANDBY VALID 1 41550 41550
[monitor] 2023-12-08 16:36:08: 守护进程(DM01)状态切换 [STARTUP-->UNIFY EP]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:36:08 UNIFY EP OK DM01 MOUNT PRIMARY VALID 1 41550 41550
[monitor] 2023-12-08 16:36:09: 守护进程(DM01)状态切换 [UNIFY EP-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:36:09 OPEN OK DM01 OPEN PRIMARY VALID 2 41551 41718
可能遇到的问题: 如果实例没有自动启动到open状态,需要手动强制启动主备实例到open状态
关闭dmwatcher
主备节点分别disql执行:
sp_set_para_value(1,'ALTER_MODE_STATUS',1);
alter database open force;
[回目录](# 目录)
7.主备节点手动切换
dmmonitor查看全局信息
bash
dmmonitor /dmdata/dmdb/dmmonitor.ini
bash
[monitor] 2023-12-08 16:47:23: DMMONITOR[4.0] V8
[monitor] 2023-12-08 16:47:24: DMMONITOR[4.0] IS READY.
[monitor] 2023-12-08 16:47:24:
#--------------------------------------------------------------------------------#
GET MONITOR CONNECT INFO FROM DMWATCHER(DM01), THE FIRST LINE IS SELF INFO.
DW_CONN_TIME MON_CONFIRM MID MON_IP MON_VERSION
2023-12-08 16:47:24 FALSE 2002194316 ::ffff:10.76.18.199 DMMONITOR[4.0] V8
2023-12-08 16:34:11 FALSE 1385275602 ::ffff:10.76.18.200 DMMONITOR[4.0] V8
#--------------------------------------------------------------------------------#
[monitor] 2023-12-08 16:47:24: 收到守护进程(DM01)消息
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:47:24 OPEN OK DM01 OPEN PRIMARY VALID 2 41718 41718
[monitor] 2023-12-08 16:47:24: 收到守护进程(DM02)消息
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:47:24 OPEN OK DM02 OPEN STANDBY VALID 2 41718 41718
show global info
2023-12-08 16:48:03
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP_DW 453402 FALSE MANUAL FALSE
<<DATABASE GLOBAL INFO:>>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.199 7436 2023-12-08 16:48:03 GLOBAL VALID OPEN DM01 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.200 7436 2023-12-08 16:48:03 GLOBAL VALID OPEN DM02 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID
#================================================================================#
#### 登录monitor
login
用户名:sysdba
密码:
[monitor] 2023-12-08 16:48:59: 登录监视器成功!
switchover GRP_DW.DM02
[monitor] 2023-12-08 16:49:21: 开始切换实例DM02
[monitor] 2023-12-08 16:49:21: 通知守护进程DM01切换SWITCHOVER状态
[monitor] 2023-12-08 16:49:21: 守护进程(DM01)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-12-08 16:49:22: 切换守护进程DM01为SWITCHOVER状态成功
[monitor] 2023-12-08 16:49:22: 通知守护进程DM02切换SWITCHOVER状态
[monitor] 2023-12-08 16:49:22: 守护进程(DM02)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-12-08 16:49:23: 切换守护进程DM02为SWITCHOVER状态成功
[monitor] 2023-12-08 16:49:23: 实例DM01开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-12-08 16:49:24: 实例DM01执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-12-08 16:49:24: 实例DM02开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-12-08 16:49:24: 实例DM02执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-12-08 16:49:24: 实例DM01开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-12-08 16:49:24: 实例DM01执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-12-08 16:49:24: 实例DM02开始执行SP_APPLY_KEEP_PKG()语句
[monitor] 2023-12-08 16:49:24: 实例DM02执行SP_APPLY_KEEP_PKG()语句成功
[monitor] 2023-12-08 16:49:24: 实例DM02开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-12-08 16:49:24: 实例DM02执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-12-08 16:49:24: 实例DM01开始执行ALTER DATABASE STANDBY语句
[monitor] 2023-12-08 16:49:26: 实例DM01执行ALTER DATABASE STANDBY语句成功
[monitor] 2023-12-08 16:49:26: 实例DM02开始执行ALTER DATABASE PRIMARY语句
[monitor] 2023-12-08 16:49:27: 实例DM02执行ALTER DATABASE PRIMARY语句成功
[monitor] 2023-12-08 16:49:27: 通知实例DM02修改所有归档状态无效
[monitor] 2023-12-08 16:49:27: 修改所有实例归档为无效状态成功
[monitor] 2023-12-08 16:49:27: 实例DM01开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-12-08 16:49:27: 实例DM01执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-12-08 16:49:27: 实例DM02开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-12-08 16:49:27: 实例DM02执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-12-08 16:49:27: 实例DM01开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-12-08 16:49:27: 实例DM01执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-12-08 16:49:27: 实例DM02开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-12-08 16:49:27: 实例DM02执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-12-08 16:49:27: 通知守护进程DM01切换OPEN状态
[monitor] 2023-12-08 16:49:27: 守护进程(DM01)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-12-08 16:49:28: 切换守护进程DM01为OPEN状态成功
[monitor] 2023-12-08 16:49:28: 通知守护进程DM02切换OPEN状态
[monitor] 2023-12-08 16:49:29: 守护进程(DM02)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-12-08 16:49:29: 切换守护进程DM02为OPEN状态成功
[monitor] 2023-12-08 16:49:29: 通知组(GRP_DW)的守护进程执行清理操作
[monitor] 2023-12-08 16:49:30: 清理守护进程(DM01)请求成功
[monitor] 2023-12-08 16:49:30: 清理守护进程(DM02)请求成功
[monitor] 2023-12-08 16:49:30: 实例DM02切换成功
2023-12-08 16:49:31
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP_DW 453402 FALSE MANUAL FALSE
<<DATABASE GLOBAL INFO:>>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.200 7436 2023-12-08 16:49:30 GLOBAL VALID OPEN DM02 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID
EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
10.76.18.200 5236 OK DM02 OPEN PRIMARY 0 0 REALTIME VALID 4834 41904 4834 41904 NONE
<<DATABASE GLOBAL INFO:>>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.199 7436 2023-12-08 16:49:30 GLOBAL VALID OPEN DM01 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME INVALID
EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
10.76.18.199 5236 OK DM01 OPEN STANDBY 0 0 REALTIME INVALID 4832 41719 4832 41719 NONE
DATABASE(DM01) APPLY INFO FROM (DM02), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4832, 4832, 4832], (RLSN, SLSN, KLSN)[41719, 41719, 41719], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (41719)
#================================================================================#
[monitor] 2023-12-08 16:49:31: 守护进程(DM02)状态切换 [OPEN-->RECOVERY]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:49:31 RECOVERY OK DM02 OPEN PRIMARY VALID 3 41904 41904
[monitor] 2023-12-08 16:49:34: 守护进程(DM02)状态切换 [RECOVERY-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:49:34 OPEN OK DM02 OPEN PRIMARY VALID 3 41904 41904
show global info
2023-12-08 16:50:26
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP_DW 453402 FALSE MANUAL FALSE
<<DATABASE GLOBAL INFO:>>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.200 7436 2023-12-08 16:50:26 GLOBAL VALID OPEN DM02 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.199 7436 2023-12-08 16:50:26 GLOBAL VALID OPEN DM01 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME VALID
#================================================================================#
#### 将节点1切换为主节点
switchover GRP_DW.DM01
[monitor] 2023-12-08 16:50:39: 开始切换实例DM01
[monitor] 2023-12-08 16:50:39: 通知守护进程DM02切换SWITCHOVER状态
[monitor] 2023-12-08 16:50:40: 守护进程(DM02)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-12-08 16:50:40: 切换守护进程DM02为SWITCHOVER状态成功
[monitor] 2023-12-08 16:50:40: 通知守护进程DM01切换SWITCHOVER状态
[monitor] 2023-12-08 16:50:41: 守护进程(DM01)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-12-08 16:50:41: 切换守护进程DM01为SWITCHOVER状态成功
[monitor] 2023-12-08 16:50:41: 实例DM02开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-12-08 16:50:41: 实例DM02执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-12-08 16:50:41: 实例DM01开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-12-08 16:50:41: 实例DM01执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-12-08 16:50:41: 实例DM02开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-12-08 16:50:41: 实例DM02执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-12-08 16:50:41: 实例DM01开始执行SP_APPLY_KEEP_PKG()语句
[monitor] 2023-12-08 16:50:41: 实例DM01执行SP_APPLY_KEEP_PKG()语句成功
[monitor] 2023-12-08 16:50:41: 实例DM01开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-12-08 16:50:41: 实例DM01执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-12-08 16:50:41: 实例DM02开始执行ALTER DATABASE STANDBY语句
[monitor] 2023-12-08 16:50:42: 实例DM02执行ALTER DATABASE STANDBY语句成功
[monitor] 2023-12-08 16:50:42: 实例DM01开始执行ALTER DATABASE PRIMARY语句
[monitor] 2023-12-08 16:50:43: 实例DM01执行ALTER DATABASE PRIMARY语句成功
[monitor] 2023-12-08 16:50:43: 通知实例DM01修改所有归档状态无效
[monitor] 2023-12-08 16:50:43: 修改所有实例归档为无效状态成功
[monitor] 2023-12-08 16:50:43: 实例DM02开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-12-08 16:50:43: 实例DM02执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-12-08 16:50:43: 实例DM01开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-12-08 16:50:44: 实例DM01执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-12-08 16:50:44: 实例DM02开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-12-08 16:50:44: 实例DM02执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-12-08 16:50:44: 实例DM01开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-12-08 16:50:44: 实例DM01执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-12-08 16:50:44: 通知守护进程DM02切换OPEN状态
[monitor] 2023-12-08 16:50:44: 守护进程(DM02)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-12-08 16:50:45: 切换守护进程DM02为OPEN状态成功
[monitor] 2023-12-08 16:50:45: 通知守护进程DM01切换OPEN状态
[monitor] 2023-12-08 16:50:45: 守护进程(DM01)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-12-08 16:50:45: 切换守护进程DM01为OPEN状态成功
[monitor] 2023-12-08 16:50:45: 通知组(GRP_DW)的守护进程执行清理操作
[monitor] 2023-12-08 16:50:45: 清理守护进程(DM01)请求成功
[monitor] 2023-12-08 16:50:46: 清理守护进程(DM02)请求成功
[monitor] 2023-12-08 16:50:46: 实例DM01切换成功
2023-12-08 16:50:46
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
GRP_DW 453402 FALSE MANUAL FALSE
<<DATABASE GLOBAL INFO:>>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.199 7436 2023-12-08 16:50:45 GLOBAL VALID OPEN DM01 OK 1 1 OPEN PRIMARY DSC_OPEN REALTIME VALID
EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
10.76.18.199 5236 OK DM01 OPEN PRIMARY 0 0 REALTIME VALID 4837 42090 4837 42090 NONE
<<DATABASE GLOBAL INFO:>>
DW_IP MAL_DW_PORT WTIME WTYPE WCTLSTAT WSTATUS INAME INST_OK N_EP N_OK ISTATUS IMODE DSC_STATUS RTYPE RSTAT
10.76.18.200 7436 2023-12-08 16:50:45 GLOBAL VALID OPEN DM02 OK 1 1 OPEN STANDBY DSC_OPEN REALTIME INVALID
EP INFO:
INST_IP INST_PORT INST_OK INAME ISTATUS IMODE DSC_SEQNO DSC_CTL_NODE RTYPE RSTAT FSEQ FLSN CSEQ CLSN DW_STAT_FLAG
10.76.18.200 5236 OK DM02 OPEN STANDBY 0 0 REALTIME INVALID 4835 41905 4835 41905 NONE
DATABASE(DM02) APPLY INFO FROM (DM01), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[4835, 4835, 4835], (RLSN, SLSN, KLSN)[41905, 41905, 41905], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (41905)
#================================================================================#
[monitor] 2023-12-08 16:50:48: 守护进程(DM01)状态切换 [OPEN-->RECOVERY]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:50:48 RECOVERY OK DM01 OPEN PRIMARY VALID 4 42090 42090
[monitor] 2023-12-08 16:50:51: 守护进程(DM01)状态切换 [RECOVERY-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-12-08 16:50:51 OPEN OK DM01 OPEN PRIMARY VALID 4 42090 42090
[回目录](# 目录)
8.注册服务
以上启动为前台方式启动,仅用户搭建过程中验证配置。配置没问题后需要将实例,守护进程配置为系统服务。使用 root 用户,到数据库安装目录的/dm8/script/root下。
注册守护进程服务(主备库都执行)。
bash
/dm8/script/root/dm_service_installer.sh -t dmwatcher -p dw -watcher_ini /dmdata/dmdb/dmwatcher.ini
注册数据库实例服务(主备库都执行):
bash
/dm8/script/root/dm_service_installer.sh -t dmserver -p dw -dm_ini /dmdata/dmdb/dm.ini
以服务方式启动
执行以下命令,启动数据库实例:
systemctl start DmServicedw
执行以下命令,启动守护进程:
systemctl start DmWatcherServicedw
节点2使用dmmonitor监控
[dmdba@0002 ~]$ dmmonitor /dmdata/dmdb/dmmonitor.ini
[monitor] 2023-06-05 10:47:16: DMMONITOR[4.0] V8
[monitor] 2023-06-05 10:47:17: DMMONITOR[4.0] IS READY.
[monitor] 2023-06-05 10:47:17: 收到守护进程(DM02)消息
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-06-05 10:47:17 OPEN OK DM02 OPEN STANDBY NULL 8 119590 119590
[monitor] 2023-06-05 10:47:17:
#--------------------------------------------------------------------------------#
GET MONITOR CONNECT INFO FROM DMWATCHER(DM02), THE FIRST LINE IS SELF INFO.
DW_CONN_TIME MON_CONFIRM MID MON_IP MON_VERSION
2023-06-05 10:47:17 FALSE 1093666190 ::ffff:10.223.189.19 DMMONITOR[4.0] V8
#--------------------------------------------------------------------------------#
[monitor] 2023-06-05 10:47:17: 收到守护进程(DM01)消息
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-06-05 10:47:17 OPEN OK DM01 OPEN PRIMARY VALID 8 119590 119591
使用 disql 客户端登录主库,创建测试表,插入数据,执行以下命令:
disql SYSDBA/'"Hn@dameng123"'@10.223.189.18:5236
SQL 提示符下执行以下命令:
create table test(id int);
insert into test values (1);
commit;
使用disql客户端登录备库,查询测试表验证,执行以下命令:
disql SYSDBA/'"Hn@dameng123"'@10.223.189.19:5236
SQL 提示符下执行以下命令:
select * from test;
查看数据是否正常同步。
```
[回目录](# 目录)
主节点上创建备份账号
```shell
账号具备BACKUP DATABASE和RESTORE DATABASE权限和部分查询权限,
"SYS"."V$DM_INI",
"SYS"."V$BACKUPSET"
"SYS"."V$BACKUPSET_SUBS"
"SYS"."V$BACKUPSET_TABLE"
"SYS"."V$BACKUPSET_SEARCH_DIRS"
"SYS"."V$BACKUPSET_BKP"
"SYS"."V$BACKUPSET_DBF"
"SYS"."V$BACKUPSET_DBINFO"
"SYS"."V$BACKUPSET_ARCH"
"SYS"."V$CIPHERS"
"SYS"."V$RLOG"
"SYS"."V$DM_MAL_INI"
"SYS"."V$DM_ARCH_INI"
"SYS"."V$DATAFILE"
"SYS"."V$RLOGFILE"
添加这些表的查询权限
create user forbackup identified by "uD_NS4l0BhYO7q";
grant create session to forbackup;
grant backup database to forbackup;
grant restore database to forbackup;
grant select on "SYS"."V$DM_INI" to forbackup;
grant select on "SYS"."V$BACKUPSET" to forbackup;
grant select on "SYS"."V$BACKUPSET_SUBS" to forbackup;
grant select on "SYS"."V$BACKUPSET_TABLE" to forbackup;
grant select on "SYS"."V$BACKUPSET_SEARCH_DIRS" to forbackup;
grant select on "SYS"."V$BACKUPSET_BKP" to forbackup;
grant select on "SYS"."V$BACKUPSET_DBF" to forbackup;
grant select on "SYS"."V$BACKUPSET_DBINFO" to forbackup;
grant select on "SYS"."V$BACKUPSET_ARCH" to forbackup;
grant select on "SYS"."V$CIPHERS" to forbackup;
grant select on "SYS"."V$RLOG" to forbackup;
grant select on "SYS"."V$DM_MAL_INI" to forbackup;
grant select on "SYS"."V$DM_ARCH_INI" to forbackup;
grant select on "SYS"."V$DATAFILE" to forbackup;
grant select on "SYS"."V$RLOGFILE" to forbackup;
```
创建业务账号
```shell
运维平台流程单号:2023061600044
达梦数据库资源分配情况:
url: jdbc:dm://dmconn?dmconn=(10.76.18.115:5236,10.76.18.116:5236)&rw_Separate=(1)
hbmmc : 智慧住建-BIM应用工程-房建BIM模型管理中心 : Housing BIM Model Management Center
数据库用户:SC_SDSP
数据库密码:
create user SC_SDSP identified by "h3~328;Vw5:BNQo!5";
grant "RESOURCE" to SC_SDSP;
grant select on v$ciphers to SC_SDSP;
```
jdbc连接主备集群
```shell
url: jdbc:dm://dmconn?dmconn=(10.76.18.115:5236,10.76.18.116:5236)&rw_Separate=(1)
```
等保安全整改项
```shell
启用客体重用:对已释放内存和文件上的内容进行清除
sp_set_para_value(2,'ENABLE_OBJ_REUSE',1);
SELECT * FROM V$PARAMETER WHERE NAME='ENABLE_OBJ_REUSE';
需要重新启动达梦主备数据库
systemctl restart DmServicedw
```
[回目录](# 目录)