7.4. 配置存储桶索引重新划分

作为存储管理员,您可以配置 bucket 索引在单站点和多站点部署中重新划分,以提高性能。

您可以手动离线或动态在线对存储桶进行重新分片。

7.4.1. 存储桶索引重新分片

Ceph 对象网关将 bucket 索引数据存储在索引池中,默认为 .rgw.buckets.index 参数。当客户端在单一存储桶中放置多个对象时,每个存储桶的最大对象数量没有设置配额,索引池可能会导致性能下降。

  • 当您为每个存储桶添加大量对象时,bucket 索引重新划分可防止性能瓶颈。
  • 您可以为新存储桶配置存储桶索引重新划分,或更改现有存储桶上的存储桶索引。
  • 您需要让分片计数作为计算的分片计数最为接近的主数。作为主要数字的 bucket 索引分片在跨分片均匀分布式 bucket 索引条目中表现更好。
  • bucket 索引可以手动或动态重新划分。

    在动态重新划分 bucket 索引的过程中,会定期检查所有 Ceph 对象网关存储桶,并检测到需要重新划分的存储桶。如果 bucket 增长大于 rgw_max_objs_per_shard 参数中指定的值,Ceph 对象网关会在后台动态重新定义存储桶。rgw_max_objs_per_shard 的默认值是每个分片 100k 对象。重新划分 bucket 索引在升级的单站点配置上动态工作,无需修改 zone 或 zone group。单个站点配置可以是以下任意一种:

    • 无 realm 的默认区配置。
    • 至少有一个域的非默认配置。
    • 多 realm 单站点配置。

7.4.2. 恢复存储桶索引

重新划分使用 bucket_index_max_shards = 0 创建的存储桶,移除存储桶的元数据。但是,您可以通过恢复受影响的存储桶来恢复存储桶索引。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 至少安装两个站点的 Ceph 对象网关。
  • 已安装 jq 软件包。

流程

  • 执行以下两个步骤之一来执行存储桶索引恢复:

    • 运行 radosgw-admin object reindex --bucket BUCKET_NAME --object OBJECT_NAME 命令。
    • 运行脚本 - /usr/bin/rgw-restore-bucket-index -b BUCKET_NAME -p DATA_POOL_NAME

      示例

      [root@host01 ceph]# /usr/bin/rgw-restore-bucket-index -b bucket-large-1 -p local-zone.rgw.buckets.data
      
      marker is d8a347a4-99b6-4312-a5c1-75b83904b3d4.41610.2
      bucket_id is d8a347a4-99b6-4312-a5c1-75b83904b3d4.41610.2
      number of bucket index shards is 5
      data pool is local-zone.rgw.buckets.data
      NOTICE: This tool is currently considered EXPERIMENTAL.
      The list of objects that we will attempt to restore can be found in "/tmp/rgwrbi-object-list.49946".
      Please review the object names in that file (either below or in another window/terminal) before proceeding.
      Type "proceed!" to proceed, "view" to view object list, or "q" to quit: view
      Viewing...
      Type "proceed!" to proceed, "view" to view object list, or "q" to quit: proceed!
      Proceeding...
      NOTICE: Bucket stats are currently incorrect. They can be restored with the following command after 2 minutes:
          radosgw-admin bucket list --bucket=bucket-large-1 --allow-unordered --max-entries=1073741824
      Would you like to take the time to recalculate bucket stats now? [yes/no] yes
      Done
      
      real    2m16.530s
      user    0m1.082s
      sys    0m0.870s

注意
  • 该工具不适用于版本存储桶。

    [root@host01 ~]# time rgw-restore-bucket-index  --proceed serp-bu-ver-1 default.rgw.buckets.data
    NOTICE: This tool is currently considered EXPERIMENTAL.
    marker is e871fb65-b87f-4c16-a7c3-064b66feb1c4.25076.5
    bucket_id is e871fb65-b87f-4c16-a7c3-064b66feb1c4.25076.5
    Error: this bucket appears to be versioned, and this tool cannot work with versioned buckets.
  • 工具的范围仅限于单个站点,而不是多站点。也就是说,如果在 site-1 上执行 rgw-restore-bucket-index 工具,它不会恢复 site-2 中的对象,反之亦然。在多站点上,应在存储桶的两个站点上执行恢复工具和对象 reindex 命令。

7.4.3. bucket 索引重新划分的限制

重要

请谨慎使用以下限制:您的硬件选择会有影响,因此您应该始终与您的红帽客户团队讨论这些要求。

  • 在需要重新划分前一个存储桶中的最大对象数量: 每个存储桶索引分片最多使用 102,400 个对象。要充分利用重新划分和最大化并行性,请在 Ceph 对象网关 bucket 索引池中提供足够数量的 OSD。这种并行化使用 Ceph 对象网关实例的数量进行扩展,并使用数字序列替换排序索引分片数。默认锁定超时从 60 秒扩展到 90 秒。
  • 使用分片时的最大对象数量:基于之前的测试,当前支持的存储桶索引分片 数量为 65,521。
  • 您可以在其他区赶上前重新划分存储桶三次 : 在旧的生成同步前,不建议重新划分存储桶。支持之前重新划分中的四个 bucket 生成。达到限制后,动态重新划分不会再次重新划分存储桶,直到至少其中一个旧日志生成被完全修剪为止。使用 radosgw-admin bucket reshard 命令抛出以下错误:

    Bucket _BUCKET_NAME_ already has too many log generations (4) from previous reshards that peer zones haven't finished syncing.
    Resharding is not recommended until the old generations sync, but you can force a reshard with `--yes-i-really-mean-it`.

7.4.4. 在简单部署中配置存储桶索引重新划分

要在所有新存储桶上启用和配置 bucket 索引重新划分,请使用 rgw_override_bucket_index_max_shards 参数。

您可以将参数设置为以下值之一:

  • 0 禁用存储桶索引分片,这是默认值。
  • 值大于 0,以启用存储桶分片并设置分片的最大数量。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 至少安装两个站点的 Ceph 对象网关。

流程

  1. 计算推荐的分片数量:

    number of objects expected in a bucket / 100,000
    注意

    目前支持的最大存储桶索引分片数量为 65,521。

  2. 相应地设置 rgw_override_bucket_index_max_shards 参数:

    语法

    ceph config set client.rgw rgw_override_bucket_index_max_shards VALUE

    使用计算的推荐分片数量替换 VALUE:

    示例

    [ceph: root@host01 /]# ceph config set client.rgw rgw_override_bucket_index_max_shards 12

    • 要为 Ceph 对象网关的所有实例配置 bucket 索引重新划分,请使用 global 选项设置 rgw_override_bucket_index_max_shards 参数。
    • 若要仅为 Ceph 对象网关的特定实例配置 bucket 索引重新划分,请在实例下添加 rgw_override_bucket_index_max_shards 参数。
  3. 在集群中的所有节点上重启 Ceph 对象网关才能生效:

    语法

    ceph orch restart SERVICE_TYPE

    示例

    [ceph: root#host01 /]# ceph orch restart rgw

7.4.5. 在多站点部署中配置存储桶索引重新划分

在多站点部署中,每个区域都可以具有不同的 index_pool 设置来管理故障转移。要为一个 zone group 中的 zone 配置一致的分片计数,请在该 zone group 配置中设置 bucket_index_max_shards 参数。bucket_index_max_shards 参数的默认值为 11。

您可以将参数设置为以下值之一:

  • 0 禁用存储桶索引分片。
  • 值大于 0,以启用存储桶分片并设置分片的最大数量。
注意

如果适用,将索引池映射到基于 SSD 的 OSD 的 CRUSH 规则集,也可能有助于 bucket 索引性能。如需更多信息,请参阅 建立性能域 部分。

重要

为了防止多站点部署中的同步问题,存储桶不应有超过三代差距。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 至少安装两个站点的 Ceph 对象网关。

流程

  1. 计算推荐的分片数量:

    number of objects expected in a bucket / 100,000
    注意

    目前支持的最大存储桶索引分片数量为 65,521。

  2. 将 zone group 配置提取到 zonegroup.json 文件中:

    示例

    [ceph: root@host01 /]# radosgw-admin zonegroup get > zonegroup.json

  3. zonegroup.json 文件中,为每个命名区设置 bucket_index_max_shards 参数:

    语法

    bucket_index_max_shards = VALUE

    使用计算的推荐分片数量替换 VALUE:

    示例

    bucket_index_max_shards = 12

  4. 重置 zone group:

    示例

    [ceph: root@host01 /]# radosgw-admin zonegroup set < zonegroup.json

  5. 更新周期:

    示例

    [ceph: root@host01 /]# radosgw-admin period update --commit

  6. 检查重新划分是否已完成:

    语法

    radosgw-admin reshard status --bucket BUCKET_NAME

    示例

    [ceph: root@host01 /]# radosgw-admin reshard status --bucket data

验证

  • 检查存储集群的同步状态:

    示例

    [ceph: root@host01 /]# radosgw-admin sync status

7.4.6. 动态重新划分存储桶索引

您可以通过将存储桶添加到重新划分队列来动态重新划分存储桶索引。它被计划重新划分。reshard 线程在后台运行,并一次执行调度的重新划分。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 至少安装两个站点的 Ceph 对象网关。

流程

  1. rgw_dynamic_resharding 参数设置为 true

    示例

    [ceph: root@host01 /]# radosgw-admin period get

  2. 可选:使用以下命令自定义 Ceph 配置:

    语法

    ceph config set client.rgw OPTION VALUE

    使用以下选项替换 OPTION:

    • rgw_reshard_num_logs :重新划分日志的分片数量。默认值为 16
    • rgw_reshard_bucket_lock_duration :在重新划分期间存储桶上锁定的持续时间。默认值为 360 秒。
    • rgw_dynamic_resharding :启用或禁用动态重新划分。默认值为 true
    • rgw_max_objs_per_shard :每个分片的最大对象数量。默认值为每个分片 100000 对象。
    • rgw_reshard_thread_interval :重新线程处理循环之间的最长时间。默认值为 600 秒。

    示例

    [ceph: root@host01 /]# ceph config set client.rgw rgw_reshard_num_logs 23

  3. 将存储桶添加到重新划分队列中:

    语法

    radosgw-admin reshard add --bucket BUCKET --num-shards NUMBER

    示例

    [ceph: root@host01 /]# radosgw-admin reshard add --bucket data --num-shards 10

  4. 列出重新划分队列:

    示例

    [ceph: root@host01 /]# radosgw-admin reshard list

  5. 检查存储桶日志生成和分片:

    示例

    [ceph: root@host01 /]# radosgw-admin bucket layout --bucket data
    {
        "layout": {
            "resharding": "None",
            "current_index": {
                "gen": 1,
                "layout": {
                    "type": "Normal",
                    "normal": {
                        "num_shards": 23,
                        "hash_type": "Mod"
                    }
                }
            },
            "logs": [
                {
                    "gen": 0,
                    "layout": {
                        "type": "InIndex",
                        "in_index": {
                            "gen": 0,
                            "layout": {
                                "num_shards": 11,
                                "hash_type": "Mod"
                            }
                        }
                    }
                },
                {
                    "gen": 1,
                    "layout": {
                        "type": "InIndex",
                        "in_index": {
                            "gen": 1,
                            "layout": {
                                "num_shards": 23,
                                "hash_type": "Mod"
                            }
                        }
                    }
                }
            ]
        }
    }

  6. 检查存储桶重新划分状态:

    语法

    radosgw-admin reshard status --bucket BUCKET

    示例

    [ceph: root@host01 /]# radosgw-admin reshard status --bucket data

  7. 立即处理重新划分队列中的条目:

    [ceph: root@host01 /]# radosgw-admin reshard process
  8. 取消待处理的存储桶重新划分:

    警告

    您只能取消 待处理的 重新划分操作。不要取消 正在进行的 重新划分的操作。

    语法

    radosgw-admin reshard cancel --bucket BUCKET

    示例

    [ceph: root@host01 /]# radosgw-admin reshard cancel --bucket data

验证

  • 检查存储桶重新划分状态:

    语法

    radosgw-admin reshard status --bucket BUCKET

    示例

    [ceph: root@host01 /]# radosgw-admin reshard status --bucket data

其他资源

7.4.7. 在多站点配置中动态重新划分存储桶索引

Red Hat Ceph Storage 5.3 支持动态 bucket 索引在多站点配置中重新划分。此功能允许在多站点配置中重新划分 bucket,而不中断对象的复制。启用 rgw_dynamic_resharding 时,它会独立在每个区上运行,并且该区域可能会为同一 bucket 选择不同的分片计数。

需要遵循的步骤 只用于 现有 Red Hat Ceph Storage 集群。升级存储集群后,您需要在现有区和 zone group 上手动启用 重新划分 功能。

注意

对于新的 Red Hat Ceph Storage 5.3 安装,默认支持并启用 zone 的 重新划分 功能。

注意

您可以在其他区赶上前重新划分存储桶三次。如需了解更多详细信息,请参阅 存储桶索引的限制重新划分

注意

如果存储桶已创建并上传超过动态重新划分的阈值对象,则需要继续将 I/O 写入旧存储桶,以开始重新划分过程。

先决条件

  • 两个站点上的 Red Hat Ceph Storage 集群都会升级到最新的版本。
  • 两个站点都启用的所有 Ceph 对象网关守护进程升级到最新版本。
  • 所有节点的根级别访问权限。

流程

  1. 检查 zonegroup 上是否启用了 resharding

    示例

    [ceph: root@host01 /]# radosgw-admin sync status

    如果没有为 zonegroup 重新启用 zonegroup 功能来重新划分 zonegroup,然后继续操作。

  2. 在安装了 Ceph 对象网关的多站点配置中所有 zonegroups 中启用 重新划分 功能:

    语法

    radosgw-admin zonegroup modify --rgw-zonegroup=ZONEGROUP_NAME --enable-feature=resharding

    示例

    [ceph: root@host01 /]# radosgw-admin zonegroup modify --rgw-zonegroup=us --enable-feature=resharding

  3. 更新 period 和提交:

    示例

    [ceph: root@host01 /]# radosgw-admin period update --commit

  4. 在安装了 Ceph 对象网关的多站点配置中的所有区上启用 重新划分 功能:

    语法

    radosgw-admin zone modify --rgw-zone=ZONE_NAME --enable-feature=resharding

    示例

    [ceph: root@host01 /]# radosgw-admin zone modify --rgw-zone=us-east --enable-feature=resharding

  5. 更新 period 和提交:

    示例

    [ceph: root@host01 /]# radosgw-admin period update --commit

  6. 验证 zone 和 zonegroups 上是否启用了 重新划分 功能。您可以看到每个区都列出其 supported_features,zonegroups 会列出其 enabled_features

    示例

    [ceph: root@host01 /]# radosgw-admin period get
    
    "zones": [
                        {
                            "id": "505b48db-6de0-45d5-8208-8c98f7b1278d",
                            "name": "us_east",
                            "endpoints": [
                                "http://10.0.208.11:8080"
                            ],
                            "log_meta": "false",
                            "log_data": "true",
                            "bucket_index_max_shards": 11,
                            "read_only": "false",
                            "tier_type": "",
                            "sync_from_all": "true",
                            "sync_from": [],
                            "redirect_zone": "",
                            "supported_features": [
                                "resharding"
                            ]
    .
    .
                    "default_placement": "default-placement",
                    "realm_id": "26cf6f23-c3a0-4d57-aae4-9b0010ee55cc",
                    "sync_policy": {
                        "groups": []
                    },
                    "enabled_features": [
                        "resharding"
                    ]

  7. 检查同步状态:

    示例

    [ceph: root@host01 /]# radosgw-admin sync status
              realm 26cf6f23-c3a0-4d57-aae4-9b0010ee55cc (usa)
          zonegroup 33a17718-6c77-493e-99fe-048d3110a06e (us)
               zone 505b48db-6de0-45d5-8208-8c98f7b1278d (us_east)
    zonegroup features enabled: resharding

    在本例中,您可以看到为 us zonegroup 启用 重新划分 功能。

  8. 可选:您可以为 zonegroups 禁用 重新划分 功能:

    1. 在安装了 Ceph 对象网关的多站点中所有 zonegroups 上禁用该功能:

      语法

      radosgw-admin zonegroup modify --rgw-zonegroup=ZONEGROUP_NAME --disable-feature=resharding

      示例

      [ceph: root@host01 /]# radosgw-admin zonegroup modify --rgw-zonegroup=us --disable-feature=resharding

    2. 更新 period 和提交:

      示例

      [ceph: root@host01 /]# radosgw-admin period update --commit

其它资源

  • 有关动态 bucket 索引的更可配置的参数重新划分,请参阅 Red Hat Ceph Storage Object Gateway Configuration and Administration Guide 中的 Dynamic Bucket Index Resharding 部分。

7.4.8. 手动重新划分存储桶索引

如果存储桶增长大于选择它的初始配置,请使用 radosgw-admin bucket reshard 命令重新定义存储桶索引池。这个命令执行以下任务:

  • 为指定存储桶创建新的 bucket 索引对象集合。
  • 在这些 bucket 索引对象之间分发对象条目。
  • 创建新的 bucket 实例。
  • 使用存储桶链接新 bucket 实例,以便所有新的索引操作都通过新 bucket 索引进行。
  • 将旧的和新的 bucket ID 打印到命令输出。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 至少安装两个站点的 Ceph 对象网关。

流程

  1. 备份原始存储桶索引:

    语法

    radosgw-admin bi list --bucket=BUCKET > BUCKET.list.backup

    示例

    [ceph: root@host01 /]# radosgw-admin bi list --bucket=data > data.list.backup

  2. 重新定义存储桶索引:

    语法

    radosgw-admin bucket reshard --bucket=BUCKET --num-shards=NUMBER

    示例

    [ceph: root@host01 /]# radosgw-admin bucket reshard --bucket=data --num-shards=100

验证

  • 检查存储桶重新划分状态:

    语法

    radosgw-admin reshard status --bucket bucket

    示例

    [ceph: root@host01 /]# radosgw-admin reshard status --bucket data

其它资源

7.4.9. 在重新划分后清理存储桶条目的过时实例

重新划分过程可能无法自动清理存储桶条目的过时的实例,这些实例可能会影响存储集群的性能。

手动清理它们,以防止过时的实例对存储集群的性能造成负面影响。

重要

在清理过时的实例前,请联系红帽支持

重要

仅在简单部署中使用这个步骤,而不是在多站点集群中使用。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 安装了 Ceph 对象网关.

流程

  1. 列出过时的实例:

    [ceph: root@host01 /]# radosgw-admin reshard stale-instances list
  2. 清理存储桶条目的过时的实例:

    [ceph: root@host01 /]# radosgw-admin reshard stale-instances rm

验证

  • 检查存储桶重新划分状态:

    语法

    radosgw-admin reshard status --bucket BUCKET

    示例

    [ceph: root@host01 /]# radosgw-admin reshard status --bucket data

7.4.10. 在重新划分后修复生命周期策略

对于具有重新划分实例的存储集群,旧的生命周期进程会标记并删除生命周期处理,因为存储桶实例在重新划分过程中发生了变化。但是,对于具有生命周期策略和已重新划分的旧存储桶,您可以使用 reshard 修复选项修复 这些存储桶。

先决条件

  • 一个正在运行的 Red Hat Ceph Storage 集群。
  • 安装了 Ceph 对象网关.

流程

  • 修复旧存储桶的生命周期策略:

    语法

    radosgw-admin lc reshard fix --bucket BUCKET_NAME

    重要

    如果不使用 --bucket 参数,则命令会修复存储集群中所有存储桶的生命周期策略。

    示例

    [ceph: root@host01 /]# radosgw-admin lc reshard fix --bucket mybucket