Ceph MGR 命令详解

Ceph MGR 命令详解

MGR(Manager)是 Ceph 集群中的管理组件,负责提供额外的监控和接口功能,包括 Web 仪表板、REST API、指标收集等。在 Ceph Luminous 版本中引入,从 Quincy 版本开始成为集群必需组件。

MGR 基础命令

1. 查看 MGR 状态

bash 复制代码
# 查看 MGR 状态
ceph mgr stat

# 查看活跃和备用 MGR 实例
ceph mgr dump

# 查看 MGR 模块列表
ceph mgr module ls

# 查看 MGR 服务状态
ceph orch ls --service-type mgr

2. MGR 模块管理

bash 复制代码
# 启用 MGR 模块
ceph mgr module enable <module_name>

# 禁用 MGR 模块
ceph mgr module disable <module_name>

# 查看模块配置选项
ceph config-key ls | grep <module_name>

常用 MGR 模块详解

1. Dashboard 模块

Dashboard 是 Ceph 提供的 Web 管理界面:

bash 复制代码
# 启用 Dashboard 模块
ceph mgr module enable dashboard

# 设置 Dashboard 用户名和密码
ceph dashboard ac-user-create <username> <password> administrator

# 查看 Dashboard 状态
ceph mgr services | grep dashboard

# 配置 SSL(可选)
ceph dashboard create-self-signed-cert

2. Prometheus 模块

Prometheus 模块提供监控指标导出功能:

bash 复制代码
# 启用 Prometheus 模块
ceph mgr module enable prometheus

# 查看 Prometheus 导出的指标端点
ceph mgr services | grep prometheus

# 配置指标刷新间隔
ceph config set mgr mgr/prometheus/scrape_interval 15

3. RESTful API 模块

RESTful 模块提供 REST API 接口:

bash 复制代码
# 启用 RESTful 模块
ceph mgr module enable restful

# 生成 API 密钥
ceph restful create-key <username>

# 查看 API 端点
ceph mgr services | grep restful

MGR 管理命令

1. 部署和管理 MGR 服务

在 cephadm 环境中,通常使用 orch 命令来管理 MGR:

bash 复制代码
# 查看 MGR 服务状态
ceph orch ls --service-type mgr

# 部署 MGR 服务到指定节点
ceph orch apply mgr --placement="<node1> <node2>"

# 手动添加 MGR 实例
ceph orch daemon add mgr <node>

# 移除 MGR 实例
ceph orch daemon rm <mgr_daemon_name>

3. MGR 性能调优

bash 复制代码
# 设置模块刷新间隔
ceph config set mgr mgr/<module_name>/scrape_interval <seconds>

# 设置 MGR 模块线程数
ceph config set mgr mgr/<module_name>/thread_pool_size <number>

常用 MGR 管理场景

场景 1:配置 Dashboard

配置并启用 Ceph Dashboard:

bash 复制代码
# 1. 启用 Dashboard 模块
ceph mgr module enable dashboard

# 2. 创建管理员用户
ceph dashboard ac-user-create admin <password> administrator

# 3. 创建自签名证书(生产环境建议使用正式证书)
ceph dashboard create-self-signed-cert

# 4. 查看 Dashboard 访问地址
ceph mgr services | grep dashboard

# 5. 通过浏览器访问 Dashboard,默认端口 8443

场景 2:配置 Prometheus 监控

配置 Prometheus 指标导出:

bash 复制代码
# 1. 启用 Prometheus 模块
ceph mgr module enable prometheus

# 2. 查看指标导出端点
ceph mgr services | grep prometheus

# 3. 配置 Prometheus 抓取间隔
ceph config set mgr mgr/prometheus/scrape_interval 15

# 4. 在 Prometheus 配置中添加该端点

场景 3:启用告警功能

配置告警管理器:

bash 复制代码
# 1. 启用 Alertmanager 模块
ceph mgr module enable alertmanager

# 2. 配置告警管理器地址
ceph config set mgr mgr/alertmanager/server_addr <alertmanager_address>

# 3. 配置告警规则
ceph config set mgr mgr/alertmanager/webhook_url <webhook_url>

MGR 相关配置参数

参数名 含义 默认值 建议值
mgr/prometheus/scrape_interval Prometheus 抓取间隔(秒) 15 15-30
mgr/dashboard/server_port Dashboard 端口 8443 8443
shell 复制代码
[root@ceph1 ~]# ceph  config get  mgr  mgr/prometheus/scrape_interval
15.000000
[root@ceph1 ~]# ceph  config get  mgr mgr/dashboard/server_port
8080

注意事项

  1. 高可用性:建议部署至少两个 MGR 实例(一个活跃,一个备用)
  2. 资源占用:MGR 模块会消耗一定系统资源,根据需要启用
  3. 网络安全:Dashboard 和 RESTful API 应配置适当的安全策略
  4. 权限控制:为不同用户分配适当的访问权限

总结

MGR 组件为 Ceph 提供了丰富的管理和监控功能,通过各种模块扩展,可以满足不同场景的需求。合理配置和使用 MGR 模块,能够极大地提升 Ceph 集群的可管理性和可观测性。

参考文档

  1. Ceph 官方文档 - MGR
  2. Ceph 官方文档 - Dashboard
  3. Ceph 官方文档 - Prometheus

温馨提示

由于网络环境或文件存储等因素,若相关文件或图片链接暂时无法访问,您也可以通过访问张师傅的好来斯技术博客获取更多相关资源和最新信息。

本篇文章原始链接:

复制代码
https://www.howlaisi.com/categories/ceph/ceph-mgr-ming-ling-xiang-jie
相关推荐
yyyyy_abc27 分钟前
ceph学习笔记
笔记·ceph·学习
自由且自律1 天前
ceph实战,基于docker部署
运维·ceph·docker·容器·云计算
老wang你好3 天前
Ceph存储全攻略:RBD、CephFS与RGW详解
ceph
珂玥c6 天前
Ceph集群新增osd
ceph
老wang你好7 天前
Ceph分布式存储系统全解析
ceph
一个行走的民20 天前
分布式系统中 Map 增量(Delta)是否需要持久化
ceph
一个行走的民21 天前
BlueStore 核心原理与关键机制
ceph
奋斗的小青年I23 天前
Proxmox VE Ceph 超融合集群落地实战
windows·ceph·vmware·pve·超融合·proxmox
一个行走的民23 天前
深度剖析 Ceph PG 分裂机制:原理、底层、实操、影响、线上避坑(最全完整版)
ceph·算法
一个行走的民24 天前
Ceph 核心概念精讲:彻底搞懂 PG、PGP、pg_num、pgp_num
ceph