目 录CONTENT

文章目录

Ceph MGR 命令详解

Administrator
2026-03-15 / 0 评论 / 0 点赞 / 3 阅读 / 0 字
温馨提示:
部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

Ceph MGR 命令详解

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

MGR 基础命令

1. 查看 MGR 状态

# 查看 MGR 状态
ceph mgr stat

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

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

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

2. MGR 模块管理

# 启用 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 管理界面:

# 启用 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 模块提供监控指标导出功能:

# 启用 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 接口:

# 启用 RESTful 模块
ceph mgr module enable restful

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

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

MGR 管理命令

1. 部署和管理 MGR 服务

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

# 查看 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 性能调优

# 设置模块刷新间隔
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:

# 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 指标导出:

# 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:启用告警功能

配置告警管理器:

# 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_intervalPrometheus 抓取间隔(秒)1515-30
mgr/dashboard/server_portDashboard 端口84438443
[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
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区