修改ceph crush map,并指定到资源池
生活随笔
收集整理的这篇文章主要介绍了
修改ceph crush map,并指定到资源池
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
版本:ceph L 版本 12.2.1
环境:单节点 15 osd
-1 0 root default -3 94.53119 host node1 0 hdd 5.37108 osd.0 up 1.00000 1.00000 1 hdd 5.37108 osd.1 up 1.00000 1.00000 2 hdd 5.37108 osd.2 up 1.00000 1.00000 3 hdd 5.37108 osd.3 up 1.00000 1.00000 4 hdd 1.75781 osd.4 up 1.00000 1.00000 5 hdd 7.12891 osd.5 up 1.00000 1.00000 6 hdd 7.12891 osd.6 up 1.00000 1.00000 7 hdd 7.12891 osd.7 up 1.00000 1.00000 8 hdd 7.12891 osd.8 up 1.00000 1.00000 9 hdd 7.12891 osd.9 up 1.00000 1.00000 10 hdd 7.12891 osd.10 up 1.00000 1.00000 11 hdd 7.12891 osd.11 up 1.00000 1.00000 12 hdd 7.12891 osd.12 up 1.00000 1.00000 13 hdd 7.12891 osd.13 up 1.00000 1.00000 14 hdd 7.12891 osd.14 up 1.00000 1.00000
创建根和crush 规则
- 取出两个osd 并重新指定osd的根,方便查看
ceph osd crush add osd.0 5.37108 host=test_rep_pool_1 root=test_rep
ceph osd crush add osd.1 5.37108 host=test_rep_pool_2 root=test_repID CLASS WEIGHT TYPE NAME STATUS REWEIGHT PRI-AFF -16 10.74216 root test_rep -15 5.37108 host test_rep_pool_1 0 hdd 5.37108 osd.0 up 1.00000 1.00000 -19 5.37108 host test_rep_pool_2 1 hdd 5.37108 osd.1 up 1.00000 1.00000 - 创建crush规则并指定根
ceph osd crush rule create-simple test_rep_rule test_rep host firstn
该命令中test_rep_rule为要创建的crush rule的名称,test_rep为该rule指定的根名称,即上一步创建的root命称test_rep
创建资源池
- 创建资源池并指定根
ceph osd pool create test_rep_pool 128 128 test_rep_rule
创建名称为test_rep_pool的资源池,pg数目为128,pgp数目为128,指定的crush规则为test_rep_rule - 查看创建后的资源池详细信息
ceph osd pool ls detailpool 2 'test_rep_pool' replicated size 3 min_size 2 crush_rule 2 object_hash rjenkins pg_num 128 pgp_num 128 last_change 98 flags hashpspool stripe_width 0 - 查看该存储池使用的crush 规则信息
[root@node1 ~]# ceph osd crush rule dump test_rep_rule `{ "rule_id": 2, #当前规则的编号 "rule_name": "test_rep_rule", #当前规则名称 "ruleset": 2, #当前规则所属的规则集, "type": 1, #一个字符串值,指定存储池类型是副本还是纠删吗,1 则为副本,3则为纠删码 "min_size": 1,#如果存储池副本数小于该值,则crush不会为该存储池使用该规则 "max_size": 10,#如果存储池副本数大于该值,则crush不会为该存储池使用该规则,即副本池目前支持的最大副本数为10副本,再大就会报异常 "steps": [{"op": "take","item": -16,"item_name": "test_rep"},{"op": "chooseleaf_firstn","num": 0,"type": "host"},{"op": "emit"} ] }
修改crush规则
- 从当前节点的mon获取CURSH map(如果在集群中,可以在任何一个节点获取)
ceph osd getcrushmap -o crush_map_file
该命令会在当前目录下生成一个名叫crush_map_file的文件,名称可以自己去更改[root@node1 ~]# ceph osd getcrushmap -o crush_map_test 41 [root@node1 ~]# ll crush_map_test -rw-r--r-- 1 root root 2337 May 4 15:45 crush_map_test - 使用
crushtool工具反编译以上文件,使其成为我们能够阅读的格式
crushtool -d crush_map_test -o crush_map_test_decompiel[root@node1 ~]# crushtool -d crush_map_test -o crush_map_test_decompiel [root@node1 ~]# ll crush_map_* -rw-r--r-- 1 root root 2337 May 4 15:45 crush_map_test -rw-r--r-- 1 root root 3658 May 4 15:48 crush_map_test_decompiel - 对
crush_map_test_decompiel文件进行编辑修改#可以看到在begin crush map和end crush map之间有很对crush map相关的信息,我们只修改部分我们自己的信息 #begin crush map ... rule test_rep_rule {id 2type replicatedmin_size 1 max_size 5 #修改该max_size 为5step take test_repstep chooseleaf firstn 0 type hoststep emit } - 修改完成后需要重新编译修改后的crush map文件为新的文件
crushtool -c crush_map_test_decompiel -o crush_new_map - 将修改后的
crush_new_map注入到原ceph集群中
ceph osd setcrushmap -i crush_new_map - 重新查看修改后的crush规则
[root@node1 ~]# ceph osd crush rule dump test_rep_rule { "rule_id": 2, "rule_name": "test_rep_rule", "ruleset": 2, "type": 1, "min_size": 1, "max_size": 5, #最大的副本数已经变为5 "steps": [{"op": "take","item": -16,"item_name": "test_rep"},{"op": "chooseleaf_firstn","num": 0,"type": "host"},{"op": "emit"} ] }
总结
以上是生活随笔为你收集整理的修改ceph crush map,并指定到资源池的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: ceph nautilus相对于mini
- 下一篇: 增加内核的ceph模块的日志打印