修改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
- 下一篇: 有个人从飞机上掉下去然后穿上机甲打怪兽是