[root@serverc ~]# ceph osd crush add-bucket lxhcloud root added bucket lxhcloud type root to crush map
创建出上海这个城市
1 2
[root@serverc ~]# ceph osd crush add-bucket Shanghai region added bucket Shanghai type region to crush map
再创建出上海的徐汇机房
1 2
[root@serverc ~]# ceph osd crush add-bucket Datacenter-XuHui datacenter added bucket Datacenter-XuHui type datacenter to crush map
再创建出两个机柜
1 2 3 4
[root@serverc ~]# ceph osd crush add-bucket Rack-1 rack added bucket Rack-1 type rack to crush map [root@serverc ~]# ceph osd crush add-bucket Rack-2 rack added bucket Rack-2 type rack to crush map
把这几个对象按照业务整合起来,形成层级关系
1 2 3 4 5 6 7 8
[root@serverc ~]# ceph osd crush move Shanghai root=lxhcloud moved item id -10 name 'Shanghai' to location {root=lxhcloud} in crush map [root@serverc ~]# ceph osd crush move Datacenter-XuHui region=Shanghai moved item id -11 name 'Datacenter-XuHui' to location {region=Shanghai} in crush map [root@serverc ~]# ceph osd crush move Rack-1 datacenter=Datacenter-XuHui moved item id -15 name 'Rack-1' to location {datacenter=Datacenter-XuHui} in crush map [root@serverc ~]# ceph osd crush move Rack-2 datacenter=Datacenter-XuHui moved item id -16 name 'Rack-2' to location {datacenter=Datacenter-XuHui} in crush map
[root@serverc ~]# ceph osd crush move serverc rack=Rack-1 moved item id -3 name 'serverc' to location {rack=Rack-1} in crush map [root@serverc ~]# ceph osd crush move serverd rack=Rack-1 moved item id -5 name 'serverd' to location {rack=Rack-1} in crush map [root@serverc ~]# ceph osd crush move servere rack=Rack-2 moved item id -7 name 'servere' to location {rack=Rack-2} in crush map
[root@serverc ~]# ceph osd pool create ecpool erasure lxhecprofile pool 'ecpool' created [root@serverc ~]# ceph osd crush rule ls replicated_rule lxhrep ecpool
修改现有存储池的crush规则
将现有池的crush规则修改到lxhrep这个规则
以下命令批量修改了现有池的放置规则为lxhrep
1 2 3 4 5 6
[root@serverc ~]# for pool in $(ceph osd pool ls);do ceph osd pool set$pool crush_rule lxhrep;done set pool 1 crush_rule to lxhrep set pool 2 crush_rule to lxhrep set pool 3 crush_rule to lxhrep set pool 4 crush_rule to lxhrep set pool 5 crush_rule to lxhrep
[ceph: root@serverc /]# bash cmds.txt set 7.6 pg_upmap_items mapping to [7->5] set 7.7 pg_upmap_items mapping to [3->6] set 7.9 pg_upmap_items mapping to [4->5] set 7.16 pg_upmap_items mapping to [5->6] set 7.17 pg_upmap_items mapping to [2->8,7->6] set 7.18 pg_upmap_items mapping to [0->5] set 7.19 pg_upmap_items mapping to [3->6] set 7.1a pg_upmap_items mapping to [3->8] set 7.1b pg_upmap_items mapping to [2->6]