标签:100% max 新建 pad 分布 eps dba white title
上面左边是我的个人微信,如需进一步沟通,请加微信。 右边是我的公众号“Openstack私有云”,如有兴趣,请关注。
上篇《Openstack 之使用外部ceph存储》中提到,为了达到不同的pool可以使用不同类型的硬盘组成的存储池,对于只是需要解决存储分级的小规模集群场景来说,先使用kolla进行统一部署ceph,在部署完成之后,然后通过手动调整ceph crush存储规则,新建rule,将相应的osd划入对应的rule,最后将相应的pool调整到相应的rule。这里我们就这个想法进行实际验证。
Openstack集群环境:
系统centos7.3
Openstack版本 Ocata 4.0.2.1 ,使用kolla部署
Openstack集群服务器分配如下:
节点 | 服务 | IP |
control01 | control+compute+network | 192.168.1.130 |
control02 | control+compute+network | 192.168.1.131 |
control03 | control+compute+network | 192.168.1.132 |
已经成功部署了3个节点的控制+存储+计算+网络的融合节点,ceph的osd初始分布如下:
ceph> osd tree
ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY
-5 0 root ssd
-6 0 chassis ssd-hosts
-1 9.00000 root default
-2 3.00000 host 192.168.1.132
0 1.00000 osd.0 up 1.00000 1.00000
3 1.00000 osd.3 up 1.00000 1.00000
6 1.00000 osd.6 up 1.00000 1.00000
-3 3.00000 host 192.168.1.130
1 1.00000 osd.1 up 1.00000 1.00000
5 1.00000 osd.5 up 1.00000 1.00000
7 1.00000 osd.7 up 1.00000 1.00000
-4 3.00000 host 192.168.1.131
2 1.00000 osd.2 up 1.00000 1.00000
4 1.00000 osd.4 up 1.00000 1.00000
8 1.00000 osd.8 up 1.00000 1.00000
我们的目标是,将ssd硬盘 osd.0/osd.1/osd.2 等3个ssd类型硬盘osd划入一个新的root根ssd,新的host组ssd-hosts ,新的host,将这3个osd分别移入新的host中,同时新建一个rule规则ssd-rule ,使这个根ssd的所有设备使用这个ssd-rule规则。最后,将openstack存放虚拟机的pool池vms设置使用这个ssd-rule规则,这样,就达到了虚拟机池vms使用ssd硬盘池的目的。同样的道理,对于glance和cinder-backup可以使用慢速硬盘SATA盘组成的慢速存储池,也可以用同样的方法进行调整。
操作记录:
创建ssd root
docker exec -it ceph_mon ceph osd crush add-bucket ssd root
//创建一个新的桶叫ssd ,级别是root最高级
创建chassis
docker exec -it ceph_mon ceph osd crush add-bucket ssd-hosts chassis
//创建一个新的桶叫ssd-hosts ,级别是机框
docker exec -it ceph_mon ceph osd crush move ssd-hosts root=ssd
//将ssd-hosts归入ssd
创建host
docker exec -it ceph_mon ceph osd crush add-bucket ssd-132 host
docker exec -it ceph_mon ceph osd crush add-bucket ssd-130 host
docker exec -it ceph_mon ceph osd crush add-bucket ssd-131 host
//创建3个新的桶叫ssd-132/ssd-130/ssd-131 ,级别是host
docker exec -it ceph_mon ceph osd crush move ssd-132 chassis=ssd-hosts
docker exec -it ceph_mon ceph osd crush move ssd-130 chassis=ssd-hosts
docker exec -it ceph_mon ceph osd crush move ssd-131 chassis=ssd-hosts
//将ssd-132/ssd-130/ssd-131归入ssd-hosts
移动osd
docker exec -it ceph_mon ceph osd crush set osd.0 1.0 host=ssd-132
docker exec -it ceph_mon ceph osd crush set osd.1 1.0 host=ssd-130
docker exec -it ceph_mon ceph osd crush set osd.2 1.0 host=ssd-131
//将osd.0/osd.1 /osd.2移动到对应的host 中
创建crush rule
docker exec -it ceph_mon ceph osd crush rule create-simple ssd-rule ssd host firstn
//创建crush rule,rule名称是ssd-rule,root=ssd,tpye=host,mode=firstn
经过调整之后osd的分布如下:
ceph> osd tree
ID WEIGHT TYPE NAME UP/DOWN REWEIGHT PRIMARY-AFFINITY
-5 3.00000 root ssd
-6 3.00000 chassis ssd-hosts
-7 1.00000 host ssd-132
0 1.00000 osd.0 up 1.00000 1.00000
-8 1.00000 host ssd-130
1 1.00000 osd.1 up 1.00000 1.00000
-9 1.00000 host ssd-131
2 1.00000 osd.2 up 1.00000 1.00000
-1 6.00000 root default
-2 2.00000 host 192.168.1.132
3 1.00000 osd.3 up 1.00000 1.00000
6 1.00000 osd.6 up 1.00000 1.00000
-3 2.00000 host 192.168.1.130
5 1.00000 osd.5 up 1.00000 1.00000
7 1.00000 osd.7 up 1.00000 1.00000
-4 2.00000 host 192.168.1.131
4 1.00000 osd.4 up 1.00000 1.00000
8 1.00000 osd.8 up 1.00000 1.00000
crush rule规则如下:
# docker exec -it ceph_mon ceph osd crush rule dump
[
{
"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"
}
]
},
{
"rule_id": 1,
"rule_name": "disks",
"ruleset": 1,
"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"
}
]
},
{
"rule_id": 2,
"rule_name": "ssd-rule",
"ruleset": 2,
"type": 1,
"min_size": 1,
"max_size": 10,
"steps": [
{
"op": "take",
"item": -5,
"item_name": "ssd"
},
{
"op": "chooseleaf_firstn",
"num": 0,
"type": "host"
},
{
"op": "emit"
}
]
}
]
可以看到新增的ssd-rule的ruleid是2。
更改vms pool的rule:
设置openstack的虚拟机存储池vms使用的rule为ssd-rule:
docker exec -it ceph_mon ceph ceph osd pool set vms crush_ruleset 2
验证:
1. 列出vms中的images:
[root@control01 neutron]# docker exec -it ceph_mon rbd -p vms ls
4ba3e273-b729-4a24-8040-629b9b58fe43_disk
2. 查看images是不是分布在osd.0/osd.1/osd.2这3块ssd盘中:
[root@control01 ceph-mon]# docker exec -it ceph_mon bash
(ceph-mon)[root@control01 ceph]# vi rbd_loc.sh
#!/bin/bash
# USAGE:./rbd-loc <pool> <image>
if [ -z ${1} ] || [ -z ${2} ];
then
echo "USAGE: ./rbd-loc <pool> <image>"
exit 1
fi
rbd_prefix=$(rbd -p ${1} info ${2} | grep block_name_prefix | awk '{print $2}')
for i in $(rados -p ${1} ls | grep ${rbd_prefix})
do
ceph osd map ${1} ${i}
done
(ceph-mon)[root@control01 ceph]# chmod +x rbd_loc.sh
(ceph-mon)[root@control01 ceph]# ./rbd_loc.sh vms 4ba3e273-b729-4a24-8040-629b9b58fe43_disk
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000004' -> pg 9.eec101a0 (9.20) -> up ([2,1], p2) acting ([2,1], p2)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000006' -> pg 9.9f03d335 (9.35) -> up ([1,2], p1) acting ([1,2], p1)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000001' -> pg 9.67b18ab5 (9.35) -> up ([1,2], p1) acting ([1,2], p1)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000003' -> pg 9.5897ddc8 (9.48) -> up ([0,2], p0) acting ([0,2], p0)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000007' -> pg 9.dbace74b (9.4b) -> up ([2,0], p2) acting ([2,0], p2)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000000' -> pg 9.f1ab8f4d (9.4d) -> up ([0,2], p0) acting ([0,2], p0)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000005' -> pg 9.20dc9e6c (9.6c) -> up ([1,2], p1) acting ([1,2], p1)
osdmap e685 pool 'vms' (9) object 'rbd_data.2744fe204970c8.0000000000000002' -> pg 9.7f6d55f7 (9.77) -> up ([2,0], p2) acting ([2,0], p2)
从上面的结果可以看到,所有的数据副本object所在的pg,都放在0,1,2上 。
验证成功!
标签:100% max 新建 pad 分布 eps dba white title
原文地址:http://blog.51cto.com/yuweibing/2140532