ceph crush map设置

本文介绍如何通过一系列步骤来获取并修改 Ceph 存储集群中的 Crush Map。包括从集群中导出 Crush Map 的二进制文件,将其转换为文本格式进行编辑,再转换回二进制文件并重新应用到集群中。此外还提供了创建池和设置 Crush 规则的具体命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 获取crushmap二进制文件


# ceph osd getcrushmap -o a.map


2.将二进制文件转成文本文件


# crushtool -d a.map -o  b


3.修改rules


# vi b








# begin crush map
tunable choose_local_tries 0
tunable choose_local_fallback_tries 0
tunable choose_total_tries 50
tunable chooseleaf_descend_once 1
tunable chooseleaf_vary_r 1
tunable chooseleaf_stable 1
tunable straw_calc_version 1
tunable allowed_bucket_algs 54


# devices
device 0 osd.0 class hdd
device 1 osd.1 class hdd
device 2 osd.2 class hdd
device 3 osd.3 class hdd
device 4 osd.4 class hdd
device 5 osd.5 class hdd
device 6 osd.6 class hdd
device 7 osd.7 class hdd
device 8 osd.8 class hdd
device 9 osd.9 class hdd
device 10 osd.10 class hdd
device 11 osd.11 class hdd


# types
type 0 osd
type 1 host
type 2 chassis
type 3 rack
type 4 row
type 5 pdu
type 6 pod
type 7 room
type 8 datacenter
type 9 region
type 10 root


# buckets
host ceph01-sas {
        id -3           # do not change unnecessarily
        alg straw2
        hash 0  # rjenkins1
        item osd.0 weight 0.010
        item osd.1 weight 0.010
}


host ceph01-ssd {
        id -4           # do not change unnecessarily
        alg straw2
        hash 0  # rjenkins1
        item osd.6 weight 0.010
        item osd.7 weight 0.010
}




host ceph02-sas {
        id -5           # do not change unnecessarily
        alg straw2
        hash 0  # rjenkins1
        item osd.2 weight 0.010
        item osd.3 weight 0.010
}


host ceph02-ssd {
        id -6           # do not change unnecessarily
        alg straw2
        hash 0  # rjenkins1
        item osd.8 weight 0.010
        item osd.9 weight 0.010
}


host ceph03-sas {
        id -7           # do not change unnecessarily
        alg straw2
        hash 0  # rjenkins1
        item osd.4 weight 0.010
        item osd.5 weight 0.010
}


host ceph03-ssd {
        id -8           # do not change unnecessarily
        alg straw2
        hash 0  # rjenkins1
        item osd.10 weight 0.010
        item osd.11 weight 0.010
}




root default {
        id -1           # do not change unnecessarily
        # weight 0.117
        alg straw2
        hash 0  # rjenkins1
        item ceph01-sas weight 0.039
        item ceph02-sas weight 0.039
        item ceph03-sas weight 0.039
        item ceph01-ssd weight 0.039
        item ceph02-ssd weight 0.039
        item ceph03-ssd weight 0.039
}


root ssd {
        id -9           # do not change unnecessarily
        alg straw
        hash 0  # rjenkins1
        item ceph01-ssd
        item ceph02-ssd
        item ceph03-ssd
}


root sas {
        id -10          # do not change unnecessarily
        alg straw
        hash 0  # rjenkins1
        item ceph01-sas
        item ceph02-sas
        item ceph03-sas
}


# rules
rule replicated_rule {
        id 0
        type replicated
        min_size 1
        max_size 10
        step take default
        step chooseleaf firstn 0 type host
        step emit
}
rule ssd {
        id 3
        type replicated
        min_size 1
        max_size 10
        step take ssd
        step choose firstn 0 type host
        step emit
}
rule sas {
        id 4
        type replicated
        min_size 1
        max_size 10
        step take sas
        step choose firstn 0 type host
        step emit
}


# end crush map




4.将文本文件转成二进制文件


# crushtool -c b -o b.map






5.设置crushmap


# ceph osd setcrushmap -i b.map






[lam@ceph01 ceph-cluster]$ ceph osd pool create sas 200
pool 'sas' created
[lam@ceph01 ceph-cluster]$ ceph osd pool create ssd 200
pool 'ssd' created




ceph osd pool set ssd crush_rule ssd
ceph osd pool set sas crush_rule sas


ceph osd dump | grep replica




ceph osd tier add sas ssd


重启所有节点
systemctl restart ceph.target
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值