Openstack云平台搭建课程十·集成Ceph存储

这是搭建Openstack云平台的第十堂课,主要讲述在Openstack中如何通过cinder结合ceph的方式部署存储集群。

Ceph是一个无单点故障的分布式存储平台,支持数据无缝复制,同时也支持并发读写等,正是由于ceph具备这些优秀特性,OPenstack通常使用Ceph作为后端存储。

Ceph集群部署方法请前往:分布式云存储Ceph部署方法

配置存储服务(所有ceph节点)

创建存储池

注意:该pool的值请参照关于pgp的说明部分。

ceph osd pool create volumes 128 #永久性存储
ceph osd pool create backups 128 #备份存储
ceph osd pool create vms 128     #实例临时后端存储
ceph osd pool create images 128  #镜像存储

创建用户并授权

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'
ceph auth get-or-create client.cinder-backup mon 'allow r' osd '\
allow class-read object_prefix rbd_children, \
allow rwx pool=columes, \
allow rwx pool=vms, \
allow rwx pool=backups'

Glance集成Ceph

安装(所有glance-api节点)

yum -y install python-rbd ceph

同步密钥(cephmgr节点)

ceph auth get-or-create client.glance | ssh controller tee /etc/ceph/ceph.client.glance.keyring

修改配置

修改配置/etc/glance/glance-api.conf

[glance_store]
stores = glance.store.rbd.Store
default_store = rbd
rbd_store_pool = images
rbd_store_user = glance
ceph_conf = /etc/ceph/ceph.conf

管理镜像

# 转换
qemu-img convert cirros-0.3.5-x86_64-disk.img cirros-0.3.5-x86_64-disk.raw
# 上传
glance image-create --name ceph-cirros --disk-format raw --container-format bare --visibility public --file cirros-0.3.5-x86_64-disk.raw
# openstack image create --disk-format raw --container-format bare --public --file CentOS-7-x86_64-DVD-1708.iso CentOS-7-x86_64-1708

计算节点集成Ceph(所有nova-compute节点)

安装

建议在ceph管理节点上通过ceph-deploy部署,以下是本机安装方法:

yum -y install ceph ceph-radosgw

同步密钥

在ceph管理节点执行如下命令同步密钥:

ceph auth get-key client.cinder | ssh compute tee clinet.cinder.key

配置kvm访问ceph池

cat > secret.xml << EOF
<secret ephemeral='no' private='no'>
<uuid>d9de3482-448c-4fc4-8ccc-f32e00b8764e</uuid>
<usage type='ceph'>
<name>client.cinder secret</name>
</usage>
</secret>
EOF

然后在计算节点执行如下命令(注意文件路径):

virsh secret-define --file secret.xml
virsh secret-set-value --secret d9de3482-448c-4fc4-8ccc-f32e00b8764e --base64 $(cat clinet.cinder)

修改配置

修改配置/etc/nova/nova.conf

[libvirt]
images_type = rbd
images_rbd_pool = vms
images_rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_user = cinder
rbd_secret_uuid = d9de3482-448c-4fc4-8ccc-f32e00b8764e
#其他优化,禁止文件注入
#inject_password = false
#inject_key = false
#inject_partition = -2

Cinder集成Ceph(所有cinder-volume节点)

安装

yum -y install ceph

同步密钥

ceph auth get-or-create client.cinder | ssh controller tee /etc/ceph/ceph.client.cinder.keyring
ceph auth get-or-create client.cinder-backup | ssh controller tee /etc/ceph/ceph.client.cinder-backup.keyring

修改配置文件

修改配置/etc/cinder/cinder.conf

[DEFAULT]
enabled_backends = ceph
glance_api_servers = http://controller:9292
osapi_volume_listen = $my_ip
osapi_volume_listen_port = 8776
state_path = /var/lib/cinder

[ceph]
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
#以下是多ceph后端参数
glance_api_version = 2
rbd_user = cinder
rbd_secret_uuid = d9de3482-448c-4fc4-8ccc-f32e00b8764e
volume_backend_name = ceph

此时,可以注释或删除[lvm]段中的内容,随后重启cinder-volume:

systemctl restart openstack-cinder-volume
# 查看cinder服务状态
cinder service-list
# cinder-manage volume update_host --currenthost controller --newhost controller@BACKEND

如果添加多个ceph后端,可以参考上述配置文件中的ceph段,新建[ceph-a]段并修改参数,如:

[ceph-a]
...
rbd_pool = volumes-a
rbd_ceph_conf = /etc/ceph/ceph-a.conf
...

附加知识

配置卷类型

cinder type-create ceph
cinder type-key ceph set volume_backend_name=ceph
cinder extra-specs-list

#如果一个ceph节点有多个ceph后端
#cinder type-create ceph-a
#cinder type-key ceph-a set volume_backend_name=ceph-a

生成volume

cinder create --volume-type ceph --name ceph-volume1 1024 #卷大小为1024G
cinder list
rbd ls volumes

原创文章禁止转载:技术学堂 » Openstack云平台搭建课程十·集成Ceph存储

精彩评论

9+8=

感谢您的支持与鼓励

支付宝扫一扫打赏

微信扫一扫打赏