diff --git a/app/zh/blogs/johnnyflute/cm-code-read-1.png b/app/zh/blogs/johnnyflute/cm-code-read-1.png new file mode 100644 index 0000000000000000000000000000000000000000..e2f8666d862f4117994e2ad6ae6145135e150bb0 Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-1.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-2.png b/app/zh/blogs/johnnyflute/cm-code-read-2.png new file mode 100644 index 0000000000000000000000000000000000000000..0358cfe70b434184377cafcf8209ab5650b2015e Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-2.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-3.png b/app/zh/blogs/johnnyflute/cm-code-read-3.png new file mode 100644 index 0000000000000000000000000000000000000000..38d4dbf53efd2155745ef86baabb83883e5f2f49 Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-3.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-4.png b/app/zh/blogs/johnnyflute/cm-code-read-4.png new file mode 100644 index 0000000000000000000000000000000000000000..659ee1fef776d2674e80d9cde31744f31f380232 Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-4.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-5.png b/app/zh/blogs/johnnyflute/cm-code-read-5.png new file mode 100644 index 0000000000000000000000000000000000000000..118efea38109e01478f8b1a9a9f03c236faad4ce Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-5.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-6.png b/app/zh/blogs/johnnyflute/cm-code-read-6.png new file mode 100644 index 0000000000000000000000000000000000000000..ce2c598cefb114efc075bb7b79f81f067d10ba96 Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-6.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-7.png b/app/zh/blogs/johnnyflute/cm-code-read-7.png new file mode 100644 index 0000000000000000000000000000000000000000..ccf67e096edcb11baddc09b46d48eb5c5946bbab Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-7.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-8.png b/app/zh/blogs/johnnyflute/cm-code-read-8.png new file mode 100644 index 0000000000000000000000000000000000000000..d96222a64dd25fb440e52280d85506d37ffa5961 Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-8.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read-9.png b/app/zh/blogs/johnnyflute/cm-code-read-9.png new file mode 100644 index 0000000000000000000000000000000000000000..0ec2c97583c81dd7acd88b240bc056a6fd5f343c Binary files /dev/null and b/app/zh/blogs/johnnyflute/cm-code-read-9.png differ diff --git a/app/zh/blogs/johnnyflute/cm-code-read.md b/app/zh/blogs/johnnyflute/cm-code-read.md new file mode 100644 index 0000000000000000000000000000000000000000..211dc0a1371fa3b6394be4e737769022b58376ce --- /dev/null +++ b/app/zh/blogs/johnnyflute/cm-code-read.md @@ -0,0 +1,61 @@ +--- +title: 'openGauss CM组件代码阅读 一' +date: '2024-06-13' +category: 'blog' +tags: ['openGauss CM组件代码阅读'] +archives: '2023-04' +author: 'xucheng' +summary: 'openGauss CM组件代码阅读' +times: '14:30' +--- + + +1.概述 + +CM(Cluster Manager)是OpenGauss 社区3.0版本开源的高可用集群管理 组件。支持自定义资源监控,提供了数据库主备状态监控、网络通信故障监控、 文件系统故障监控、以及故障后自动切换主备等能力。 配合OpenGauss社区OM脚本,可以进行自动化高可用集群的部署安装和运 维操作。 +管理和监控数据库系统中各个功能单元和物理资源的运行情况,确保整 个数据库系统的稳定运行。 支持自定义资源监控,提供了数据库主备的状态监控、网络通信故障监 控、文件系统故障监控、故障自动主备切换等能力。提供了丰富的数据库管 理能力,如节点、实例级的启停,数据库实例状态查询、主备切换、日志管 理等功能。 +![](./cm-code-read-1.png) + +![](./cm-code-read-2.png) + +- cm_agent: 负责启停和数据库实例进 程监控上报、故障检测、执行下发的 仲裁命令 +- cm_server:接收agent发送的各节点 实例状态,通过心跳超时或异常状态 消息,由cm_server主集中仲裁DN的 主备状态关系,触发故障迁移 +- cm_ctl:集群管理命令行 +- om_monitor: cm_agent的守护进程 + + +2.代码结构 + +![](./cm-code-read-3.png) + +3.cm_ctl + +主要负责代码启停,状态查询等操作。从实现上来说大体分为两类操作 +1)其中集群启停等操作由执行节点调用pssh,将标志文件拷贝到bin目录下。如cm_ctl会创建cluster_manual_start文件,停止重启操作类似。 +2)查询等操作需要与cm_server进行交互,cm_server处理指令返回给客户端,由客户端根据参数控制输出。 +3)消息对应处理函数 + +![](./cm-code-read-4.png) + +4.om_monitor + +![](./cm-code-read-5.png) +定制任务,负责监控cm_agent,severloop中不断检查agent,并不断进行。保证cm_agent能一直将状态发送给cm_server,并在用户使用om或者cm工具关闭集群之后,关闭cma。 + +5.cm_agent + +多个线程不断采集DN和系统状态,并根据检查状态,选择杀死节点或者将信息发送给CM-Server + +6.cm_server + +1)选主逻辑 + +![](./cm-code-read-6.png) +2)示例 + +![](./cm-code-read-7.png) + +![](./cm-code-read-8.png) +3)消息对应处理函数 + +![](./cm-code-read-9.png) \ No newline at end of file