ceph與openstack對接(cinder、glance、nova)


對接分為三種,也就是存儲為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
<secret ephemeral='no' private='no'>
<uuid>192ff8f8-2e80-4b5f-abcf-9792ccc5a91f</uuid>
<usage type='ceph'>
<name>client.cinder secret</name>
</usage>
</secret>

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!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM