操作命令:
ceph osd getcrushmap -o map_old 导出map
crushtool -d map_old -o map_old.txt 转化成可编辑格式
crushtool -c map_new.txt -o map_new 还原为map
ceph osd setcrushmap -i map_new 将map导入ceph
更改Crush map流程:
1、修改配置文件,防止ceph自动更新crushmap
echo ‘osd_crush_update_on_start = false‘ >> /etc/ceph/ceph.conf /etc/init.d/ceph restart
2、导出map,并转化成可编辑格式
ceph osd getcrushmap -o map_old crushtool -d map_old -o map_old.txt cp map_old.txt map_new.txt
3、更改map_new.txt
如:
##################sas
host node1-sas {
id -2 # do not change unnecessarily
# weight 0.120
alg straw
hash 0 # rjenkins1
item osd.0 weight 0.040
item osd.1 weight 0.040
}
host node2-sas {
id -3 # do not change unnecessarily
# weight 0.120
alg straw
hash 0 # rjenkins1
item osd.3 weight 0.040
item osd.4 weight 0.040
}
##################ssd
host node1-ssd {
id -5 # do not change unnecessarily
# weight 0.120
alg straw
hash 0 # rjenkins1
item osd.2 weight 0.040
}
host node2-ssd {
id -6 # do not change unnecessarily
# weight 0.120
alg straw
hash 0 # rjenkins1
item osd.5 weight 0.040
}
#################pool
root sas-pool {
id -1 # do not change unnecessarily
# weight 0.360
alg straw
hash 0 # rjenkins1
item node1-sas weight 0.080
item node2-sas weight 0.080
}
root ssd-pool {
id -8 # do not change unnecessarily
# weight 0.360
alg straw
hash 0 # rjenkins1
item node1-ssd weight 0.040
item node2-ssd weight 0.040
}
##################rule
rule sas {
ruleset 0
type replicated
min_size 1
max_size 10
step take sas-pool
step choose firstn 0 type osd
step emit
}
rule ssd {
ruleset 1
type replicated
min_size 1
max_size 10
step take ssd-pool
step choose firstn 0 type osd
step emit
}4、将修改后的crushmap编译并且注入集群中
crushtool -c map_new.txt -o map_new ceph osd setcrushmap -i map_new ceph osd tree
5、创建资源池,使用新创建的规则
ceph osd pool create sas 128 128 ceph osd pool create ssd 128 128 ceph osd pool set sas crush_ruleset 0 ceph osd pool set ssd crush_ruleset 1
6、重新对pool授权(如果对接过openstack)
ceph auth del client.cinder ceph auth get-or-create client.cinder mon ‘allow r‘ osd ‘allow class-read object_prefix rbd_children,allow rwx pool=volumes, allow rwx pool=vms, allow rx pool=images, allow rwx pool=ssd‘
本文出自 “生命不息,奋斗不止!” 博客,请务必保留此出处http://linuxnote.blog.51cto.com/9876511/1790758
原文:http://linuxnote.blog.51cto.com/9876511/1790758