在多数据中心设置中放置 Ceph 卷和实例

loic

OpenStack Havana 安装在从 OVHHetzner 租用的机器上。为托管在 OVH 的机器创建了一个 聚合,为托管在 Hetzner 的机器创建了另一个聚合。使用来自 OVH 的磁盘创建一个 Ceph 集群,并使用来自 Hetzner 的磁盘创建另一个池。为每个 Ceph 池创建一个 cinder 后端。从 仪表板,可以使用由匹配的 OVH 池提供的 Ceph 卷在 OVH 可用区中创建一个实例。

创建可用区

可用区是 创建聚合的副作用。

# nova aggregate-create ovh ovh +----+------+-------------------+-------+--------------------------------+ | Id | Name | Availability Zone | Hosts | Metadata | +----+------+-------------------+-------+--------------------------------+ | 2 | ovh | ovh | [] | {u'availability_zone': u'ovh'} | +----+------+-------------------+-------+--------------------------------+

nova aggregate-create hetzner hetzner

+----+---------+-------------------+-------+------------------------------------+ | Id | Name | Availability Zone | Hosts | Metadata | +----+---------+-------------------+-------+------------------------------------+ | 3 | hetzner | hetzner | [] | {u'availability_zone': u'hetzner'} | +----+---------+-------------------+-------+------------------------------------+

将主机分配到其可用区

# nova aggregate-add-host ovh bm0015.the.re Aggregate 2 has been successfully updated. +----+------+-------------------+--------------------+--------------------------------+ | Id | Name | Availability Zone | Hosts | Metadata | +----+------+-------------------+--------------------+--------------------------------+ | 2 | ovh | ovh | [u'bm0015.the.re'] | {u'availability_zone': u'ovh'} | +----+------+-------------------+--------------------+--------------------------------+

可以使用以下命令检查结果

# nova availability-zone-list +-----------------------+----------------------------------------+ | Name | Status | +-----------------------+----------------------------------------+ | internal | available | | |- bm0015.the.re | | | | |- nova-conductor | enabled :-) 2013-11-11T14:26:43.000000 | | | |- nova-consoleauth | enabled :-) 2013-11-11T14:26:43.000000 | | | |- nova-scheduler | enabled :-) 2013-11-11T14:26:43.000000 | | | |- nova-cert | enabled :-) 2013-11-11T14:26:43.000000 | | ovh | available | | |- bm0015.the.re | | | | |- nova-compute | enabled :-) 2013-11-11T14:26:48.000000 | | hetzner | available | | |- bm0016.the.re | | | | |- nova-compute | enabled :-) 2013-11-11T14:26:49.000000 | | nova | available | +-----------------------+----------------------------------------+

创建 Ceph 池

使用以下命令提取 crush map

ceph osd getcrushmap -o crush.bin crushtool -d crush.bin -o crush.txt

对其进行编辑以添加

datacenter ovh { id -5 alg straw hash 0 item bm0014 weight 1.820 item bm0015 weight 1.820 }

rule ovh { ruleset 3 type replicated min_size 1 max_size 10 step take ovh step chooseleaf firstn 0 type host step emit }

并将其发送回 Ceph 监控器

crushtool -c crush.txt -o crush.bin ceph osd setcrushmap crush.bin

创建一个 ovh 池并将其设置为使用 ovh 规则集

ceph osd pool create ovh 128 ceph osd pool set ovh crush_ruleset 3

crush.txt 文件还包含 hetzner 池的规则集。

创建 cinder 后端

在运行 cinder-volume 的主机的 /etc/cinder/cinder.conf 文件中,为每个 Ceph 池定义一个 cinder 后端

enabled_backends=rbd-hetzner,rbd-ovh [rbd-hetzner] volume_driver=cinder.volume.driver.RBDDriver rbd_pool=hetzner volume_backend_name=RBD_HETZNER [rbd-ovh] volume_driver=cinder.volume.driver.RBDDriver rbd_pool=ovh volume_backend_name=RBD_OVH

为了启用 cinder create–volume-type ovh 选项,必须创建相应的类型键

# cinder type-create ovh +--------------------------------------+------+ | ID | Name | +--------------------------------------+------+ | 48645332-4835-4a9b-9078-cd735f47dae5 | ovh | +--------------------------------------+------+

cinder type-key ovh set volume_backend_name=RBD_OVH

cinder extra-specs-list

+--------------------------------------+---------+------------------------------------------+ | ID | Name | extra_specs | +--------------------------------------+---------+------------------------------------------+ | 48645332-4835-4a9b-9078-cd735f47dae5 | ovh | {u'volume_backend_name': u'RBD_OVH'} | +--------------------------------------+---------+------------------------------------------+

检查 cinder 调度器是否在 /etc/cinder/cinder.conf 中设置为如下

scheduler_driver=cinder.scheduler.filter_scheduler.FilterScheduler

组装实例和卷

使用 OVH cinder 后端创建卷后

cinder create --volume-type ovh --display-name test 1

在 OVH 可用区中创建一个实例

nova boot --availability-zone ovh \ --image 'cirros image' \ --key-name key_loic \ --nic net-id=e1d72366-1f25-42c1-a953-a944c9f932e3 \ --flavor m1.tiny --poll try

将卷附加到实例

nova volume-attach try 045d1cae-cd9b-4d64-b0b8-544f5b6d0c5a /dev/vdb