本章目标:
- 建立 Kubernetes + Rook-Ceph 全链路可观测体系
- 实现 Ceph 集群健康、性能、容量、业务影响监控
- 建立生产级 Prometheus + Grafana + Alertmanager 平台
- 支撑企业 SLA/SLO 管理和自动化运维
12.1 Ceph可观测性架构
生产推荐架构:
用户/业务
|
Kubernetes Pod
|
Kubernetes CSI
|
RBD / CephFS
|
Ceph Cluster
+-------------------+-------------------+
| | |
MON OSD MGR
| | |
+-------------------+-------------------+
|
Ceph Metrics Exporter
|
Prometheus
|
+-------------+-------------+
| |
Grafana Alertmanager
| |
Dashboard 告警通知
|
企业IM/邮件/电话
12.2 监控组件组成
| 组件 | 作用 |
|---|---|
| Prometheus | 指标采集 |
| Grafana | 可视化 |
| Alertmanager | 告警路由 |
| Ceph Exporter | Ceph指标 |
| Node Exporter | 节点指标 |
| Kube State Metrics | K8s对象 |
| Loki | 日志分析 |
| Tempo | 链路追踪 |
12.3 Rook-Ceph Metrics开启
Rook默认支持:
Ceph Manager Prometheus Module
查看:
kubectl -n rook-ceph get cephcluster
查看配置:
kubectl -n rook-ceph get cephcluster \
-o yaml
确认:
monitoring:
enabled: true
12.4 开启Ceph Prometheus模块
进入toolbox:
kubectl -n rook-ceph exec -it \
deploy/rook-ceph-tools \
-- bash
查看:
ceph mgr module ls
找到:
prometheus
开启:
ceph mgr module enable prometheus
验证:
ceph mgr services
输出:
prometheus:
http://10.x.x.x:9283
12.5 Prometheus ServiceMonitor
Rook创建:
Service
↓
ServiceMonitor
↓
Prometheus
查看:
kubectl get servicemonitor \
-n rook-ceph
正常:
rook-ceph-mgr
rook-ceph-exporter
12.6 核心监控指标体系
生产重点关注:
12.6.1 集群健康指标
Ceph Health
指标:
ceph_health_status
状态:
| 值 | 含义 |
|---|---|
| 0 | OK |
| 1 | WARN |
| 2 | ERR |
告警:
alert: CephHealthError
expr:
ceph_health_status > 0
for:
5m
12.6.2 OSD状态
指标:
ceph_osd_up
正常:
1
异常:
0
查询:
PromQL:
ceph_osd_up == 0
告警:
alert: CephOSDDown
expr:
count(ceph_osd_up == 0)>0
for:
5m
12.6.3 OSD容量
指标:
ceph_osd_stat_bytes
关注:
- USED
- AVAIL
容量百分比:
(
ceph_cluster_used_bytes
/
ceph_cluster_total_bytes
)*100
告警:
80%:
warning
85%:
critical
12.6.4 PG状态
指标:
ceph_pg_active
ceph_pg_degraded
ceph_pg_incomplete
正常:
active+clean
异常:
degraded
inactive
stale
12.6.5 MON状态
指标:
ceph_mon_quorum_status
检查:
sum(ceph_mon_quorum_status)
生产:
3 MON:
必须:
>=2
12.7 Grafana Dashboard
推荐导入:
Ceph Cluster Dashboard
包含:
- Cluster Health
- OSD
- Pool
- PG
- IO
Node Dashboard
查看:
- CPU
- Memory
- Disk
- Network
Kubernetes Storage Dashboard
查看:
- PVC
- CSI
- Volume
12.8 Ceph性能监控
IOPS
指标:
ceph_osd_op_r
ceph_osd_op_w
延迟
指标:
ceph_osd_op_latency
重点:
| 延迟 | 状态 |
|---|---|
| <5ms | 优秀 |
| 5-20ms | 正常 |
| 20-50ms | 注意 |
| >100ms | 异常 |
12.9 网络监控
Ceph严重依赖网络。
监控:
带宽
Node Exporter:
node_network_receive_bytes_total
丢包
指标:
node_network_receive_errs_total
TCP连接
指标:
node_netstat_Tcp_CurrEstab
12.10 磁盘性能监控
重点:
IOPS
Latency
Queue
Utilization
Node Exporter:
node_disk_io_time_seconds_total
查看:
iostat -x 1
重点:
await
util
svctm
12.11 Kubernetes CSI监控
RBD CSI
关注:
- Provision失败
- Mount失败
- Attach失败
查询:
kubectl get pod \
-n rook-ceph | grep csi
日志:
kubectl logs \
-n rook-ceph \
deploy/csi-rbdplugin-provisioner
12.12 PVC业务监控
PVC容量
指标:
kubelet_volume_stats_used_bytes
查询:
(
kubelet_volume_stats_used_bytes
/
kubelet_volume_stats_capacity_bytes
)*100
告警:
90%
12.13 Alertmanager生产告警
架构:
Prometheus
|
Alertmanager
|
+---+----+----+
邮件 企业微信 PagerDuty
12.14 核心告警规则
Ceph健康异常
groups:
- name: ceph
rules:
- alert:
CephHealthWarning
expr:
ceph_health_status > 0
for:
10m
OSD Down
- alert:
CephOSDDown
expr:
ceph_osd_up == 0
for:
5m
容量不足
- alert:
CephCapacityHigh
expr:
ceph_cluster_used_bytes
/
ceph_cluster_total_bytes
>0.85
PG异常
- alert:
CephPGDegraded
expr:
ceph_pg_degraded >0
for:
10m
12.15 日志可观测体系
推荐:
Ceph
|
Fluent Bit
|
Loki
|
Grafana
采集:
- MON日志
- OSD日志
- CSI日志
- Rook日志
12.16 Loki日志查询
示例:
查询OSD:
{namespace="rook-ceph"}
|= "osd"
查询异常:
{namespace="rook-ceph"}
|= "error"
12.17 Ceph事件审计
重点记录:
- OSD down
- Pool修改
- 用户权限变化
- 删除操作
查看:
ceph log last
12.18 SLA/SLO设计
生产存储指标:
可用性
目标:
99.95%
IO延迟
RBD:
<10ms
数据恢复
RPO:
<=1小时
RTO:
<=4小时
12.19 自动化巡检
每日:
#!/bin/bash
echo "Ceph Health"
ceph health
echo "OSD"
ceph osd tree
echo "PG"
ceph pg stat
echo "Capacity"
ceph df
输出:
================
Ceph HEALTH_OK
OSD 24/24 UP
PG active+clean
Capacity 65%
================
12.20 生产监控大屏设计
第一屏:集群健康
显示:
Ceph Health
MON
MGR
OSD
PG
第二屏:容量
显示:
RAW Capacity
Used
Available
Growth Rate
第三屏:性能
显示:
IOPS
Latency
Throughput
Network
第四屏:业务
显示:
PVC
Pod
CSI
Application
12.21 企业级存储运营平台架构
运维人员
|
Grafana
|
+---------+---------+
| |
Prometheus Loki
| |
Metrics Logs
|
+-----+------+
| |
Kubernetes Ceph
|
CSI
12.22 生产监控检查清单
| 项目 | 状态 |
|---|---|
| Ceph Metrics开启 | □ |
| Prometheus采集 | □ |
| Grafana Dashboard | □ |
| Alertmanager | □ |
| OSD告警 | □ |
| PG告警 | □ |
| 容量告警 | □ |
| CSI监控 | □ |
| 日志平台 | □ |
| 巡检自动化 | □ |