TiDB 同城双中心监控组件高可用方案
作者: Prest13 原文来源:https://tidb.net/blog/44b9b8b1
背景
在双中心部署 tidb dr-auto sync 集群,出于监控的高可用考虑,在物理分离的两个数据中心分别部署独立的 prometheus+alertmanager+grafana,实现任一监控均可访问。
此部署架构需考虑两套监控组件数据采集的一致性,以及监控告警重复发送的问题。

实现思路
两套 Prometheus 组件各自独立进行集群监控信息的采集和存储;
两套 Grafana 连接各自的 Prometheus 作为数据源;
AlertManager 通过集群配置,基于 gossip 机制,在多个 alertmanager 收到相同告警事件后,由其中之一对外发送监控告警信息。
模拟实现
模拟实现的环境
TiDB v7.1.0 LTS
单个集群部署两套监控
调整监控数据链路
grafana 调整 datasource


确认 prometheus 配置,设置 alertmanager 信息

登录 alertmanager,确认多个 alertmanager 组成了集群(此处由 tidb 自动完成配置)

需复用 haproxy+keepalive 反向代理多个 prometheus,并修改 dashboard 的 prometheus 数据源,以免单个 prometheus 故障后影响 dashboard 的使用
haproxy 配置略
dashboard 配置如下

Webhook 实现
编写 webhook 转换为飞书 api 的 golang 程序
略
测试,使用 HTTP 接口测试工具,确认飞书 webhook 小程序接收并解析了相关告警事件
配置 alertmanager webhook
编写 alertmanager 配置文件模板,添加 reciver 及 webhook 定义,存放在 tiup 中控机的路径下
使用 tiup edit-config,添加 alertmanager_server 下的 config_file,路径指向上一步编写的 alertmanager 配置文件
尝试触发告警,确认未产生多条告警



关闭其中一个中心的监控组件,确认是否可以正常告警

启动上一步停止的 tidb 组件,确认可以触发告警的恢复


(此处为 webhook 代码中的错误,未引用恢复时间)
结论
在多中心环境下,除考虑集群本身的高可用功能外,其监控组件同样应具备高可用能力。本文从多中心监控使用及告警整合的维度,尝试构建了集群监控在多中心的高可用部署及实现方案。
如有疑问,欢迎讨论。
参考:
https://www.prometheus.wang/ha/alertmanager-high-availability.html
https://prometheus.io/docs/alerting/latest/overview/
版权声明: 本文为 InfoQ 作者【TiDB 社区干货传送门】的原创文章。
原文链接:【http://xie.infoq.cn/article/adc0a42a9cdd8b2b799b27b8d】。文章转载请联系作者。
评论