6.3. 自动调优 OSD 内存

OSD 守护进程根据 osd_memory_target 配置选项调整内存消耗。选项 osd_memory_target 根据系统中可用的 RAM 来设置 OSD 内存。

如果 Red Hat Ceph Storage 部署在不与其他服务共享内存的专用节点上,cephadm 会自动根据 RAM 总量和部署的 OSD 数量自动调整每个 OSD 消耗。

重要

默认情况下,Red Hat Ceph Storage 5.1 中的 osd_memory_target_autotune 参数设为 true

语法

ceph config set osd osd_memory_target_autotune true

当存储集群升级到 Red Hat Ceph Storage 5.0(例如添加 OSD 或替换 OSD)后,红帽建议将 osd_memory_target_autotune 参数设置为 true,以根据系统内存自动调优 osd memory。

Cephadm 以分数 mgr/cephadm/autotune_memory_target_ratio 开头,默认为系统总 RAM 的 0.7,这会减小非自动tuned守护进程(如 non-OSDS)以及 osd_memory_target_autotune 为 false 的 OSD,然后划分剩余的 OSD。

默认情况下,autotune_memory_target_ratio 对于超融合基础架构为 0.2,其他环境为 0.7。

osd_memory_target 参数计算如下:

语法

osd_memory_target = TOTAL_RAM_OF_THE_OSD_NODE (in Bytes) * (autotune_memory_target_ratio) / NUMBER_OF_OSDS_IN_THE_OSD_NODE - (SPACE_ALLOCATED_FOR_OTHER_DAEMONS (in Bytes))

SPACE_ALLOCATED_FOR_OTHER_DAEMONS 可能包括以下守护进程空间分配:

  • Alertmanager: 1 GB
  • Grafana: 1 GB
  • Ceph Manager:4 GB
  • Ceph Monitor: 2 GB
  • Node-exporter: 1 GB
  • Prometheus: 1 GB

例如,如果节点有 24 个 OSD 且具有 251 GB RAM 空间,则 osd_memory_target7860684936

最终目标反映在带有选项的配置数据库中。您可以从 ceph orch ps 输出的 MEM LIMIT 列下查看各个守护进程使用的限值和当前内存。

注意

在 Red Hat Ceph Storage 5.1 中,对于计算和 Ceph 存储服务在一起的超融合基础架构,osd_memory_target_autotune true 的默认设置并不适合。在超融合基础架构中,autotune_memory_target_ratio 可以设置为 0.2,以减少 Ceph 的内存消耗。

示例

[ceph: root@host01 /]# ceph config set mgr mgr/cephadm/autotune_memory_target_ratio 0.2

您可以为存储集群中的 OSD 手动设置特定内存目标。

示例

[ceph: root@host01 /]# ceph config set osd.123 osd_memory_target 7860684936

您可以为存储集群中的 OSD 主机手动设置特定内存目标。

语法

ceph config set osd/host:HOSTNAME osd_memory_target TARGET_BYTES

示例

[ceph: root@host01 /]# ceph config set osd/host:host01 osd_memory_target 1000000000

注意

启用 osd_memory_target_autotune 覆盖现有的手动 OSD 内存目标设置。要防止守护进程内存被调整(即使启用了 osd_memory_target_autotune 选项或启用了其他类似的选项),在主机上设置 _no_autotune_memory 标签。

语法

ceph orch host label add HOSTNAME _no_autotune_memory

您可以通过禁用 autotune 选项并设置特定内存目标,从内存自动调整 OSD 中排除。

示例

[ceph: root@host01 /]# ceph config set osd.123 osd_memory_target_autotune false
[ceph: root@host01 /]# ceph config set osd.123 osd_memory_target 16G