OpenStack 和 Ceph 集成

本文介绍如何将Ceph与OpenStack集成,包括配置libvirt和QEMU与Ceph的接口,设置Ceph集群,配置Glance以管理映像,以及配置Cinder以管理卷。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ceph通过利用libvirt和OpenStack一起使用块设备,其中的libvirt配置了QEMU同librbd的接口。OpenStack中有两个部分同Ceph的块设备进行了集成: 

  • 映像(Image): 使用OpenStack Glance对VM的映像进行管理 
  • 卷(Volume): OpenStack使用卷来启动VM,它还能向运行中的VM添加额外的卷 

Ceph 集群

创建卷池和图像池: 

rados mkpool volumes
rados mkpool images

增加两个池的复制水平: 

ceph osd pool set volumes size 3
ceph osd pool set images size 3

现在,为两个池创建 Ceph 客户端和密钥环: 

ceph auth get-or-create client.volumes mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rx pool=images' -o /etc/ceph/client.volumes.keyring
ceph auth get-or-create client.images mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images' -o /etc/ceph/client.images.keyring

将上面的密钥环复制到 glance-api并将 cinder-volume 节点和 ceph.conf 文件拷贝到 /etc/ceph/目录下。运行 nova-compute 的主机无需密钥环。替代的,他们讲密钥储存于 libvirt。要创建 libvirt 密钥,你需要来自 client.volumes.keyring 的密钥。你可以通过下面命令取得: 

ceph-authtool -p -n client.volumes /etc/ceph/client.volumes.keyring > /etc/ceph/client.volumes

当需要时,拷贝这个密钥到 nova-compute 节点。在设置完成后,你可以删除它。同时,要安装 Ceph 组件,你需要 Ceph 官方库(ubuntu): 

wget -q -O - 'https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc' | apt-key add -
echo "deb http://ceph.com/debian-cuttlefish/ precise main" >> /etc/apt/sources.list.d/ceph.list

在你拷贝 Ceph 集群的 ceph.conf 到 glance-api,且 cinder-volume 节点更新密钥环路径之后: 

[client.volumes]
    keyring = /etc/ceph/client.volumes.keyring
[client.images]
    keyring = /etc/ceph/client.images.keyring

Glance 

在 glance-api 主机,你需要为 librbd 绑定 Python: 

apt-get install -y python-ceph

更新你的 glance-api 配置文件(/etc/glance/glance-api.conf): 

default_store = rbd
rbd_store_user = images
rbd_store_pool = images
show_image_direct_url = True

并重启 glance-api 服务: 

service glance-api restart

Nova compute

创建临时的 secret.xml 文件: 

cat > secret.xml <<EOF
<secret ephemeral='no' private='no'>
  <usage type='ceph'>
    <name>client.volumes secret</name>
  </usage>
</secret>
EOF

从创建的 secret.xml 文件创建密钥: 

virsh secret-define --file secret.xml

设定 libvirt 使用上面的密钥: 

virsh secret-set-value --secret your_key \
                       --base64 $(cat /path/to/client.volumes)
rm client.volumes secret.xml

将密钥记录下载,以便于使用上面的命令添加节点。你也需要使用这个密钥来配置 cinder。重启 nova-compute: 

service nova-compute restart

从Ceph 源更新 librbd 到最新版本。 Ubuntu 所带版本较老,无法工作: 

apt-get upgrade librbd

Cinder 卷

在 cinder-volume 主机,安装客户端命令行工具: 

apt-get install -y ceph-common

更新 cinder 配置 (/etc/cinder/cinder.conf): 

#iscsi_helper = tgtadm
#volumes_dir = /var/lib/cinder/volumes
# Folsom
#volume_driver=cinder.volume.driver.RBDDriver
# Grizzly
volume_driver=cinder.volume.drivers.rbd.RBDDriver
rbd_pool=volumes
rbd_user=volumes
# libvirt secret key
rbd_secret_uuid=your_key

在 cinder 启动脚本配置文件(/etc/init/cinder-volume.conf)的“stop on runlevel [!2345]” 之后添加如下代码: 

env CEPH_ARGS="--id volumes"

重启 cinder-volume 服务: 

service cinder-volume restart

所有完成后,你应该可以储存 glance 图像,创建卷,通过卷将它们附加到运行机器或启动机器上。同时,Ceph 兼容敏捷API,你可以将对象直接横向传递给 Ceph。更多信息将在我说道 RadosGW 时提及。 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值