Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1488478
  • 博文数量: 230
  • 博客积分: 474
  • 博客等级: 下士
  • 技术积分: 1955
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-19 18:40
文章分类

全部博文(230)

文章存档

2020年(3)

2019年(3)

2018年(12)

2017年(13)

2016年(11)

2015年(55)

2014年(74)

2013年(39)

2012年(2)

2011年(18)

我的朋友

分类: 云计算

2015-12-16 14:29:55

概述

        libvirt配置了librbdQEMU接口,通过它可以在OpenStack中使用Ceph块存储。Ceph块存储是集群对象,这意味着它比独立的服务器有更好的性能。
        在OpenStack中使用Ceph块设备,必须首先安装QEMUlibvirtOpenStack,下图描述了 OpenStackCeph技术层次结构:


http://my.oschina.net/JerryBaby/blog/376580 我翻译的官方文档,仅供参考 ^ ^

系统规划

OpenStack集群:
         控制节点:openstackcontroller192.168.1.131
         计算节点:compute                      192.168.1.132
         存储节点:storage                        192.168.1.133

Ceph集群:
       monitormdsosd0 节点:openstackcontroller192.168.1.131
       osd1compute       192.168.1.132
       osd2storage         192.168.1.133

系统架构:


配置过程

Important:由于这里将两套集群服务部署在了同一组节点上,所以配置过程中省略了一些关于Ceph集群的配置。

创建存储池

?
1
2
3
# ceph osd pool create volumes 128
# ceph osd pool create images 128
# ceph osd pool create vms 128

设置Ceph客户端认证

OpenStack节点执行如下命令:

?
1
2
# 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'
# ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'

client.cinderclient.glance添加密钥文件来访问节点并改变属主:

?
1
2
3
4
5
6
7
8
# ceph auth get-or-create client.glance | ssh openstack sudo tee /etc/ceph/ceph.client.glance.keyring
# ssh openstack sudo chown glance:glance /etc/ceph/ceph.client.glance.keyring
# ceph auth get-or-create client.glance | ssh compute sudo tee /etc/ceph/ceph.client.glance.keyring
# ssh compute sudo chown nova:nova /etc/ceph/ceph.client.glance.keyring
# ceph auth get-or-create client.cinder | ssh compute sudo tee /etc/ceph/ceph.client.cinder.keyring
# ssh compute sudo chown nova:nova /etc/ceph/ceph.client.cinder.keyring
# ceph auth get-or-create client.cinder | ssh storage sudo tee /etc/ceph/ceph.client.cinde.keyring
# ssh storage sudo chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring

运行nova-compute的节点nova-compute进程需要密钥文件。它们也存储client.cinder用户的密钥在libvirtlibvirt进程在Cinder中绑定块设备时需要用到它来访问集群。
nova-compute节点创建一个临时的密钥副本:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
# uuidgen
457eb676-33da-42ec-9a8c-9293d545c337
 
# cat > secret.xml <
  457eb676-33da-42ec-9a8c-9293d545c337
  
    client.cinder secret
  
EOF
# sudo virsh secret-define --file secret.xml
# sudo virsh secret-set-value --secret 457eb676-33da-42ec-9a8c-9293d545c337 --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml

配置Glance

编辑 /etc/glance/glance-api.conf并添加如下内容:

?
1
2
3
4
5
6
7
8
9
[DEFAULT]
default_store = rbd
...
[glance_store]
stores = rbd
rbd_store_pool = images
rbd_store_user = glance
rbd_store_ceph_conf = /etc/ceph/ceph.conf
rbd_store_chunk_size = 8

如果要启动镜像的写时复制功能,添加下面的 [DEFAULT] 部分:

?
1
show_image_direct_url = True

配置Cinder

openstack节点和storage节点编辑 /etc/cinder/cinder.conf配置文件并添加如下内容:

?
1
2
3
4
5
6
7
8
volume_driver = cinder.volume.drivers.rbd.RBDDriver
rbd_pool = volumes
rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_flatten_volume_from_snapshot = false
rbd_max_clone_depth = 5
rbd_store_chunk_size = 4
rados_connect_timeout = -1
glance_api_version = 2

如果使用cephx验证,需要配置useruuid

?
1
2
rbd_user = cinder
rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337

配置Nova

为了挂载Cinder设备(普通设备或可引导卷),必须指明使用的用户及UUIDlibvirt将使用期在Ceph集群中进行连接和验证:

?
1
2
rbd_user = cinder
rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337

编辑 /etc/nova/nova.conf并添加如下内容:

?
1
2
3
4
5
6
7
[libvirt]
images_type = rbd
images_rbd_pool = vms
images_rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_user = cinder
rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337
libvirt_live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST"

禁用文件注入。当启动一个实例的时候,nova通常会尝试打开rootfs。这时,nova注入一些数据,如密码、ssh 密钥,配置文件等到文件系统中。然而,这最好依靠元数据服务和cloud-init来完成。

在每个计算节点,编辑 /etc/nova/nova.conf  [libvirt] 标签添加:

?
1
2
3
libvirt_inject_password = false
libvirt_inject_key = false
libvirt_inject_partition = -2

重启服务

?
1
2
3
4
# sudo glance-control api restart
# sudo service nova-compute restart
# sudo service cinder-volume restart
# sudo service cinder-backup restar

从块设备引导

Ceph后端存储状况:

Ceph不支持从qcow2格式的镜像引导,所以创建一个raw格式的镜像:

创建一个可引导卷:


从可引导卷创建一个实例:

查看Ceph存储状况:

阅读(2066) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~