使用Ceph作為OpenStack的后端存儲配置過程詳解
概述
libvirt配置了librbd的QEMU接口,通過它可以在OpenStack中使用Ceph塊存儲。Ceph塊存儲是集群對象,這意味著它比獨立的服務(wù)器有更好的性能。
在OpenStack中使用Ceph塊設(shè)備,必須首先安裝QEMU,libvirt和OpenStack,下圖描述了 OpenStack和Ceph技術(shù)層次結(jié)構(gòu):
http://my.oschina.net/JerryBaby/blog/376580 我翻譯的官方文檔,僅供參考 ^ ^。
系統(tǒng)規(guī)劃
OpenStack集群:
控制節(jié)點:openstack(controller)192.168.1.131
計算節(jié)點:compute 192.168.1.132
存儲節(jié)點:storage 192.168.1.133
Ceph集群:
monitor、mds、osd0 節(jié)點:openstack(controller)192.168.1.131
osd1:compute 192.168.1.132
osd2:storage 192.168.1.133
系統(tǒng)架構(gòu):
#p#
配置過程
Important:由于這里將兩套集群服務(wù)部署在了同一組節(jié)點上,所以配置過程中省略了一些關(guān)于Ceph集群的配置。
創(chuàng)建存儲池
- # ceph osd pool create volumes 128
- # ceph osd pool create images 128
- # ceph osd pool create vms 128
設(shè)置Ceph客戶端認證
在OpenStack節(jié)點執(zhí)行如下命令:
- # 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.cinder,client.glance添加密鑰文件來訪問節(jié)點并改變屬主:
- # 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的節(jié)點nova-compute進程需要密鑰文件。它們也存儲client.cinder用戶的密鑰在libvirt。libvirt進程在Cinder中綁定塊設(shè)備時需要用到它來訪問集群。
在nova-compute節(jié)點創(chuàng)建一個臨時的密鑰副本:
- # 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并添加如下內(nèi)容:
- [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] 部分:
- show_image_direct_url = True
配置Cinder
在openstack節(jié)點和storage節(jié)點編輯 /etc/cinder/cinder.conf配置文件并添加如下內(nèi)容:
- 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驗證,需要配置user和uuid:
- rbd_user = cinder
- rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337
配置Nova
為了掛載Cinder設(shè)備(普通設(shè)備或可引導卷),必須指明使用的用戶及UUID。libvirt將使用期在Ceph集群中進行連接和驗證:
- rbd_user = cinder
- rbd_secret_uuid = 457eb676-33da-42ec-9a8c-9293d545c337
編輯 /etc/nova/nova.conf并添加如下內(nèi)容:
- [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注入一些數(shù)據(jù),如密碼、ssh 密鑰,配置文件等到文件系統(tǒng)中。然而,這***依靠元數(shù)據(jù)服務(wù)和cloud-init來完成。
在每個計算節(jié)點,編輯 /etc/nova/nova.conf 在 [libvirt] 標簽添加:
- libvirt_inject_password = false
- libvirt_inject_key = false
- libvirt_inject_partition = -2
重啟服務(wù)
- # sudo glance-control api restart
- # sudo service nova-compute restart
- # sudo service cinder-volume restart
- # sudo service cinder-backup restar
#p#
從塊設(shè)備引導
Ceph后端存儲狀況:
Ceph不支持從qcow2格式的鏡像引導,所以創(chuàng)建一個raw格式的鏡像:
創(chuàng)建一個可引導卷:
從可引導卷創(chuàng)建一個實例:
查看Ceph存儲狀況: