前言
本篇是luminous一个新功能介绍,关于磁盘智能分组的,这个在ceph里面叫crush class,这个我自己起名叫磁盘智能分组,因为这个实现的功能就是根据磁盘类型进行属性关联,然后进行分类,减少了很多的人为操作
以前我们需要对ssd和hdd进行分组的时候,需要大量的修改crush map,然后绑定不同的存储池到不同的 crush 树上面,现在这个逻辑简化了很多
ceph crush class {create,rm,ls} manage the new CRUSH device
class feature. ceph crush set-device-class
will set the clas for a particular device.
Each OSD can now have a device class associated with it (e.g., hdd or
ssd), allowing CRUSH rules to trivially map data to a subset of devices
in the system. Manually writing CRUSH rules or manual editing of the CRUSH is normally not required.
这个是发布的公告里面关于这两个功能的说明的,本篇就来看看这个功能怎么用
实践
首先创建分类的规则
创建一个ssd的分组
1 2
| [root@lab8106 ceph]# ceph osd crush class create ssd created class ssd with id 0 to crush map
|
也就是一个名称,这里我认为是ssd的分组就创建名词为ssd
再创建一个hdd的分组
1 2
| [root@lab8106 ceph]# ceph osd crush class create hdd created class hdd with id 1 to crush map
|
查询分组规则
1 2 3 4 5
| [root@lab8106 ceph]# ceph osd crush class ls [ "ssd", "hdd" ]
|
把osd绑定不同的属性(属性名称就是上面的分类)
1 2 3 4 5 6 7 8
| [root@lab8106 ceph]# ceph osd crush set-device-class osd.0 ssd set-device-class item id 0 name 'osd.0' device_class ssd [root@lab8106 ceph]# ceph osd crush set-device-class osd.2 ssd set-device-class item id 2 name 'osd.2' device_class ssd [root@lab8106 ceph]# ceph osd crush set-device-class osd.1 hdd set-device-class item id 1 name 'osd.1' device_class hdd [root@lab8106 ceph]# ceph osd crush set-device-class osd.3 hdd set-device-class item id 3 name 'osd.3' device_class hdd
|
查询设置以后的效果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| [root@lab8106 ceph]# ceph osd tree ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY -6 0.54559 root default~hdd -5 0.54559 host lab8106~hdd 1 0.27280 osd.1 up 1.00000 1.00000 3 0.27280 osd.3 up 1.00000 1.00000 -4 0.54559 root default~ssd -3 0.54559 host lab8106~ssd 0 0.27280 osd.0 up 1.00000 1.00000 2 0.27280 osd.2 up 1.00000 1.00000 -1 1.09119 root default -2 1.09119 host lab8106 0 0.27280 osd.0 up 1.00000 1.00000 1 0.27280 osd.1 up 1.00000 1.00000 2 0.27280 osd.2 up 1.00000 1.00000 3 0.27280 osd.3 up 1.00000 1.00000
|
这个就是这个功能比较核心的地方,会根据磁盘类型不同,自动的创建了不同的树,并且把磁盘放入到了树里面去了
根据根创建规则(这个地方有bug,下面会提及)
1
| [root@lab8106 ceph]# ceph osd crush rule create-simple ssd default~ssd host firstn
|
检查创建的rule规则:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| [root@lab8106 build]# ceph osd crush rule dump ssd { "rule_id": 1, "rule_name": "ssd", "ruleset": 1, "type": 1, "min_size": 1, "max_size": 10, "steps": [ { "op": "take", "item": -4, "item_name": "default~ssd" }, { "op": "chooseleaf_firstn", "num": 0, "type": "host" }, { "op": "emit" } ] }
|
根据rule创建存储池
1 2 3
| ceph osd pool create testpool 64 64 ssd ceph osd dump|grep pool pool 3 'testpool' replicated size 3 min_size 1 crush_rule 1 object_hash rjenkins pg_num 64 pgp_num 64 last_change 27 flags hashpspool stripe_width 0
|
这里有个验证规则的小bug 代码在src/mon/MonCommands.h
1 2 3 4
| COMMAND("osd crush rule create-simple " \ "name=name,type=CephString,goodchars=[A-Za-z0-9-_.] " \ "name=root,type=CephString,goodchars=[A-Za-z0-9-_.] " \ "name=type,type=CephString,goodchars=[A-Za-z0-9-_.] " \
|
默认的goodchars不包含’~’,这里不清楚社区是准备去改创建的逻辑去掉这个特殊符号,还是去改创建rule相关的规则,我已经提交了issue#20446,等待社区的修改方案
功能逻辑
现在方法
创建一个磁盘类型的class,给磁盘标记class的统一标签,自动会根据class的类型创建一个树,根据树创建rule,根据rule创建存储池,整个操作没有动crushmap的操作
增加或修改盘的时候,设置下属性即可
以前的方法
先添加盘,手动创建树,新加的osd要找下原来的树的名称,然后把osd放到这个树里面去,然后创建规则,根据rule创建存储池
增加盘或修改盘的时候,需要查找下,然后根据查找的规则进行相关操作
总结
现在方法对用户操作来说更透明,直接对磁盘进行分类打标签即可,减少了一些复杂的操作逻辑,是一个很不错的功能
更新
后面会在crush rule创建的时候指定一个class的选项,就可以不改规则,也不改命令了
https://www.spinics.net/lists/ceph-devel/msg37343.html,下个版本的rc应该会解决
变更记录
Why |
Who |
When |
创建 |
武汉-运维-磨渣 |
2017-06-28 |
更新进度 |
武汉-运维-磨渣 |
2017-06-28 |