1)总体配置:两个节点的DSC集群,搭建完成后再增加一个备库
具体规划如下表
操作系统:CentOS7.9
数据库版本:dm8_20231011_x86_rh6_64
2)磁盘规划
在第一个节点虚拟机添加4块磁盘:dmdcr、dmvote、dmlog、dmdata01,大小分别为1G、1G、10G、20G
第二个节点使用已经添加好的现有磁盘
注意:这里必须选择独立和永久,添加磁盘之前虚拟机不要做快照,否则后续会报磁盘版本不一致的错误。
添加完后更改虚拟机配置文件:虚拟机文件夹中的vmx后缀文件,添加下列语句
disk.locking="FALSE"
disk.SharedBus="Virtual"
disk.enableUUID="TRUE" ---可以查询到添加磁盘的uuid,用于后续绑定磁盘
disk.shared="TRUE" ---这里必须添加,否则最后启动节点2的css服务时会报找不到控制文件
开启虚拟机
1)新建组和用户,修改文件最大打开数
groupadd dinstall
useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
passwd dmdba
vim /etc/security/limits.conf
dmdba soft nproc 16384
dmdba hard nproc 16384
dmdba soft nofile 65536
dmdba hard nofile 65536
dmdba soft stack 16384
dmdba hard stack 32768
2)udev绑定磁盘
查询磁盘uuid:/usr/lib/udev/scsi_id -g -u -d /dev/sdb
在目录/etc/udev/rules.d中新建文件88-dm-asmdevices.rules
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29da7f8e70fa6a8de81f7903ba7", SYMLINK+="dmdcr",OWNER="dmdba", GROUP="dinstall",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2984ef8e0315d16594484f9313d", SYMLINK+="dmvote",OWNER="dmdba", GROUP="dinstall",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29c3e5e1b67b4829b8b3d50c7c7", SYMLINK+="dmlog",OWNER="dmdba", GROUP="dinstall",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29cd92c0ef73779c2b5ee44a3e8", SYMLINK+="dmdata01",OWNER="dmdba", GROUP="dinstall",MODE="0660"
使之生效:/sbin/udevadm trigger --type=devices --action=change
在目录/dev下就可以看到我们添加的磁盘
3)创建目录,命令行安装数据库到目录/dm下
mkdir -p /dm8_setup/iso
mount /dm8_setup/iso/dm8_20231011_x86_rh6_64.iso /mnt
mkdir /dm
chown dmdba:dinstall /dm
su - dmdba
./DMInstall.bin –i
[dmdba@localhost mnt]$ ./DMInstall.bin -i
安装语言:
[1]: 简体中文
[2]: English
请选择安装语言 [1]:
解压安装程序..........
欢迎使用达梦数据库安装程序
是否输入Key文件路径? (Y/y:是 N/n:否) [Y/y]:n
是否设置时区? (Y/y:是 N/n:否) [Y/y]:y
设置时区:
[ 1]: (GTM-12:00) 日界线西
[ 2]: (GTM-11:00) 萨摩亚群岛
[ 3]: (GTM-10:00) 夏威夷
[ 4]: (GTM-09:00) 阿拉斯加
[ 5]: (GTM-08:00) 太平洋时间(美国和加拿大)
[ 6]: (GTM-07:00) 亚利桑那
[ 7]: (GTM-06:00) 中部时间(美国和加拿大)
[ 8]: (GTM-05:00) 东部部时间(美国和加拿大)
[ 9]: (GTM-04:00) 大西洋时间(美国和加拿大)
[10]: (GTM-03:00) 巴西利亚
[11]: (GTM-02:00) 中大西洋
[12]: (GTM-01:00) 亚速尔群岛
[13]: (GTM) 格林威治标准时间
[14]: (GTM+01:00) 萨拉热窝
[15]: (GTM+02:00) 开罗
[16]: (GTM+03:00) 莫斯科
[17]: (GTM+04:00) 阿布扎比
[18]: (GTM+05:00) 伊斯兰堡
[19]: (GTM+06:00) 达卡
[20]: (GTM+07:00) 曼谷,河内
[21]: (GTM+08:00) 中国标准时间
[22]: (GTM+09:00) 首尔
[23]: (GTM+10:00) 关岛
[24]: (GTM+11:00) 所罗门群岛
[25]: (GTM+12:00) 斐济
[26]: (GTM+13:00) 努库阿勒法
[27]: (GTM+14:00) 基里巴斯
请选择时区 [21]:
安装类型:
1 典型安装
2 服务器
3 客户端
4 自定义
请选择安装类型的数字序号 [1 典型安装]:
所需空间: 2084M
请选择安装目录 [/home/dmdba/dmdbms]:/dm
可用空间: 23G
是否确认安装路径(/dm)? (Y/y:是 N/n:否) [Y/y]:y
安装前小结
安装位置: /dm
所需空间: 2084M
可用空间: 23G
版本信息:
有效日期:
安装类型: 典型安装
是否确认安装? (Y/y:是 N/n:否):y
2023-10-24 05:44:44
[INFO] 安装 基础 模块...
2023-10-24 05:44:44
[INFO] 安装达梦数据库...
2023-10-24 05:44:48
[INFO] 安装 服务器 模块...
2023-10-24 05:44:49
[INFO] 安装 客户端 模块...
2023-10-24 05:44:52
[INFO] 安装 驱动 模块...
2023-10-24 05:44:53
[INFO] 安装 手册 模块...
2023-10-24 05:44:53
[INFO] 安装 服务 模块...
2023-10-24 05:44:54
[INFO] 移动日志文件。
2023-10-24 05:44:54
[INFO] 安装达梦数据库完成。
请以root系统用户执行命令:
/dm/script/root/root_installer.sh
安装结束
4)检查关闭防火墙、修改selinux状态
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
vim /etc/selinux/config
5)创建目录/dm/conf ,新建配置文件dmdcr_cfg.ini
DCR_N_GRP = 3 #集群环境中包括多少个group
DCR_VTD_PATH = /dev/dmvote #Voting Disk路径
DCR_OGUID = 20231024 #消息标识, dmcssm 登录 dmcss 消息校验用
[GRP]
DCR_GRP_TYPE = CSS #组类型
DCR_GRP_NAME = GRP_CSS #组名
DCR_GRP_N_EP = 2 #组内节点数
DCR_GRP_DSKCHK_CNT = 65 #磁盘心跳机制,容错时间,单位s,缺省60
[GRP_CSS]
DCR_EP_NAME = CSS0 #节点名
DCR_EP_HOST = 192.168.192.150 #节点ip
DCR_EP_PORT = 11286 #节点TCP监听端口,范围:1024-65535
[GRP_CSS]
DCR_EP_NAME = CSS1
DCR_EP_HOST = 192.168.192.155
DCR_EP_PORT = 11286
[GRP]
DCR_GRP_TYPE = ASM
DCR_GRP_NAME = GRP_ASM
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 61
[GRP_ASM]
DCR_EP_NAME = ASM0
DCR_EP_SHM_KEY = 42424 #共享内存标识,数值类型(ASM 有效,初始化共享内存的标识符),大于 0 的 4 字节整数
DCR_EP_SHM_SIZE = 200 #共享内存大小,单位M,(ASM 有效,初始化共享内存大小),范围10-1024
DCR_EP_HOST = 192.168.192.150
DCR_EP_PORT = 11276
DCR_EP_ASM_LOAD_PATH = /dev #ASM磁盘扫描路径,必须全路径
[GRP_ASM]
DCR_EP_NAME = ASM1
DCR_EP_SHM_KEY = 42425
DCR_EP_SHM_SIZE = 200
DCR_EP_HOST = 192.168.192.155
DCR_EP_PORT = 11277
DCR_EP_ASM_LOAD_PATH = /dev
[GRP]
DCR_GRP_TYPE = DB
DCR_GRP_NAME = GRP_HLDB
DCR_GRP_N_EP = 2
DCR_GRP_DSKCHK_CNT = 57
[GRP_CZDB]
DCR_EP_NAME = CZDB0
DCR_EP_SEQNO = 0 #组内序号,CSS/ASM 不能配置,自动分配,DB 可以配置, 0 ~ n_ep -1, 组内不能重复,如不配置则自动分配
DCR_EP_PORT = 11236
DCR_CHECK_PORT = 11256 #DCR检查端口号,检查实例是否活动的时候用,各实例不能冲突。
[GRP_CZDB]
DCR_EP_NAME = CZDB1
DCR_EP_SEQNO = 1
DCR_EP_PORT = 11236
DCR_CHECK_PORT = 11257
6)创建asm磁盘,初始化dcr vote磁盘(只在一个节点上执行)
cd /dm/bin
./dmasmcmd
create dcrdisk '/dev/dmdcr' 'DCR'
create votedisk '/dev/dmvote' 'VOTE'
create asmdisk '/dev/dmdata01' 'DATA01'
create asmdisk '/dev/dmlog' 'LOG'
init dcrdisk '/dev/dmdcr' from '/dm/conf/dmdcr_cfg.ini' identified by '1234'
init votedisk '/dev/dmvote' from '/dm/conf/dmdcr_cfg.ini'
7)创建配置文件dmdcr.ini dmasvrmal.ini
dmdcr.ini
DMDCR_PATH = /dev/dmdcr
DMDCR_MAL_PATH = /dm/conf/dmasvrmal.ini
DMDCR_SEQNO = 0
DMDCR_ASM_RESTART_INTERVAL = 0
DMDCR_ASM_STARTUP_CMD = /dm/bin/dmasmsvr dcr_ini = /dm/conf/dmdcr.ini
DMDCR_DB_RESTART_INTERVAL = 0
DMDCR_DB_STARTUP_CMD=/dm/bin/dmserver path=/dm/conf/czdb0_config/dm.ini dcr_ini=/dm/conf/dmdcr.ini
dmasvrmal.ini
[MAL_INST1]
MAL_INST_NAME = ASM0
MAL_HOST = 192.168.192.150
MAL_PORT = 5244
[MAL_INST2]
MAL_INST_NAME = ASM1
MAL_HOST = 192.168.192.155
MAL_PORT = 5244
把这三个文件拷贝到第二个节点相同目录下,并在第二个节点把dmdcr.ini中的 DMDCR_SEQNO 改为1 path=/dm/conf/czdb0_config 第二个节点path=/dm/conf/czdb1_config
8)配置css服务并启动
./dmcss dcr_ini=/dm/conf/dmdcr.ini
./dm_service_installer.sh -t dmcss -p CZDB0 -dcr_ini /dm/conf/dmdcr.ini
./dm_service_installer.sh -t dmcss -p CZDB1 -dcr_ini /dm/conf/dmdcr.ini
[dmdba@localhost bin]$ ./DmCSSServiceCZDB0 start
[dmdba@localhost bin]$ ./DmCSSServiceCZDB1 start
9)配置asm服务并启动
./dmasmsvr dcr_ini=/dm/conf/dmdcr.ini
./dm_service_installer.sh -t dmasmsvr -p CZDB0 -y DmCSSServiceCZDB0 -dcr_ini /dm/conf/dmdcr.ini
./dm_service_installer.sh -t dmasmsvr -p CZDB1 -y DmCSSServiceCZDB1 -dcr_ini /dm/conf/dmdcr.ini
[dmdba@localhost bin]$ ./DmASMSvrServiceCZDB0 start
[dmdba@localhost bin]$ ./DmASMSvrServiceHLDB1 start
10)在bin目录下配置dmcssm.ini,启动监视器
[dmdba@localhost bin]$ cat dmcssm.ini
CSSM_OGUID=20231024
CSSM_CSS_IP=192.168.124.150:11286
CSSM_CSS_IP=192.168.124.155:11286
CSSM_LOG_PATH=/dm/log
CSSM_LOG_FILE_SIZE=32
CSSM_LOG_SPACE_LIMIT=0
11)创建磁盘组,用于存放数据库数据文件和日志文件
./dmasmtool dcr_ini=/dm/conf/dmdcr.ini
create diskgroup 'DGDATA' asmdisk '/dev/dmdata01'
create diskgroup 'DGLOG' asmdisk '/dev/dmlog'
12)初始化库
在/dm/conf目录下新建dminit.ini文件
[dmdba@localhost conf]$ cat dminit.ini
db_name=CZDB
system_path=+DGDATA
system=+DGDATA01/CZDB/system.dbf
system_size=128
roll=+DGDATA01/CZDB/roll.dbf
roll_size=128
main=+DGDATA01/CZDB/main.dbf
main_size=128
ctl_path=+DGDATA01/CZDB/dm.ctl
ctl_size=8
log_size=256
dcr_path=/dev/dmdcr
dcr_seqno=0
auto_overwrite=1
[CZDB0]
config_path=/dm/conf/czdb0_config
port_num=5236
mal_host=192.168.192.150
mal_port=9340
log_path=+DGLOG01/CZDB0/log01.log
log_path=+DGLOG01/CZDB0/log02.log
[CZDB1]
config_path=/dm/conf/czdb1_config
port_num=5237
mal_host=192.168.192.155
mal_port=9341
log_path=+DGLOG01/CZDB1/log01.log
log_path=+DGLOG01/CZDB1/log02.log
在第一个节点上初始化数据库
[dmdba@localhost bin]$ ./dminit control=/dm/conf/dminit.ini
后把生成的CZDB1_config文件夹拷贝到第二个节点/dm/conf目录下,成功后把第一个节点的这个目录删掉,以免造成干扰
扩展:如果安装有问题,可登陆asm删除数据,重新初始化
[dmdba@localhost bin]$ ./dmasmtool dcr_ini=/dm/conf/dmdcr.ini
DMASMTOOL V8
ASM>ls
disk groups total [4]......
NO.1 name: DGDATA01
NO.2 name: DGLOG01
NO.3 name: VOTE
NO.4 name: DCR
Used time: 2.533(ms).
ASM>cd DGDATA01
+DGDATA01
Used time: 2.517(ms).
ASM>rm -rf CZDB
Used time: 21.557(ms).
ASM>ls
total count 0.
Used time: 1.039(ms).
ASM>cd ..
Used time: 0.954(ms).
ASM>ls
+
disk groups total [4]......
NO.1 name: DGDATA01
NO.2 name: DGLOG01
NO.3 name: VOTE
NO.4 name: DCR
Used time: 0.846(ms).
ASM>cd DGLOG01
+DGLOG01
Used time: 1.437(ms).
ASM>ls
dir : CZDB0
dir : CZDB1
total count 2.
Used time: 0.850(ms).
ASM>rm -rf CZDB0
Used time: 8.191(ms).
ASM>rm -rf CZDB1
Used time: 9.748(ms).
ASM>ls
total count 0.
Used time: 1.466(ms).
ASM>exit
13)配置数据库服务并启动数据库服务
[root@localhost root]# ./dm_service_installer.sh -t dmserver -y DmASMSvrServiceCZDB0 -p CZDB0 -dm_ini /dm/conf/czdb0_config/dm.ini -dcr_ini /dm/conf/dmdcr.ini
Created symlink /etc/systemd/system/multi-user.target.wants/DmServiceCZDB0.service → /usr/lib/systemd/system/DmServiceCZDB0.service.
创建服务(DmServiceCZDB0)完成
[root@localhost root]# ./dm_service_installer.sh -t dmserver -y DmASMSvrServiceCZDB1 -p CZDB1 -dm_ini /dm/conf/czdb1_config/dm.ini -dcr_ini /dm/conf/dmdcr.ini
Created symlink /etc/systemd/system/multi-user.target.wants/DmServiceCZDB1.service → /usr/lib/systemd/system/DmServiceCZDB1.service.
创建服务(DmServiceCZDB1)完成
[dmdba@localhost bin]$ ./DmServiceCZDB0 start
[dmdba@localhost bin]$ ./DmServiceCZDB1 start
成功启动后监视器show如下
14)开启dsc归档
修改dm.ini ARCH_INI = 1
CZDB0节点
vim dmarch.ini
ARCH_LOCAL_SHARE = 1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST =+DGDATA/ARCH0
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT =5120
[ARCH_REMOTE1]
ARCH_TYPE = REMOTE
ARCH_DEST = CZDB1
ARCH_INCOMING_PATH =+DGDATA/ARCH1
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT = 5120
CZDB1节点
vim dmarch.ini
ARCH_LOCAL_SHARE = 1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST =+DGDATA/ARCH1
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT = 5120
[ARCH_REMOTE1]
ARCH_TYPE = REMOTE
ARCH_DEST = CZDB0
ARCH_INCOMING_PATH =+DGDATA/ARCH0
ARCH_FILE_SIZE = 256
ARCH_SPACE_LIMIT = 5120
1)环境准备:安装相同版本的操作系统,安装相同版本得数据库
./dminit path=/dm/data db_name=CZDB instance_name=DW
[dmdba@localhost bin]$ ./dminit path=/dm/data db_name=CZDB instance_name=DW
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2024-10-11
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
log file path: /dm/data/CZDB/CZDB01.log
log file path: /dm/data/CZDB/CZDB02.log
write to dir [/dm/data/CZDB].
create dm database success. 2023-10-26 22:28:55
2)开启备库归档模式
修改dm.ini ARCH_INI = 1
[dmdba@localhost CZDB]$ cat dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = CZDB0/CZDB1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm/dmarch
ARCH_FILE_SIZE = 1024
ARCH_SPACE_LIMIT = 5120
3)脱机备份DSC集群
./DmServiceCZDB0 stop
./DmServiceCZDB1 stop
注:备份前提是 asm 服务要打开,而 asm 服务要打开必须要启动 css 服务
[dmdba@localhost bin]$ ./dmrman dcr_ini=/dm/conf/dmdcr.ini
dmrman V8
RMAN> backup database '/dm/conf/czdb1_config/dm.ini' full backupset '/dm/dmbak/BACKUP_FILE'
backup database '/dm/conf/czdb1_config/dm.ini' full backupset '/dm/dmbak/BACKUP_FILE'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[1]'s cur_lsn[42746], file_lsn[42746]
EP[0]'s cur_lsn[42584]
Processing backupset /dm/dmbak/BACKUP_FILE
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
backup successfully!
time used: 00:00:09.439
4)备机还原
scp -r BACKUP_FILE dmdba@192.168.124.160:/dm/data/CZDB/bak
./dmrman
restore database '/dm/data/CZDB/dm.ini' from backupset '/dm/data/CZDB/bak/BACKUP_FILE';
recover database '/dm/data/CZDB/dm.ini' from backupset '/dm/data/CZDB/bak/BACKUP_FILE';
recover database '/dm/data/CZDB/dm.ini' update DB_MAGIC;
5)修改dm.ini
PORT_NUM = 5236 #主备库保持一致
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI = 1 #打开归档配置
RLOG_SEND_APPLY_MON = 64 #统计最近 64 次的日志发送信息
6)修改dmarch.ini 文件
主库两节点增加实时归档
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DW
备库
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = CZDB0/CZDB1
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm/dmarch
ARCH_FILE_SIZE = 1024
ARCH_SPACE_LIMIT = 5120
7)替换dmmal.ini文件
主,备库在 /dm/conf/czdb0_config
从库在/dm/data/CZDB
vi dmmal.ini
mal_check_interval = 30
mal_conn_fail_interval = 10
[mal_inst0]
mal_inst_name = CZDB0
mal_host = 192.168.192.150
mal_port = 9340
mal_inst_host = 192.168.124.150
mal_inst_port = 5236
mal_dw_port = 9348
mal_inst_dw_port =9349
[mal_inst1]
mal_inst_name = CZDB1
mal_host = 192.168.192.155
mal_port = 9340
mal_inst_host = 192.168.124.155
mal_inst_port = 5236
mal_dw_port = 9348
mal_inst_dw_port=9349
[mal_inst2]
mal_inst_name = DW
mal_host = 102.168.192.160
mal_port = 9340
mal_inst_host = 192.168.124.160
mal_inst_port = 5236
mal_dw_port = 9348
mal_inst_dw_port = 9349
8)创建dmwatcher.ini文件
Node1:
/dm/conf/czdb0_config
[dmdba@localhost czdb0_config]$ cat dmwatcher.ini
[CZDBDW1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_ERROR_TIME = 35
INST_RECOVER_TIME = 60
INST_OGUID = 45332
INST_INI = /dm/conf/czdb0_config/dm.ini
DCR_INI = /dm/conf/dmdcr.ini
INST_STARTUP_CMD = /dm/bin/DmServiceCZDB0
INST_AUTO_RESTART = 0
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
Node2:
[dmdba@localhost czdb1_config]$ cat dmwatcher.ini
[CZDBDW1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_ERROR_TIME = 35
INST_RECOVER_TIME = 60
INST_OGUID = 45332
INST_INI = /dm/conf/czdb1_config/dm.ini
DCR_INI = /dm/conf/dmdcr.ini
INST_STARTUP_CMD = /dm/bin/DmServiceCZDB1
INST_AUTO_RESTART = 0
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
从库:
[dmdba@localhost CZDB]$ cat dmwatcher.ini
[CZDBDW1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_ERROR_TIME = 35
INST_RECOVER_TIME = 60
INST_OGUID = 45332
INST_INI = /dm/data/CZDB/dm.ini
INST_STARTUP_CMD = /dm/bin/DmServiceCZDB
INST_AUTO_RESTART = 1
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
9)注册服务
Node1:
[root@localhost root]# ./dm_service_installer.sh -t dmwatcher -p CZDB0 -watcher_ini /dm/conf/czdb0_config/dmwatcher.ini
创建服务(DmWatcherServiceCZDB0)完成
Node2:
[root@localhost root]# ./dm_service_installer.sh -t dmwatcher -p CZDB1 -watcher_ini /dm/conf/czdb1_config/dmwatcher.ini
创建服务(DmWatcherServiceCZDB1)完成
从库:
[root@localhost root]# ./dm_service_installer.sh -t dmwatcher -p DW -watcher_ini /dm/data/CZDB/dmwatcher.ini
创建服务(DmWatcherServiceDW)完成
[dmdba@localhost CZDB]$ cat dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm/log
MON_LOG_INTERVAL = 0
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[CZDBDW1]
MON_INST_OGUID = 45332
MON_DW_IP = 192.168.192.155:9348/192.168.192.150:9348
MON_DW_IP = 192.168.192.160:9348
两节点主库:
[dmdba@localhost bin]$ ./disql SYSDBA/SYSDBA:11236
服务器[LOCALHOST:11236]:处于普通打开状态
登录使用时间 : 28.247(ms)
disql V8
SQL> alter database mount;
操作已执行
已用时间: 17.789(毫秒). 执行号:0.
SQL> sp_set_oguid(45332);
DMSQL 过程已成功完成
已用时间: 46.386(毫秒). 执行号:1.
SQL> alter database primary;
操作已执行
已用时间: 115.228(毫秒). 执行号:0.
从库:
[dmdba@localhost bin]$ ./disql SYSDBA/SYSDBA
服务器[LOCALHOST:5236]:处于普通配置状态
登录使用时间 : 14.159(ms)
disql V8
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
DMSQL 过程已成功完成
已用时间: 17.461(毫秒). 执行号:1.
SQL> sp_set_oguid(45332);
DMSQL 过程已成功完成
已用时间: 4.897(毫秒). 执行号:2.
SQL> alter database standby;
操作已执行
已用时间: 39.169(毫秒). 执行号:0.
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
DMSQL 过程已成功完成
已用时间: 13.998(毫秒). 执行号:3.
12)启动守护进程
node1:
[dmdba@localhost bin]$ ./DmWatcherServiceCZDB0 start
Starting DmWatcherServiceCZDB0: [ OK ]
node2:
[dmdba@localhost bin]$ ./DmWatcherServiceCZDB1 start
Starting DmWatcherServiceCZDB1: [ OK ]
从库:
[dmdba@localhost bin]$ ./DmWatcherServiceDW start
Starting DmWatcherServiceDW: [ OK ]
13)配置监视器,在监视器中查看
[dmdba@localhost CZDB]$ cat dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm/log
MON_LOG_INTERVAL = 0
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[CZDBDW1]
MON_INST_OGUID = 45332
MON_DW_IP = 192.168.192.155:9348/192.168.192.150:9348
MON_DW_IP = 192.168.192.160:9348
./dmmonitor /dm/data/CZDB/dmmonitor.ini
login
用户名:SYSDBA
密码:
[monitor] 2023-11-07 22:50:13: 登录监视器成功!
switchover CZDBDW1.DW
[monitor] 2023-11-07 22:51:18: 开始切换实例DW
[monitor] 2023-11-07 22:51:18: 通知守护进程CZDB0切换SWITCHOVER状态
[monitor] 2023-11-07 22:51:18: 守护进程(CZDB0)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-11-07 22:51:19: 切换守护进程CZDB0为SWITCHOVER状态成功
[monitor] 2023-11-07 22:51:19: 通知守护进程DW切换SWITCHOVER状态
[monitor] 2023-11-07 22:51:19: 守护进程(DW)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-11-07 22:51:20: 切换守护进程DW为SWITCHOVER状态成功
[monitor] 2023-11-07 22:51:20: 实例CZDB0开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-11-07 22:51:20: 实例CZDB0执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-11-07 22:51:20: 实例DW开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-11-07 22:51:20: 实例DW执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-11-07 22:51:20: 实例CZDB0开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-11-07 22:51:20: 实例CZDB0执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-11-07 22:51:20: 实例DW开始执行SP_APPLY_KEEP_PKG()语句
[monitor] 2023-11-07 22:51:21: 实例DW执行SP_APPLY_KEEP_PKG()语句成功
[monitor] 2023-11-07 22:51:21: 实例DW开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-11-07 22:51:21: 实例DW执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-11-07 22:51:21: 实例CZDB0开始执行ALTER DATABASE STANDBY语句
[monitor] 2023-11-07 22:51:21: 实例CZDB0执行ALTER DATABASE STANDBY语句成功
[monitor] 2023-11-07 22:51:21: 实例DW开始执行ALTER DATABASE PRIMARY语句
[monitor] 2023-11-07 22:51:21: 实例DW执行ALTER DATABASE PRIMARY语句成功
[monitor] 2023-11-07 22:51:21: 通知实例DW修改所有归档状态无效
[monitor] 2023-11-07 22:51:21: 修改所有实例归档为无效状态成功
[monitor] 2023-11-07 22:51:21: 实例CZDB0开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-11-07 22:51:22: 实例CZDB0执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-11-07 22:51:22: 实例DW开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-11-07 22:51:24: 实例DW执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-11-07 22:51:24: 实例CZDB0开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-11-07 22:51:24: 实例CZDB0执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-11-07 22:51:24: 实例DW开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-11-07 22:51:24: 实例DW执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-11-07 22:51:24: 通知守护进程CZDB0切换OPEN状态
[monitor] 2023-11-07 22:51:25: 守护进程(CZDB0)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-11-07 22:51:25: 切换守护进程CZDB0为OPEN状态成功
[monitor] 2023-11-07 22:51:25: 通知守护进程DW切换OPEN状态
[monitor] 2023-11-07 22:51:25: 守护进程(DW)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-11-07 22:51:26: 切换守护进程DW为OPEN状态成功
[monitor] 2023-11-07 22:51:26: 通知组(CZDBDW1)的守护进程执行清理操作
[monitor] 2023-11-07 22:51:26: 清理守护进程(CZDB0)请求成功
2023-11-07 22:51:26
[monitor] 2023-11-07 22:51:26: 清理守护进程(DW)请求成功
[monitor] 2023-11-07 22:51:26: 实例DW切换成功
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
CZDBDW1 45332 TRUE 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
192.168.192.160 9348 2023-11-07 22:51:26 GLOBAL VALID OPEN DW 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
192.168.124.160 5236 OK DW OPEN PRIMARY 0 0 REALTIME VALID 5391 44487 5391 44487 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
192.168.192.150 9348 2023-11-06 10:53:07 GLOBAL VALID OPEN CZDB0 OK 2 2 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
192.168.124.150 11236 OK CZDB0 OPEN STANDBY 0 0 REALTIME INVALID 5389 44285 5389 44285 NONE
192.168.124.155 11236 OK CZDB1 OPEN STANDBY 1 0 REALTIME INVALID 2501 44285 2501 44285 NONE
DATABASE(CZDB0) APPLY INFO FROM (DW), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5389, 5389, 5389], (RLSN, SLSN, KLSN)[44285, 44285, 44285], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (44285)
DSC_SEQNO[1], (RSEQ, SSEQ, KSEQ)[2501, 2501, 2501], (RLSN, SLSN, KLSN)[44285, 44285, 44285], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (44285)
#================================================================================#
[monitor] 2023-11-07 22:51:28: 守护进程(DW)状态切换 [OPEN-->RECOVERY]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-11-07 22:51:28 RECOVERY OK DW OPEN PRIMARY VALID 8 44487 44487
[monitor] 2023-11-07 22:51:32: 守护进程(DW)状态切换 [RECOVERY-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-11-07 22:51:32 OPEN OK DW OPEN PRIMARY VALID 8 44487 44487
可以看到dsc得两节点状态变成了standby,切换成功
验证测试:新的主库上插入数据
[dmdba@localhost bin]$ ./disql SYSDBA/SYSDBA
服务器[LOCALHOST:5236]:处于主库打开状态
登录使用时间 : 4.244(ms)
disql V8
SQL> SELECT * FROM TEST;
行号 ID
---------- -----------
1 1
已用时间: 0.912(毫秒). 执行号:701.
SQL> insert into test values (2);
影响行数 1
已用时间: 3.250(毫秒). 执行号:702.
SQL> commit;
操作已执行
Dsc备库查询验证
[dmdba@localhost bin]$ ./disql SYSDBA/SYSDBA:11236
服务器[LOCALHOST:11236]:处于备库打开状态
登录使用时间 : 18.928(ms)
disql V8
SQL> select * from test;
行号 ID
---------- -----------
1 1
2 2
已用时间: 88.269(毫秒). 执行号:501.
2)DSC切换为主库
login
用户名:sysdba
密码:
[monitor] 2023-11-08 00:10:36: 登录监视器成功!
switchover CZDBDW1.CZDB0
[monitor] 2023-11-08 00:11:09: 开始切换实例CZDB0
[monitor] 2023-11-08 00:11:09: 通知守护进程DW切换SWITCHOVER状态
[monitor] 2023-11-08 00:11:09: 守护进程(DW)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-11-08 00:11:10: 切换守护进程DW为SWITCHOVER状态成功
[monitor] 2023-11-08 00:11:10: 通知守护进程CZDB0切换SWITCHOVER状态
[monitor] 2023-11-08 00:11:10: 守护进程(CZDB0)状态切换 [OPEN-->SWITCHOVER]
[monitor] 2023-11-08 00:11:11: 切换守护进程CZDB0为SWITCHOVER状态成功
[monitor] 2023-11-08 00:11:11: 实例DW开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-11-08 00:11:11: 实例DW执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-11-08 00:11:11: 实例CZDB0开始执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句
[monitor] 2023-11-08 00:11:11: 实例CZDB0执行SP_SET_GLOBAL_DW_STATUS(0, 6)语句成功
[monitor] 2023-11-08 00:11:11: 实例DW开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-11-08 00:11:12: 实例DW执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-11-08 00:11:12: 实例CZDB0开始执行SP_APPLY_KEEP_PKG()语句
[monitor] 2023-11-08 00:11:13: 实例CZDB0执行SP_APPLY_KEEP_PKG()语句成功
[monitor] 2023-11-08 00:11:13: 实例CZDB0开始执行ALTER DATABASE MOUNT语句
[monitor] 2023-11-08 00:11:13: 实例CZDB0执行ALTER DATABASE MOUNT语句成功
[monitor] 2023-11-08 00:11:13: 实例DW开始执行ALTER DATABASE STANDBY语句
[monitor] 2023-11-08 00:11:13: 实例DW执行ALTER DATABASE STANDBY语句成功
[monitor] 2023-11-08 00:11:13: 实例CZDB0开始执行ALTER DATABASE PRIMARY语句
[monitor] 2023-11-08 00:11:13: 实例CZDB0执行ALTER DATABASE PRIMARY语句成功
[monitor] 2023-11-08 00:11:13: 通知实例CZDB0修改所有归档状态无效
[monitor] 2023-11-08 00:11:13: 修改所有实例归档为无效状态成功
[monitor] 2023-11-08 00:11:13: 实例DW开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-11-08 00:11:13: 实例DW执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-11-08 00:11:13: 实例CZDB0开始执行ALTER DATABASE OPEN FORCE语句
[monitor] 2023-11-08 00:11:14: 实例CZDB0执行ALTER DATABASE OPEN FORCE语句成功
[monitor] 2023-11-08 00:11:14: 实例DW开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-11-08 00:11:14: 实例DW执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-11-08 00:11:14: 实例CZDB0开始执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句
[monitor] 2023-11-08 00:11:14: 实例CZDB0执行SP_SET_GLOBAL_DW_STATUS(6, 0)语句成功
[monitor] 2023-11-08 00:11:14: 通知守护进程DW切换OPEN状态
[monitor] 2023-11-08 00:11:14: 守护进程(DW)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-11-08 00:11:15: 切换守护进程DW为OPEN状态成功
[monitor] 2023-11-08 00:11:15: 通知守护进程CZDB0切换OPEN状态
[monitor] 2023-11-08 00:11:15: 守护进程(CZDB0)状态切换 [SWITCHOVER-->OPEN]
[monitor] 2023-11-08 00:11:16: 切换守护进程CZDB0为OPEN状态成功
[monitor] 2023-11-08 00:11:16: 通知组(CZDBDW1)的守护进程执行清理操作
[monitor] 2023-11-08 00:11:16: 清理守护进程(CZDB0)请求成功
[monitor] 2023-11-08 00:11:16: 清理守护进程(DW)请求成功
[monitor] 2023-11-08 00:11:16: 实例CZDB0切换成功
2023-11-08 00:11:16
#================================================================================#
GROUP OGUID MON_CONFIRM MODE MPP_FLAG
CZDBDW1 45332 TRUE 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
192.168.192.150 9348 2023-11-06 12:12:57 GLOBAL VALID OPEN CZDB0 OK 2 2 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
192.168.124.150 11236 OK CZDB0 OPEN PRIMARY 0 0 REALTIME VALID 5409 45392 5409 45392 NONE
192.168.124.155 11236 OK CZDB1 OPEN PRIMARY 1 0 REALTIME VALID 2505 45392 2505 45392 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
192.168.192.160 9348 2023-11-08 00:11:16 GLOBAL VALID OPEN DW 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
192.168.124.160 5236 OK DW OPEN STANDBY 0 0 REALTIME INVALID 5406 45055 5406 45055 NONE
DATABASE(DW) APPLY INFO FROM (CZDB0), REDOS_PARALLEL_NUM (1), WAIT_APPLY[FALSE]:
DSC_SEQNO[0], (RSEQ, SSEQ, KSEQ)[5406, 5406, 5406], (RLSN, SLSN, KLSN)[45055, 45055, 45055], N_TSK[0], TSK_MEM_USE[0]
REDO_LSN_ARR: (45055)
#================================================================================#
[monitor] 2023-11-08 00:11:18: 守护进程(CZDB0)状态切换 [OPEN-->RECOVERY]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-11-06 12:12:59 RECOVERY OK CZDB0 OPEN PRIMARY VALID 11 45392 45392
[monitor] 2023-11-08 00:11:21: 守护进程(CZDB0)状态切换 [RECOVERY-->OPEN]
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-11-06 12:13:02 OPEN OK CZDB0 OPEN PRIMARY VALID 11 45392 45392
可以看到DSC两个节点变成primary模式,切换成功。
文章
阅读量
获赞