达梦共享集群dsc+实时主备搭建
达梦共享集群dsc+实时主备搭建
环境准备
主机用途 |
对外IP |
心跳ip |
实例名 |
操作系统 |
数据库版本 |
DSC主库 |
192.168.10.75 |
192.168.20.15 |
DSC0 |
centos 7 |
dm8 ENT |
192.168.10.76 |
192.168.20.16 |
DSC1 |
centos 7 |
dm8 ENT |
|
单机备库 |
192.168.10.74 |
192.168.20.14 |
DM74 |
centos 7 |
dm8 ENT |
共享磁盘50G,划分4个分区存放不同的文件
/dev/sdb1 raw1 dcr 2.5G
/dev/sdb2 raw2 voting 5G
/dev/sdb3 raw3 log 7.5G
/dev/sdb4 raw4 data 35G
操作系统配置
关闭SELINUX,防火墙
vi /etc/selinux/configS ELINUX=disabled
systemctl stop firewalld
systemctl disable firewalld
创建用户组和安装目录
mkdir -p /dm8
mkdir -p /dm8/config
groupadd dinstall
useradd -g dinstall dmdba
chown -R dmdba:dinstall /dm8
passwd dmdba
修改hosts文件
echo "
192.168.10.75 m5
192.168.10.76 m6
192.168.10.74 m4" >> /etc/hosts
设置文件最大打开数目
cat >> /etc/security/limits.conf << EOF
dmdba soft nofile 65536
dmdba hard nofile 65536
EOF
安装数据库(过程忽略),DSC集群切记不要初始化数据
库!!!
DSC 集群部署
裸设备绑定
vim /etc/udev/rules.d/60-raw.rules
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdb3", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdb4", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="raw[1-4]", OWNER="dmdba", GROUP="dinstall",
MODE="660"
完成裸设备绑定
systemctl restart systemd-udev-trigger.service
查看绑定的裸设备
ll /dev/raw*
查看裸设备大小
blockdev --getsize64 /dev/raw/raw*
切换到dmdba用户 ,后续命令都在/dm8/bin下执行,dsc配置文件
都放在在/dm8/config下
vim dmdcr_cfg.ini #两节点配置相同
DCR_N_GRP = 3
DCR_VTD_PATH = /dev/raw/raw2
DCR_OGUID = 63635
[GRP]
DCR_GRP_TYPE = CSS
DCR_GRP_NAME = GRP_CSS
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_CSS]
DCR_EP_NAME = CSS0
DCR_EP_HOST = 192.168.20.15 #
DCR_EP_PORT = 9341
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 192.168.20.16
DCR_EP_PORT = 9341
[GRP]
DCR_GRP_TYPE = ASM
DCR_GRP_NAME = GRP_ASM
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_ASM]
DCR_EP_NAME = ASM0
DCR_EP_SHM_KEY = 93360
DCR_EP_SHM_SIZE = 10
DCR_EP_HOST = 192.168.10.75 #实例的对外服务 IP 地址
DCR_EP_PORT = 9349
DCR_EP_ASM_LOAD_PATH = /dev/raw
[GRP_ASM]
DCR_EP_NAME = ASM1
DCR_EP_SHM_KEY = 93361
DCR_EP_SHM_SIZE = 10
DCR_EP_HOST = 192.168.10.76 #实例的对外服务 IP 地址
DCR_EP_PORT = 9349
DCR_EP_ASM_LOAD_PATH = /dev/raw
[GRP]
DCR_GRP_TYPE = DB
DCR_GRP_NAME = GRP_DSC
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 60
[GRP_DSC]
DCR_EP_NAME = DSC0
DCR_EP_SEQNO = 0
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741
[GRP_DSC]
DCR_EP_NAME = DSC1
DCR_EP_SEQNO = 1
DCR_EP_PORT = 5236
DCR_CHECK_PORT = 9741
使用 DMASMCMD 工具初始化(m5节点执行即可)
./dmasmcmd
create dcrdisk '/dev/raw/raw1' 'dcr'
create votedisk '/dev/raw/raw2' 'vote'
create asmdisk '/dev/raw/raw3' 'LOG0'
create asmdisk '/dev/raw/raw4' 'DATA0'
init dcrdisk '/dev/raw/raw1' from '/dm8/config/dmdcr_cfg.ini' identified by 'dm123'
init votedisk '/dev/raw/raw2' from '/dm8/config/dmdcr_cfg.ini'
准备 DMASM 的 MAL 配置文件(命名为 dmasvrmal.ini),两
节点配置一样
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 192.168.20.15
MAL_PORT = 7236
[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 192.168.20.16
MAL_PORT = 7236
配置 dmdcr.ini,dmdcr_seqo 分别为 0 和 1。
节点一 m5
DMDCR_PATH = /dev/raw/raw1
DMDCR_MAL_PATH =/dm8/config/dmasvrmal.ini #dmasmsvr 使用的 MAL 配置文件路径
DMDCR_SEQNO = 0
#ASM 重启参数,命令行方式启动
DMDCR_ASM_RESTART_INTERVAL = 0
DMDCR_ASM_STARTUP_CMD = /dm8/bin/dmasmsvr dcr_ini=/dm8/config/dmdcr.ini
#DB 重启参数,命令行方式启动
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD = /dm8/bin/dmserver
path=/dm8/config/dsc0_config/dm.ini dcr_ini=/dm8/config/dmdcr.ini
节点二 m6
DMDCR_PATH = /dev/raw/raw1
DMDCR_MAL_PATH =/dm8/config/dmasvrmal.ini #dmasmsvr 使用的 MAL 配置文件路径
DMDCR_SEQNO = 1
#ASM 重启参数,命令行方式启动
DMDCR_ASM_RESTART_INTERVAL = 0
DMDCR_ASM_STARTUP_CMD = /dm8/bin/dmasmsvr dcr_ini=/dm8/config/dmdcr.ini
#DB 重启参数,命令行方式启动
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD = /dm8/bin/dmserver
path=/dm8/config/dsc1_config/dm.ini dcr_ini=/dm8/config/dmdcr.ini
两节点分别启动 DMCSS、DMASM 服务程序
./dmcss DCR_INI=/dm8/config/dmdcr.ini
./dmasmsvr DCR_INI=/dm8/config/dmdcr.ini
使用 dmasmtool 工具创建 DMASM 磁盘组(m5节点执行)
./dmasmtool DCR_INI=/dm8/config/dmdcr.ini
create diskgroup 'DMLOG' asmdisk '/dev/raw/raw3'
create diskgroup 'CONFIG' asmdisk '/dev/raw/raw4'
配置dminit.ini 文件(m5节点配置)
db_name = dsc
system_path = +CONFIG/data
system = +CONFIG/data/dsc/system.dbf
system_size = 128
roll = +CONFIG/data/dsc/roll.dbf
roll_size = 128
main = +CONFIG/data/dsc/main.dbf
main_size = 128
ctl_path = +CONFIG/data/dsc/dm.ctl
ctl_size = 8
log_size = 256
dcr_path = /dev/raw/raw1 #dcr 磁盘路径,目前不支持 asm,只能是裸设备
dcr_seqno = 0
auto_overwrite = 1
charset =1 #字符集为 utf8
page_size =32
[DSC0] #inst_name 跟 dmdcr_cfg.ini 中 DB 类型 group 中 DCR_EP_NAME 对应
config_path = /dm8/config/dsc0_config
port_num = 5236
mal_host = 192.168.20.15
mal_port = 9236
log_path = +DMLOG/log/dsc0_log01.log
log_path = +DMLOG/log/dsc0_log02.log
[DSC1] #inst_name 跟 dmdcr_cfg.ini 中 DB 类型 group 中 DCR_EP_NAME 对应
config_path = /dm8/config/dsc1_config
port_num = 5236
mal_host = 192.168.20.16
mal_port = 9236
log_path = +DMLOG/log/dsc1_log01.log
log_path = +DMLOG/log/dsc1_log02.log
启动 dminit 工具初始化数据库(m5节点执行)
./dminit control=/dm8/config/dminit.ini
dminit 执行完成后,生成两个(/dm8/config/dsc0_config 和/config/dsc1_config)配置文
件 ,将/data/dsc1_config 目录拷贝到另外一个节点相同目录下
scp -r /dm8/config/dsc1_config/ dmdba@192.168.10.76:/dm8/config
m5节点启动 dmserver
./dmserver /dm8/config/dsc0_config/dm.ini dcr_ini=/dm8/config/dmdcr.ini
m6节点启动 dmserver
./dmserver /dm8/config/dsc1_config/dm.ini dcr_ini=/dm8/config/dmdcr.ini
启动成功之后,任意一节点登录数据库验证
select * from v$dsc_ep_info;
Root用户注册 DMCSS和DMASM服务 ,/dm8/script/root/目
录下面
./dm_service_installer.sh -t dmcss -dcr_ini /dm8/config/dmdcr.ini -p DMCSS
./dm_service_installer.sh -t dmasmsvr -dcr_ini /dm8/config/dmdcr.ini -p DMASM -y DmCSSServiceDMCSS
./dm_service_installer.sh -t dmserver -p DMSERVER -dm_ini
/dm8/config/dsc0_config/dm.ini -dcr_ini /dm8/config/dmdcr.ini -y
DmASMSvrServiceDMASM
配置监视器 dmcssm.ini
CSSM_OGUID = 63635
#配置所有 CSS 的连接信息,
#和 dmdcr_cfg.ini 中 CSS 配置项的 DCR_EP_HOST 和 DCR_EP_PORT 保持一致
CSSM_CSS_IP = 192.168.20.15:9341
CSSM_CSS_IP = 192.168.20.16:9341
CSSM_LOG_PATH =/dm8/dsc_log #监视器日志文件存放路径
CSSM_LOG_FILE_SIZE = 32 #每个日志文件最大 32M
CSSM_LOG_SPACE_LIMIT =1000 #不限定日志文件总占用空间
启动监视器
./dmcssm INI_PATH=/dm8/config/dmcssm.ini
DSC主库+单机备库部署
在监视器关闭DSC数据库服务
ep stop GRP_DSC
使用 dmrman 工具备份数据库,任意一个DSC节点执行,使用dmdba用户操作
./dmrman use_ap=2 dcr_ini=/dm8/config/dmdcr.ini
RMAN>BACKUP DATABASE '/dm8/config/dsc0_config/dm.ini' FULL BACKUPSET
'/dm8/config/dscfullbakup';
初始化单节点备库
./dminit PATH=/dm8/data INSTANCE_NAME=DM74 charset=1 page_size=32
备份完成将备份文件拷贝到单节点备库
scp -r /dm8/config/dscfullbakup dmdba@192.168.10.74:/dm8/data/
在单节点备库使用dmrman脱机还原
RESTORE DATABASE '/dm8/data/DAMENG/dm.ini' FROM BACKUPSET
'/dm8/data/dscfullbakup';
RECOVER DATABASE '/dm8/data/DAMENG/dm.ini' FROM BACKUPSET
'/dm8/data/dscfullbakup';
RECOVER DATABASE '/dm8/data/DAMENG/dm.ini' UPDATE DB_MAGIC;
分别编辑两个 DSC 节点的 dm.ini 文件
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
ARCH_INI = 1 #开启归档模式
MAL_INI = 1
后面配置文件都在实例dm.ini同一目录下
在 DSC 集群的 dmmal.ini 文件基础上,增加备库 DM74 的配置项。所有节
点 dmmal.ini 文件内容是一致的
[MAL_INST0]
MAL_INST_NAME = DSC0 #实例名,和 dm.ini 中的 INSTANCE_NAME 一致
MAL_HOST = 192.168.20.15 #MAL 系统监听 TCP 连接的 IP 地址
MAL_PORT = 9236 #MAL 系统监听 TCP 连接的端口
MAL_INST_HOST = 192.168.10.75 #实例的对外服务 IP 地址
MAL_INST_PORT = 5236 #实例的对外服务端口,和 dm.ini 中的 PORT_NUM 一致
MAL_DW_PORT = 3567 #实例本地的守护进程监听 TCP 连接的端口
MAL_INST_DW_PORT = 4567 #实例监听守护进程 TCP 连接的端口
[MAL_INST1]
MAL_INST_NAME = DSC1
MAL_HOST = 192.168.20.16
MAL_PORT = 9236
MAL_INST_HOST = 192.168.10.76
MAL_INST_PORT = 5237 #实例的对外服务端口,和 dm.ini 中的 PORT_NUM 一致
MAL_DW_PORT = 3567
MAL_INST_DW_PORT = 4567
[MAL_INST2]
MAL_INST_NAME = DM74
MAL_HOST = 192.168.20.14
MAL_PORT = 9236
MAL_INST_HOST = 192.168.10.74
MAL_INST_PORT = 5236
MAL_DW_PORT = 3567
MAL_INST_DW_PORT = 4567
修改 DSC0 的 dmarch.ini 文件
ARCH_WAIT_APPLY = 1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/config/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 51200
[ARCHIVE_REMOTE]
ARCH_TYPE = REMOTE
ARCH_DEST = DSC1
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 51200
ARCH_INCOMING_PATH = /dm8/config/arch_remote
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DM74
修改 DSC1 的 dmarch.ini 文件
ARCH_WAIT_APPLY = 1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/config/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 51200
[ARCHIVE_REMOTE]
ARCH_TYPE = REMOTE
ARCH_DEST = DSC0
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 51200
ARCH_INCOMING_PATH = /dm8/config/arch_remote
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DM74
配置 DSC0 的 dmwatcher.ini 文件
[GRP1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = MANUAL #手动切换模式
DW_ERROR_TIME = 60 #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #主库守护进程启动恢复的间隔时间
INST_ERROR_TIME = 35 #本地实例故障认定时间
INST_INI = /dm8/config/dsc0_config/dm.ini#dm.ini 配置文件路径
DCR_INI = /dm8/config/dmdcr.ini #dmdcr.ini 配置文件路径
INST_OGUID = 1000 #守护系统唯一 OGUID 值
INST_AUTO_RESTART = 0 #关闭实例的自动启动功能
配置 DSC1 的 dmwatcher.ini 文件
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 35
INST_INI = /dm8/config/dsc1_config/dm.ini
DCR_INI = /dm8/config/dmdcr.ini
INST_OGUID = 1000
INST_AUTO_RESTART = 0
修改单机备库实例dm.ini文件
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
ARCH_INI = 1 #开启归档模式
MAL_INI = 1 #开启 MAL 系统
配置单机备库dmarch.ini
arch_wait_apply=1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/data/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 51200
[ARCHIVE_REALTIME1]
ARCH_TYPE = REALTIME
ARCH_DEST = DSC0/DSC1
配置单机备库mal系统dmmal.ini 和dsc节点一致
配置单机备库守护进程dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 35
INST_INI = /dm8/data/DAMENG/dm.ini
INST_OGUID = 1000
INST_STARTUP_CMD = /dm8/bin/dmserver
INST_AUTO_RESTART = 1 #对单节点,如果需要打开自动拉起功能,将此配置修改为 1 即可
启动所有实例到 mount 状态
./dmserver /dm8/config/dsc0_config/dm.ini dcr_ini=/dm8/config/dmdcr.ini mount
./dmserver /dm8/config/dsc1_config/dm.ini dcr_ini=/dm8/config/dmdcr.ini mount
./dmserver /dm8/data/DAMENG/dm.ini mount
启动命令行工具 DIsql,连接 DMDSC 集群中的任意一个节点,设
置OGUID, 修改 库为Primary 模式。
SP_SET_OGUID(1000);
ALTER DATABASE PRIMARY;
DIsql 连接单节点备库,修改OGUID及修改库为 Standby 模式
SP_SET_OGUID(1000);
ALTER DATABASE STANDBY;
启动所有节点守护进程
./dmwatcher /dm8/config/dsc0_config/dmwatcher.ini
./dmwatcher /dm8/config/dsc1_config/dmwatcher.ini
./dmwatcher /dm8/data/DAMENG/dmwatcher.ini
配置监视器 dmmonitor.ini,本示例在单机备机上配置
MON_DW_CONFIRM = 0 #0监控监视器模式 1确认监视器模式
MON_LOG_PATH = /dm8/data/monitor_log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 64
MON_LOG_SPACE_LIMIT = 0
MON_DW_CONFIRM = 0
[GRP1]
MON_INST_OGUID = 1000
MON_DW_IP = 192.168.20.15:3567/192.168.20.16:3567
MON_DW_IP = 192.168.20.14:3567
启动监视器
./dmmonitor /dm8/data/DAMENG/dmmonitor.ini
登录数据库测试,验证数据库是否正常同步
创建实例服务
./dm_service_installer.sh -t dmserver -p DAMENG -dm_ini /dm8/data/DAMENG/dm.ini
创建守护进程服务
./dm_service_installer.sh -t dmwatcher -p DMWATCHER -watcher_ini /dm8/config/dsc0_config/dmwatcher.ini -dcr_ini /dm8/config/dmdcr.ini -y DmASMSvrServiceDMASM
./dm_service_installer.sh -t dmwatcher -p DMWATCHER -watcher_ini /dm8/config/dsc1_config/dmwatcher.ini -dcr_ini /dm8/config/dmdcr.ini -y DmASMSvrServiceDMASM
./dm_service_installer.sh -t dmwatcher -p DMWATCHER -watcher_ini /dm8/data/DAMENG/dmwatcher.ini
如果需要把备库切换为主库 switchover GRP1.DM74
把主库切换为备库 switchover GRP1.DSC0