Skip to content

Commit

Permalink
Merge pull request #202 from molliezhang/main
Browse files Browse the repository at this point in the history
docs *: Add files about monitoring #169
  • Loading branch information
andyli029 authored Sep 14, 2021
2 parents 63dfdad + aa1663d commit 64eb02b
Show file tree
Hide file tree
Showing 39 changed files with 287 additions and 67 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ RadonDB MySQL Kubernetes supports deployment and management of RaodnDB MySQL clu
- Leader-follower switching in second-level
- Strongly consistent data for cluster switching
- Cluster management
- Monitoring and alerting
- [Monitoring and alerting](docs/deploy_monitoring.md)
- [Backups](docs/deploy_backup_restore_s3.md)
- Logs
- Account management

## Quick Start

### Helm

- [Deploy RadonDB MySQL on Kubernetes](docs/Kubernetes/deploy_radondb-mysql_on_kubernetes.md)
- [Deploy RadonDB MySQL through git on Kubesphere](docs/KubeSphere/deploy_radondb-mysql_on_kubesphere.md)
- [Deploy RadonDB MySQL through helm repo on Kubesphere](docs/KubeSphere/deploy_radondb-mysql_on_kubesphere_repo.md)
- [Deploy RadonDB MySQL through Appstore of KubeSphere](docs/KubeSphere/deploy_radondb-mysql_on_kubesphere_appstore.md)
- [Deploy RadonDB MySQL on Kubernetes](docs/kubernetes/deploy_radondb-mysql_on_kubernetes.md)
- [Deploy RadonDB MySQL through git on Kubesphere](docs/kubesphere/deploy_radondb-mysql_on_kubesphere.md)
- [Deploy RadonDB MySQL through helm repo on Kubesphere](docs/kubesphere/deploy_radondb-mysql_on_kubesphere_repo.md)
- [Deploy RadonDB MySQL through Appstore of KubeSphere](docs/kubesphere/deploy_radondb-mysql_on_kubesphere_appstore.md)

### Operator

- [Deploy RadonDB MySQL on Kubernetes](docs/Kubernetes/deploy_radondb-mysql_operator_on_k8s.md)
- [Deploy RadonDB MySQL on Kubernetes](docs/kubernetes/deploy_radondb-mysql_operator_on_k8s.md)

## Roadmap

| Release | Features | Mode |
|------|--------|--------|
| 1.0 | High availability <br> Non-centralized automatic leader election <br> Second-level switching <br> Strongly consistent data <br> Cluster management <br> Monitoring and alerting <br> Logs <br> Account management | Helm |
| 1.0 | Cluster management <br> Monitoring and alerting <br> Logs <br> Account management | Helm |
| 2.0 | Node management <br> Automatic expansion and shrinkage capacity <br> Upgrade <br> Backups and Restorations <br> Automatic failover <br> Automatic rebuild node <br> Automatic restart service(all or signal node)<br> Account management(API)<br> Migrating Data online | Operator |
| 3.0 | Automatic O&M <br> Multiple node roles <br> Disaster Recovery <br> SSL transmission encryption | Operator |

Expand All @@ -56,17 +57,17 @@ RadonDB MySQL Kubernetes supports deployment and management of RaodnDB MySQL clu

## License

RadonDB MySQL is released under the Apache 2.0, see [LICENSE](./LICENSE).
RadonDB MySQL is released under the Apache 2.0, see [License](./LICENSE).

## Discussion and Community

- Forum

The RadonDB MySQL topic is in [Kubesphere Community](https://kubesphere.com.cn/forum/t/radondb).
The RadonDB MySQL topic is in [KubeSphere Community](https://kubesphere.com.cn/forum/t/radondb).

- Please pay attention to our official account.

![](docs/images/qrcode_for_gh_ffb9d7c5dc1f_258.jpg)
![](docs/images/vx_code_258.jpg)

---
<p align="center">
Expand Down
23 changes: 12 additions & 11 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@ RadonDB MySQL Kubernetes支持在[Kubernetes](https://kubernetes.io)和[KubeSphe
- 主从秒级切换
- 集群切换的数据强一致性
- 集群管理
- 监控告警
- [监控告警](docs/deploy_monitoring.md)
- [备份](docs/deploy_backup_restore_s3.md)
- 集群日志管理
- 账户管理

## 快速开始

### Helm

- [ 在 Kubernetes 上部署 RadonDB MySQL 集群](docs/Kubernetes/deploy_radondb-mysql_on_kubernetes.md)
- [在 KubeSphere 上通过 Git 部署 RadonDB MySQL 集群](docs/KubeSphere/deploy_radondb-mysql_on_kubesphere.md)
- [在 KubeSphere 上通过 Helm Repo 部署 RadonDB MySQL 集群](docs/KubeSphere/deploy_radondb-mysql_on_kubesphere_repo.md)
- [在 KubeSphere 上通过应用商店部署 RadonDB MySQL 集群](docs/KubeSphere/deploy_radondb-mysql_on_kubesphere_appstore.md)
- [ 在 Kubernetes 上部署 RadonDB MySQL 集群](docs/kubernetes/deploy_radondb-mysql_on_kubernetes.md)
- [在 KubeSphere 上通过 Git 部署 RadonDB MySQL 集群](docs/kubesphere/deploy_radondb-mysql_on_kubesphere.md)
- [在 KubeSphere 上通过 Helm Repo 部署 RadonDB MySQL 集群](docs/kubesphere/deploy_radondb-mysql_on_kubesphere_repo.md)
- [在 KubeSphere 上通过应用商店部署 RadonDB MySQL 集群](docs/kubesphere/deploy_radondb-mysql_on_kubesphere_appstore.md)

### Operator

- [在 Kubernetes 上部署 RadonDB MySQL 集群](docs/Kubernetes/deploy_radondb-mysql_operator_on_k8s.md)
- [在 Kubernetes 上部署 RadonDB MySQL 集群](docs/kubernetes/deploy_radondb-mysql_operator_on_k8s.md)

## 路线图

| 版本 | 功能 | 实现方式 |
|------|--------|------|
| 1.0 | MySQL 高可用 <br> 无中心化领导者自动选举<br> 主从秒级切换<br> 数据强一致性 <br> 集群管理 <br> 监控告警 <br> 集群日志管理 <br> 账户管理 | Helm |
| 1.0 | 集群管理 <br> 监控告警 <br> 集群日志管理 <br> 账户管理 | Helm |
| 2.0 | 增删节点 <br> 自动扩缩容 <br> 升级集群 <br> 备份与恢复 <br> 故障自动转移 <br> 自动重建节点 <br> 自动重启服务 <br> 账户管理(提供 API 接口)<br> 在线迁移 | Operator |
| 3.0 | 自动化运维 <br> 多节点角色 <br> 灾备集群 <br> SSL 传输加密 | Operator |

Expand All @@ -56,17 +57,17 @@ RadonDB MySQL Kubernetes支持在[Kubernetes](https://kubernetes.io)和[KubeSphe

## 协议

RadonDB MySQL 基于 Apache 2.0 协议,详见 [LICENSE](./LICENSE)
RadonDB MySQL 基于 Apache 2.0 协议,详见 [License](./LICENSE)

## 欢迎加入社区话题互动

- 论坛

请加入[Kubesphere 开发者社区](https://kubesphere.com.cn/forum/t/radondb) RadonDB MySQL 话题专区。
请加入[KubeSphere 开发者社区](https://kubesphere.com.cn/forum/t/radondb) RadonDB MySQL 话题专区。

- 请关注我们的微信公众号
- 欢迎关注微信公众号

![](docs/images/qrcode_for_gh_ffb9d7c5dc1f_258.jpg)
![](docs/images/vx_code_258.jpg)

---
<p align="center">
Expand Down
Binary file removed docs/KubeSphere/png/主节点端口.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/从节点端口.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/企业空间.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/应用管理.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/应用负载.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/控制台部署成功.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/访问方式.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/连接客户端节点.png
Binary file not shown.
Binary file removed docs/KubeSphere/png/项目管理.png
Binary file not shown.
Binary file added docs/_images/config_dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/monitor_overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/monitor_service.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/mysql_exporter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/pod_metrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/prometheus_grafana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
192 changes: 192 additions & 0 deletions docs/deploy_monitoring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
Contents
=================

* [开启监控指标](#开启监控指标)
* [简介](#简介)
* [准备工作](#准备工作)
* [部署步骤](#部署步骤)
* [步骤 1:配置 serviceMonitor](#步骤-1-配置-servicemonitor)
* [步骤 2: 配置 metricsOpts](#步骤-2-配置-metricsopts)
* [查看监控服务](#查看监控服务)
* [通过客户端查看](#通过客户端查看)
* [在 KubeSphere 平台查看](#在-kubesphere-平台查看)
* [查看监控](#查看监控)
* [通过 KubeSphere 自定义监控](#通过-kubesphere-自定义监控)
* [通过 Prometheus + Grafana 平台](#通过-prometheus--grafana-平台)

# 开启监控指标

## 简介

[Prometheus](https://prometheus.io/) 基于文本的暴露格式,已经成为云原生监控领域事实上的标准格式。

RadonDB MySQL 监控引擎基于 [Prometheus MySQLd Exporter](https://github.com/prometheus/mysqld_exporter) 定义。通过 `mysqld-exporter` 抓取 RadonDB MySQL 服务指标,再通过接入第三方应用平台实现监控指标可视化。

本教程演示如何开启 RadonDB MySQL 监控指标。

## 准备工作

- 已准备可用 Kubernetes 或 KubeSphere 集群。
- 已获取RadonDB MySQL Operator 2.1.0 及以上版本。

## 部署步骤

### 步骤 1: 配置 serviceMonitor

`serviceMonitor` 是定义 RadonDB MySQL Operator 自动监控引擎的参数,开启后将自动绑定 `mysqld_exporter` 与 Prometheus。

`serviceMonitor` 参数包含如下字段:

```bash
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
```

您可以在 `charts/mysql-operator/values.yaml` 文件中配置 `serviceMonitor`

- 新部署 Operator 时, `serviceMonitor.enabled` 默认为 **true**,表示默认开启。
- 已部署 Operator 2.1.0 以下版本的集群,需重新部署 Operator。

### 步骤 2: 配置 metricsOpts

`metricsOpts` 是 CRD `clusters.mysql.radondb.com` 中定义 RadonDB MySQL 集群监控的参数,可通过配置`mysql_v1alpha1_cluster.yaml` 文件中参数值开启监控服务。

`metricsOpts` 参数包含如下字段:

```bash
metricsOpts:
enabled: false
image: prom/mysqld-exporter:v0.12.1

resources:
requests:
cpu: 10m
memory: 32Mi
limits:
cpu: 100m
memory: 128Mi
```

`metricsOpts.enabled` 默认为 **false**,需手动设置为 **true**

- 选择设置 `metricsOpts.enabled` 状态为 **true**,开启集群监控功能。
- 设置资源参数值,定义监控容器资源配额大小。

文件参数修改完成后,使用如下指令应用配置,部署/更新集群回显信息如下:

```bash
$ kubectl apply -f config/sample/mysql_v1alpha1_cluster.yaml
cluster.mysql.radondb.com/sample created/configured
```

## 查看监控服务

### 通过客户端查看

您可以通过如下指令查看集群监控服务和 serviceMonitor 信息。

```bash
$ kubectl get service,servicemonitor

$ kubectl describe servicemonitor <serviceName>
```

**预期效果**

```shell
$ kubectl get service,servicemonitor
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/mysql-operator-metrics ClusterIP 10.96.242.205 <none> 8443/TCP 3h25m
service/sample-follower ClusterIP 10.96.2.234 <none> 3306/TCP 21h
service/sample-leader ClusterIP 10.96.30.238 <none> 3306/TCP 21h
service/sample-metrics ClusterIP 10.96.7.222 <none> 9104/TCP 3h24m
service/sample-mysql ClusterIP None <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 `,可查看监控服务信息。

![查看监控服务](_images/monitor_service.png)

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

![查看监控资源状态](_images/pod_metrics.png)

## 查看监控

### 通过 KubeSphere 自定义监控

> **说明**
>
> RadonDB MySQL Operator 和集群需部署在 KubeSphere。
KubeSphere 的监控引擎基于 Prometheus 和 Prometheus Operator。使用 KubeSphere 的自定义监控功能支持以可视化的形式监控 RadonDB MySQL 指标。

1. 在集群同一项目中,选择**监控告警**下的**自定义监控**,点击**创建**
2. 在对话框中,选择 **MySQL** 模版,并继续配置监控模版。

![选择模版](_images/mysql_exporter.png)

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

![保存监控模版](_images/config_dashboard.png)

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

![查看监控](_images/monitor_overview.png)

更多详情,请查看 KubeSphere [自定义监控介绍](https://kubesphere.io/zh/docs/project-user-guide/custom-application-monitoring/introduction/)[可视化监控](https://kubesphere.io/zh/docs/project-user-guide/custom-application-monitoring/visualization/overview/)

### 通过 Prometheus + Grafana 平台

[Grafana](https://github.com/grafana/grafana) 是一个跨平台、开源的数据可视化网络应用程序平台。通过 Prometheus + Grafana 平台查看监控基本原理如下:

- 通过 [mysql_exporter](https://github.com/prometheus/mysqld_exporter) 获取 RadonDB MySQL 服务监控数据.
- 通过 [node_exporter](https://github.com/prometheus/node_exporter) 获得 RadonDB MySQL 服务器的监控数据。
- 将监控数据传到 [Prometheus](https://prometheus.io/download/) 后,通过配置数据源,最终在 Grafana 呈现丰富的监控数据图表和警告。

![基本原理](_images/prometheus_grafana.png)

更多 Grafana 可视化监控使用说明,请参见 [Grafana Dashboards](https://grafana.com/docs/grafana/latest/dashboards/)
File renamed without changes
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ kubectl get statefulset,pod,svc
mysql -p <节点地址> -u <用户名> -P <节点端口> -p
```

> 说明:使用外网主机连接可能会出现 `SSL connection error`,需要加上 `--ssl-mode=DISABLE` 参数,关闭 SSL。
> **说明**
>
> 使用外网主机连接可能会出现 `SSL connection error`,需要加上 `--ssl-mode=DISABLE` 参数,关闭 SSL。

## 配置

Expand Down Expand Up @@ -304,7 +306,11 @@ kubectl get statefulset,pod,svc

> *"当 Pod 分配给节点时,将首先创建一个 emptyDir 卷,只要该 Pod 在该节点上运行,该卷便存在。 当 Pod 从节点中删除时,emptyDir 中的数据将被永久删除."*

**注意**:PersistentVolumeClaim 中可以使用不同特性的 PersistentVolume,其 IO 性能会影响数据库的初始化性能。所以当使用 PersistentVolumeClaim 启用持久化存储时,可能需要调整 livenessProbe.initialDelaySeconds 的值。数据库初始化的默认限制是60秒 (livenessProbe.initialDelaySeconds + livenessProbe.periodSeconds * livenessProbe.failureThreshold)。如果初始化时间超过限制,kubelet将重启数据库容器,数据库初始化被中断,会导致持久数据不可用。
> **注意**
>
> PersistentVolumeClaim 中可以使用不同特性的 PersistentVolume,其 IO 性能会影响数据库的初始化性能。所以当使用 PersistentVolumeClaim 启用持久化存储时,可能需要调整 `livenessProbe.initialDelaySeconds` 的值。
>
> 数据库初始化的默认限制是60秒 (l`ivenessProbe.initialDelaySeconds` + `livenessProbe.periodSeconds` * `livenessProbe.failureThreshold`)。如果初始化时间超过限制,kubelet 将重启数据库容器,数据库初始化被中断,会导致持久数据不可用。

## 自定义 MYSQL 配置

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 64eb02b

Please sign in to comment.