當你建立一個配置文件並用 mkcephfs部署Ceph, Ceph會在你的配置中生成一個默認CRUSH映射。默認CRUSH映射對你的Ceph sandbox環境很好。然而,當你部署一個大規模的數據集羣,你應該着重考慮開發一個自定義CRUSH映射,由於它會幫助你管理你的Ceph集羣,提升性能並確保數據的安全性。node
例如,若是一個OSD壞了,crush映射能夠幫助你能夠在你須要使用現場支持或替換硬件的項目中找到失敗的OSD的物理數據中心,空間,行和主機的機架。.python
一樣,crush能夠幫助你更迅速地找出故障。例如,若是在一個特定的機架中的全部的OSD同時壞了,故障可能在於一個網絡交換機或在機架或網絡交換機的電源,而不是OSD自己。算法
一個自定義的CRUSH映射也能夠幫助你識別Ceph存儲數據的冗餘副本的物理位置。當失敗的主機關聯配置組都處於降級狀態。vim
ceph osd getcrushmap-o {compiled-crushmap-filename}安全
# ceph osd getcrushmap -o crushmap.map
網絡
crushtool -d {compiled-crushmap-filename} -o {decompiled-crushmap-filename}性能
# crushtool -d crushmap.map -o crushmap.txt
ui
# vim crushmap.txt
spa
# 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 straw_calc_version 1 # devices device 0 osd.0 device 1 osd.1 device 2 osd.2 device 3 osd.3 device 4 osd.4 device 5 osd.5 device 6 osd.6 device 7 osd.7 device 8 osd.8 # 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 node2 { id -2 # do not change unnecessarily # weight 0.046 alg straw hash 0 # rjenkins1 item osd.0 weight 0.018 item osd.5 weight 0.018 item osd.6 weight 0.009 } host node3 { id -3 # do not change unnecessarily # weight 0.046 alg straw hash 0 # rjenkins1 item osd.1 weight 0.018 item osd.7 weight 0.018 item osd.8 weight 0.009 } host node1 { id -4 # do not change unnecessarily # weight 0.046 alg straw hash 0 # rjenkins1 item osd.2 weight 0.018 item osd.3 weight 0.018 item osd.4 weight 0.009 } root default { id -1 # do not change unnecessarily # weight 0.137 alg straw hash 0 # rjenkins1 item node2 weight 0.046 item node3 weight 0.046 item node1 weight 0.046 } # rules rule replicated_ruleset { ruleset 0 type replicated min_size 1 max_size 10 step take default step chooseleaf firstn 0 type host step emit } # end crush map
也能夠用如下的命令查看crush tree
code
# ceph osd crush tree
[ { "id": -1, "name": "default", "type": "root", "type_id": 10, "items": [ { "id": -2, "name": "node2", "type": "host", "type_id": 1, "items": [ { "id": 0, "name": "osd.0", "type": "osd", "type_id": 0, "crush_weight": 0.018494, "depth": 2 }, { "id": 5, "name": "osd.5", "type": "osd", "type_id": 0, "crush_weight": 0.018494, "depth": 2 }, { "id": 6, "name": "osd.6", "type": "osd", "type_id": 0, "crush_weight": 0.008789, "depth": 2 } ] }, { "id": -3, "name": "node3", "type": "host", "type_id": 1, "items": [ { "id": 1, "name": "osd.1", "type": "osd", "type_id": 0, "crush_weight": 0.018494, "depth": 2 }, { "id": 7, "name": "osd.7", "type": "osd", "type_id": 0, "crush_weight": 0.018494, "depth": 2 }, { "id": 8, "name": "osd.8", "type": "osd", "type_id": 0, "crush_weight": 0.008789, "depth": 2 } ] }, { "id": -4, "name": "node1", "type": "host", "type_id": 1, "items": [ { "id": 2, "name": "osd.2", "type": "osd", "type_id": 0, "crush_weight": 0.018494, "depth": 2 }, { "id": 3, "name": "osd.3", "type": "osd", "type_id": 0, "crush_weight": 0.018494, "depth": 2 }, { "id": 4, "name": "osd.4", "type": "osd", "type_id": 0, "crush_weight": 0.008789, "depth": 2 } ] } ] } ]
以及用一下命令查看devices、buckets和rulesets信息。
# ceph osd crush dump
ceph osd crush dump { "devices": [ { "id": 0, "name": "osd.0" }, { "id": 1, "name": "osd.1" }, { "id": 2, "name": "osd.2" }, { "id": 3, "name": "osd.3" }, { "id": 4, "name": "osd.4" }, { "id": 5, "name": "osd.5" }, { "id": 6, "name": "osd.6" }, { "id": 7, "name": "osd.7" }, { "id": 8, "name": "osd.8" } ], "types": [ { "type_id": 0, "name": "osd" }, { "type_id": 1, "name": "host" }, { "type_id": 2, "name": "chassis" }, { "type_id": 3, "name": "rack" }, { "type_id": 4, "name": "row" }, { "type_id": 5, "name": "pdu" }, { "type_id": 6, "name": "pod" }, { "type_id": 7, "name": "room" }, { "type_id": 8, "name": "datacenter" }, { "type_id": 9, "name": "region" }, { "type_id": 10, "name": "root" } ], "buckets": [ { "id": -1, "name": "default", "type_id": 10, "type_name": "root", "weight": 9000, "alg": "straw", "hash": "rjenkins1", "items": [ { "id": -2, "weight": 3000, "pos": 0 }, { "id": -3, "weight": 3000, "pos": 1 }, { "id": -4, "weight": 3000, "pos": 2 } ] }, { "id": -2, "name": "node2", "type_id": 1, "type_name": "host", "weight": 3000, "alg": "straw", "hash": "rjenkins1", "items": [ { "id": 0, "weight": 1212, "pos": 0 }, { "id": 5, "weight": 1212, "pos": 1 }, { "id": 6, "weight": 576, "pos": 2 } ] }, { "id": -3, "name": "node3", "type_id": 1, "type_name": "host", "weight": 3000, "alg": "straw", "hash": "rjenkins1", "items": [ { "id": 1, "weight": 1212, "pos": 0 }, { "id": 7, "weight": 1212, "pos": 1 }, { "id": 8, "weight": 576, "pos": 2 } ] }, { "id": -4, "name": "node1", "type_id": 1, "type_name": "host", "weight": 3000, "alg": "straw", "hash": "rjenkins1", "items": [ { "id": 2, "weight": 1212, "pos": 0 }, { "id": 3, "weight": 1212, "pos": 1 }, { "id": 4, "weight": 576, "pos": 2 } ] } ], "rules": [ { "rule_id": 0, "rule_name": "replicated_ruleset", "ruleset": 0, "type": 1, "min_size": 1, "max_size": 10, "steps": [ { "op": "take", "item": -1, "item_name": "default" }, { "op": "chooseleaf_firstn", "num": 0, "type": "host" }, { "op": "emit" } ] } ], "tunables": { "choose_local_tries": 0, "choose_local_fallback_tries": 0, "choose_total_tries": 50, "chooseleaf_descend_once": 1, "chooseleaf_vary_r": 0, "straw_calc_version": 1, "allowed_bucket_algs": 22, "profile": "unknown", "optimal_tunables": 0, "legacy_tunables": 0, "require_feature_tunables": 1, "require_feature_tunables2": 1, "require_feature_tunables3": 0, "has_v2_rules": 0, "has_v3_rules": 0, "has_v4_buckets": 0 } }
關於詳細的CRUSH Maps介紹能夠查閱官方文檔 CRUSH Maps中查看在ceph中CRUSH Map的介紹和規則,以及查閱算法CRUSH - Controlled, Scalable, Decentralized Placement of Replicated Data。
TODO
參考文獻
[1] CRUSH映射
[2] CRUSH Maps
[3] CRUSH算法 CRUSH - Controlled, Scalable, Decentralized Placement of Replicated Data