对接分为三种,也就是存储为openstack提供的三类功能
1.云盘,就好比我们新加的硬盘
2.原本的镜像也放在ceph里,但是我没有选择这种方式,原因是因为后期有要求,但是我会把这个也写出来,大家自己对比
3.为云主机提供系统盘,在云主机创建的初期就必须给人家/、/boot、/home一类分空间,大家都懂的
ceph -s检查健康状态,一般情况回事HEALTH_WARN或者HEALTH_OK,ok就不说了没问题,warn也很常见说下问题跟解决方式:
1.health HEALTH_WARN too few PGs per OSD (X < min 30)
2.health HEALTH_WARN clock skew detected on mon1, mon2
第一种一般出现在你的ceph集群刚刚搭建完成,意思就是你的pg太少了,ceph的基础理论不写了,太多了,这个要大家自己去了解了,这个报错暂时可以忽略,因为我们要对接需要新建池加pg,之后就够了,你只要看到最下面是88 active+clean没有别的什么unclean或者inactive就好
第二种其实更简单啦,就是时间同步有问题,去调整下时间即可
正式开始:
创建对应三类功能的三个池,并指定pg数量,这样你的pg一般就够了
ceph osd pool create volumes 16
ceph osd pool create images 16
ceph osd pool create vms 16
创建关于池的密钥
ceph auth get-or-create client.glance | ssh controller01 tee /etc/ceph/ceph.client.glance.keyring
ssh controller01 chown glance:glance /etc/ceph/ceph.client.glance.keyring
ceph auth get-or-create client.cinder | ssh controller01 tee /etc/ceph/ceph.client.cinder.keyring
ssh controller01 chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring
创建操作池的用户,用户名格式请注意,必须是client.XXXX
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'
如果出现Error EINVAL: key for client.cinder exists but cap mon does not match则先执行更新cap后再次执行上面两条命令:
ceph auth caps 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 caps client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images'
各计算节点执行
ceph auth get-key client.cinder | ssh computer01 tee client.cinder.key(会返回字符串,记一下)
vim secret.xml
virsh secret-define --file secret.xml
此时如果报错a secret with UUID 455edb45-910c-4711-a511-14ee5491cd48 already defined for use with client.cinder secret
virsh secret-list会列出client.cinder之前的UUID
virsh secret-undefine 455edb45-910c-4711-a511-14ee5491cd48
再次virsh secret-define --file secret.xml
virsh secret-set-value --secret 192ff8f8-2e80-4b5f-abcf-9792ccc5a91f --base64 AQAGGC1Y2J7kJRAACJD6Qw4SQN+ph0g7mwnUGA==
最后那一长串就是刚才返回的字符串
镜像对接:
修改部署glance服务的节点配置文件/etc/glance/glance-api.conf
[glance_store]
default_store = rbd
stores = rbd
rbd_store_pool = images
rbd_store_user = glance
rbd_store_ceph_conf = /etc/ceph/ceph.conf
rbd_store_chunk_size = 8
systemctl restart openstack-glance-api
openstack image create "cirros-test" --file cirros-0.3.4-x86_64-disk.img --disk-format raw --container-format bare --public
注意了这里必须专成raw格式的镜像,因为默认情况ceph仅支持此格式,可以修改但是很麻烦,这也是我不对接镜像的原因,后期要二次开发此功能
ceph df可以列出池的使用情况
nova对接(系统盘):
各个计算节点修改/etc/nova/nova.conf
[libvirt]
images_type = rbd(如果你没有对接镜像,这里写qcow2)
images_rbd_pool = vms
images_rbd_ceph_conf = /etc/ceph/ceph.conf
rbd_user = cinder
rbd_secret_uuid = 192ff8f8-2e80-4b5f-abcf-9792ccc5a91f
disk_cachemodes="network=writeback"
inject_password = false
inject_key = false
inject_partition = -2
live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"
hw_disk_discard = unmap
systemctl restart openstack-nova-compute.service
云盘对接:
yum install ceph-common -y
各个存储节点修改 /etc/cinder/cinder.conf
[DEFAULT]
enabled_backends = ceph
[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
glance_api_version = 2
rbd_user = cinder
rbd_secret_uuid = 192ff8f8-2e80-4b5f-abcf-9792ccc5a91f
mkdir -p /var/run/ceph/guests/ /var/log/qemu/
chown qemu:libvirt /var/run/ceph/guests /var/log/qemu/
systemctl restart openstack-cinder-volume.service
tail -f /var/log/cinder/volume.log如果有Update driver status failed: (config name ceph) is uninitialized说明未成功,请认真检查各个步骤,fsid及key!