使用命令行管理多数据中心 CRUSH 映射

loic

一个新的数据中心被添加到 CRUSH 映射Ceph 集群中

# ceph osd crush add-bucket fsf datacenter 添加了 bucket fsf,类型为 datacenter 到 crush 映射

ceph osd crush move fsf root=default

已将 item id -13 名称 'fsf' 移动到 crush 映射中的位置 {root=default}

ceph osd tree

id weight type name up/down reweight

-13 0 datacenter fsf -5 7.28 datacenter ovh -2 1.82 host bm0014 0 1.82 osd.0 up 1 ...

datacenter bucket 类型默认情况下已经存在于集群创建时提供的默认 CRUSH 映射中。 fsf bucket 被移动(使用 crush move )到 CRUSH 映射的根目录。

创建一个新的规则,以获取 fsf 数据中心中的对象,并确保没有 host 持有超过一个副本

# ceph osd crush rule create-simple fsf-rule fsf host

ceph osd crush rule dump

... { "rule_id": 6, "rule_name": "fsf", "ruleset": 6, "type": 1, "min_size": 1, "max_size": 10, "steps": [ { "op": "take", "item": -13}, { "op": "chooseleaf_firstn", "num": 0, "type": "host"}, { "op": "emit"}]}]

创建一个新的 pool 并将其与新创建的规则(id 6 )关联

# ceph osd pool create fsf 128 创建了 pool 'fsf'

ceph osd pool set fsf crush_ruleset 6

将 pool 7 的 crush_ruleset 设置为 6

通过将以下内容添加到 /etc/ceph/ceph.conf,OSD 会自动添加到 fsf bucket 中

osd_crush_update_on_start = 1 osd_crush_location = datacenter=fsf

该配置被 ceph-osd upstart 脚本 解释,该脚本在创建新的 OSD 或机器启动时触发。

# ceph-deploy osd create bm0101.the.re:/dev/sdb:/dev/sdc ...

ceph osd tree

... -13 3.64 datacenter fsf -14 3.64 host bm0101 8 3.64 osd.8 up 1