容器化 | 构建 RadonDB MySQL 集群监控平台
时间:2023-02-16
浏览:436
作者:佚名
本篇文章向大家介绍《容器化 | 构建 RadonDB MySQL 集群监控平台》,主要包括MySQL、数据库、kubernetes、kubesphere,具有一定的参考价值,需要的朋友可以参考一下。
上一篇文章我们演示了如何《在 S3 备份恢复 RadonDB MySQL 集群数据》,本文将演示在 KubeSphere[1] 中使用 Prometheus[2] + Grafana[3] 构建 MySQL 监控平台,开启所需监控指标。
背景
Prometheus 基于文本的暴露格式,已经成为云原生监控领域事实上的标准格式。
RadonDB MySQL 监控引擎基于 Prometheus MySQLd Exporter[5] 定义。通过
serviceMonitor:
enabled: true
## Additional labels for the serviceMonitor. Useful if you have multiple prometheus operators running to select only specific ServiceMonitors
# additionalLabels:
# prometheus: prom-internal
interval: 10s
scrapeTimeout: 3s
# jobLabel:
# targetLabels:
# podTargetLabels:
namespaceSelector:
any: true
selector:
matchLabels:
app.kubernetes.io/managed-by: mysql.radondb.com
app.kubernetes.io/name: mysql您可以在
metricsOpts:
enabled: false
image: prom/mysqld-exporter:v0.12.1
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
cpu: 100m
memory: 128Mi$ kubectl apply -f config/sample/mysql_v1alpha1_mysqlcluster.yaml cluster.mysql.radondb.com/sample created/configured
查看监控服务
通过客户端查看
您可以通过如下指令查看集群监控服务和 serviceMonitor 信息。
$ kubectl get service,servicemonitor $ kubectl describe servicemonitor
预期效果
$ kubectl get service,servicemonitor NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/mysql-operator-metrics ClusterIP 10.96.242.2058443/TCP 3h25m service/sample-follower ClusterIP 10.96.2.234 3306/TCP 21h service/sample-leader ClusterIP 10.96.30.238 3306/TCP 21h service/sample-metrics ClusterIP 10.96.7.222 9104/TCP 3h24m service/sample-mysql ClusterIP None 3306/TCP 21h NAME AGE servicemonitor.monitoring.coreos.com/demo-mysql-operator 3h25m $ kubectl describe servicemonitor demo-mysql-operator Name: test-radondb-mysql-metrics Namespace: default Labels: app=test-radondb-mysql app.kubernetes.io/managed-by=Helm app.kubernetes.io/vendor=kubesphere chart=radondb-mysql-1.0.0 heritage=Helm release=test Annotations: kubesphere.io/creator: admin API Version: monitoring.coreos.com/v1 Kind: ServiceMonitor ...... Spec: Endpoints: Interval: 1m Path: /metrics Port: metrics Scheme: http Scrape Timeout: 10s ......
在 KubeSphere 平台查看
在 KubeSphere 企业空间部署的 RadonDB MySQL Operator 和集群,开启监控后,可在如下页面查看监控服务状态。
- 在项目空间应用负载下的服务页面,点击
<集群名称>-metrics
,可查看监控服务信息。

- 在项目空间应用负载下的容器组页面,点击一个容器的名称,可查看该容器中
metrics
资源状态。

查看监控内容
通过 KubeSphere 自定义监控
KubeSphere 的监控引擎基于 Prometheus 和 Prometheus Operator。使用 KubeSphere 的自定义监控功能支持以可视化的形式监控 RadonDB MySQL 指标。
- 在集群同一项目中,选择 监控告警 -> 自定义监控 -> 创建;
- 在对话框中,选择 MySQL 模版,并继续配置监控模版;

- 点击 保存模版,即新创建监控面板。

- 新建监控面板需等待约十分钟,即可查看监控数据。

更多详情,请查看 KubeSphere 自定义监控介绍[6] 和 可视化监控[7]。
通过 Prometheus + Grafana 平台
Grafana 是一个跨平台、开源的数据可视化网络应用程序平台。通过 Prometheus + Grafana 平台查看监控基本原理如下:
- 通过 mysql_exporter 获取 RadonDB MySQL 服务监控数据.
- 通过 node_exporter 获得 RadonDB MySQL 服务器的监控数据。
- 将监控数据传到 Prometheus 后,通过配置数据源,最终在 Grafana 呈现丰富的监控数据图表和警告。

更多 Grafana 可视化监控使用说明,请参见 Grafana Dashboards[8]。
参考引用
- KubeSphere:https://kubesphere.com.cn
- Prometheus:https://prometheus.io/
- Grafana:https://grafana.org/
- RadonDB MySQL Kubernetes 2.1.3:https://radondb.com/projects/...
- Prometheus MySQLd Exporter:https://github.com/prometheus...
- 自定义监控:https://kubesphere.io/zh/docs...
- 可视化监控:https://kubesphere.io/zh/docs...
- Grafana Dashboards:https://grafana.com/docs/graf...
今天带大家了解了MySQL、数据库、kubernetes、kubesphere的相关知识,希望对你有所帮助;关于数据库的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~
本文内容来源于互联网,如有侵权请联系删除。
近期热门
站内热门
最新文章
热门专题
