【我和openGauss的故事】openGauss特性:CM支持两节点部署特性
杨凯同学 2023-07-14 18:50 发表于 openGauss公众号
1.什么是CM
CM(Cluster Manager)是一款数据库管理模块。支持自定义资源监控,提供了数据库主备的状态监控、网络通信故障监控、文件系统故障监控、故障自动主备切换等能力。提供了丰富的数据库管理能力,如节点、实例级的启停,数据库实例状态查询、主备切换、日志管理等。提供了通过REST接口远程查询和接收集群状态的能力。
2.CM 特点
从5.0开始CM支持2节点部署
CM集群和数据库集群都能实现高可用,RPO=0
(1)CM集群高可用:
基于网关IP实现:备实例基于与网关IP的连通性判定自身是否升主,主实例基于与其与网关IP的连通性判定自身是否降备。目前支持自动故障切换和手工故障切换。
(2)数据库集群高可用
备实例是否failover的判定除去基于流复制状态,额外增加对数据库集群VIP(选配参数)的连通性的探测,以此降低主实例故障的误判概率,进而降低脑裂故障概率。为了确保脑裂故障时数据库集群的数据一致性,提供可配参数支持自动故障恢复和手工故障恢复。手工故障恢复需要按照特定文档及工具执行差异数据合并。
3.CM两节点部署的XML
root@k8s-node1 cm_server]# vi /home/omm/cluster_config.xml
<?xml version="1.0" encoding="utf-8"?>
<ROOT>
<CLUSTER>
<PARAM name="clusterName" value="Cluster_template" />
<PARAM name="nodeNames" value="k8s-master,k8s-node1"/>
<PARAM name="gaussdbAppPath" value="/dbms/huawei/opengauss/install/app" />
<PARAM name="gaussdbLogPath" value="/var/log/omm" />
<PARAM name="tmpMppdbPath" value="/dbms/huawei/opengauss/tmp"/>
<PARAM name="gaussdbToolPath" value="/dbms/huawei/opengauss/install/om" />
<PARAM name="corePath" value="/dbms/huawei/opengauss/corefile"/>
<PARAM name="backIp1s" value="192.168.10.2,192.168.10.3"/>
</CLUSTER>
<DEVICELIST>
<DEVICE sn="node1_hostname">
<PARAM name="name" value="k8s-master"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.168.10.2"/>
<PARAM name="sshIp1" value="192.168.10.2"/>
<!-- cm主 -->
<PARAM name="cmsNum" value="1"/>
<PARAM name="cmDir" value="/dbms/huawei/opengauss/install/cm"/>
<PARAM name="cmServerPortBase" value="15300"/>
<PARAM name="cmServerListenIp1" value="192.168.10.2,192.168.10.3"/>
<PARAM name="cmServerHaIp1" value="192.168.10.2,192.168.10.3"/>
<!-- cmServerlevel目前只支持1 -->
<PARAM name="cmServerlevel" value="1"/>
<!-- cms主及所有备的hostname -->
<PARAM name="cmServerRelation" value="k8s-master,k8s-node1"/>
<!-- dn -->
<PARAM name="dataNum" value="1"/>
<PARAM name="dataPortBase" value="15400"/>
<PARAM name="dataNode1" value="/dbms/huawei/opengauss/install/data/dn,k8s-node1,/dbms/huawei/opengauss/install/data/dn"/>
<PARAM name="dataNode1_syncNum" value="0"/>
</DEVICE>
<DEVICE sn="node2_hostname">
<PARAM name="name" value="k8s-node1"/>
<PARAM name="azName" value="AZ1"/>
<PARAM name="azPriority" value="1"/>
<PARAM name="backIp1" value="192.168.10.3"/>
<PARAM name="sshIp1" value="192.168.10.3"/>
<!-- cm -->
<PARAM name="cmDir" value="/dbms/huawei/opengauss/install/cm"/>
<PARAM name="cmServerPortStandby" value="15300"/>
</DEVICE>
</DEVICELIST>
</ROOT>
4.cm日常运维命令
--cm命令查看集群状态
[omm@k8s-master ~]$ cm_ctl query -Cvdi
[ CMServer State ]
node node_ip instance state
--------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 1 /dbms/huawei/opengauss/install/cm/cm_server Primary
2 k8s-node1 192.168.10.3 2 /dbms/huawei/opengauss/install/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state | node node_ip instance state
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 6001 /dbms/huawei/opengauss/install/data/dn P Standby Normal | 2 k8s-node1 192.168.10.3 6002 /dbms/huawei/opengauss/install/data/dn S Primary Normal
cm切换primary库命令
[omm@k8s-master ~]$ cm_ctl switchover -n 1 -D /dbms/huawei/opengauss/install/data/dn
....
cm_ctl: switchover successfully.
[omm@k8s-master ~]$ cm_ctl query -Cvdi
[ CMServer State ]
node node_ip instance state
--------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 1 /dbms/huawei/opengauss/install/cm/cm_server Primary
2 k8s-node1 192.168.10.3 2 /dbms/huawei/opengauss/install/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state | node node_ip instance state
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 6001 /dbms/huawei/opengauss/install/data/dn P Primary Normal | 2 k8s-node1 192.168.10.3 6002 /dbms/huawei/opengauss/install/data/dn S Standby Normal
--停止集群
[omm@k8s-master ~]$ cm_ctl stop
cm_ctl: stop cluster.
cm_ctl: stop nodeid: 1
cm_ctl: stop nodeid: 2
.........
cm_ctl: stop cluster successfully.
[omm@k8s-master ~]$ cm_ctl query -Cvdi
[ CMServer State ]
node node_ip instance state
--------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 1 /dbms/huawei/opengauss/install/cm/cm_server Down
2 k8s-node1 192.168.10.3 2 /dbms/huawei/opengauss/install/cm/cm_server Down
--启动集群
[omm@k8s-master ~]$ cm_ctl start
cm_ctl: checking cluster status.
cm_ctl: checking cluster status.
cm_ctl: checking finished in 366 ms.
cm_ctl: start cluster.
cm_ctl: start nodeid: 1
cm_ctl: start nodeid: 2
............
cm_ctl: start cluster successfully.
[omm@k8s-master ~]$ cm_ctl query -Cvdi
[ CMServer State ]
node node_ip instance state
--------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 1 /dbms/huawei/opengauss/install/cm/cm_server Primary
2 k8s-node1 192.168.10.3 2 /dbms/huawei/opengauss/install/cm/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state | node node_ip instance state
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 k8s-master 192.168.10.2 6001 /dbms/huawei/opengauss/install/data/dn P Primary Normal | 2 k8s-node1 192.168.10.3 6002 /dbms/huawei/opengauss/install/data/dn S Standby Normal
5.CM两节点特性-配置前提条件
--cm集群故障自动切换配置前提条件
third_party_gateway_ip = 192.168.10.1
cms_enable_failover_on2nodes = true
cms_network_isolation_timeout = 20
--cm集群故障手工切换配置前提条件
third_party_gateway_ip = 192.168.10.1
cms_enable_failover_on2nodes = false
cms_network_isolation_timeout = 20
--数据库集群故障自动切换配置前提条件
third_party_gateway_ip = 192.168.10.1
cms_enable_failover_on2nodes = true
cms_enable_db_crash_recovery = on
--数据库集群故障手工切换配置前提条件
third_party_gateway_ip = 192.168.10.1
cms_enable_failover_on2nodes = true
cms_enable_db_crash_recovery = off
6.CM 在openGauss5.0 新增的特性
高可用:CM支持VIP管理
通过VIP可以直接找到主机,连接重连更准更快(毫秒级别);
支持主机故障,CM选出新主时,VIP漂移到新的主上;
当出现双主时,依然可以通过VIP访问到唯一一个主机,降低了双主丢数据的风险。
高可用:CM支持两节点部署
通过引入第三方网关IP,有效解决CM集群两节点部署模式下自仲裁问题,支持CMS和DN均为2节点的部署;
同时支持动态配置CM集群故障切换策略和数据库集群脑裂故障恢复策略,从而能够尽可能确保集群数据的完整性和一致性。
高可用:CM磁盘只读检测能力增强
只读状态从数据库获取,保证准确性;
只读仲裁只仲裁当前超过阈值的实例,其他节点不受影响;
主机只读保护后自动主备切换,选可用备机升主保证集群能正常提供工作。
高可用:CM易用性提升
支持一键式关闭CM集群服务;
支持和内核的安装部署解耦;
支持按事件调用用户自定义脚本;
支持CM组件单独升级,增强数据库集群可靠性;
CM根据配置信息,支持用户自定义组件的监控和管理
复制
标签:node,CM,cm,特性,192.168,ctl,openGauss,k8s
From: https://blog.51cto.com/u_16191492/6783685