ceph與openstack的對接集成

實驗環境
三節點的社區版Openstack環境
controller:172.16.1.100
computer:172.16.1.131
cinder:172.16.1.132
這裏三個節點使用的IP地址爲Openstack的管理地址
ceph1:172.16.1.128
ceph2:172.16.1.129
ceph3:172.16.1.130
我這裏使用的Openstack雲平臺跟ceph分佈式集羣均爲手動搭建的測試環境
使用rbd方式爲雲平臺提供存儲
(1)image:保存glance中的映像文件
(2)volume存儲:保存cinder的volume;保存創建虛擬機時選擇創建新卷;
(3)vms存儲:保存創建虛擬機時不選擇創新卷;

首先在雲平臺安裝rbd相關軟件(雲平臺三個節點上全部安裝)
yum install -y python-rbd
yum install -y ceph-common
#在ceph的控制節節點創建三個POOL
ceph osd pool create volumes 128
ceph osd pool create images 128
ceph osd pool create vms 128
#初始化POOL
rbd pool init volumes
rbd pool init images
rbd pool init vms

ceph與openstack的對接集成
將ceph的配置文件導入到雲平臺的三個節點

在ceph集羣的控制節點上執行
sudo ssh [email protected]  tee /etc/ceph/ceph.conf </etc/ceph/ceph.conf
sudo ssh [email protected]  tee /etc/ceph/ceph.conf </etc/ceph/ceph.conf
sudo ssh [email protected]  tee /etc/ceph/ceph.conf </etc/ceph/ceph.conf

創建ceph用戶和密鑰
ceph與openstack的對接集成

查詢用戶,寫入文件
#ceph auth get-or-create client.glance | ssh [email protected]  tee /etc/ceph/ceph.client.glance.keyring
#ssh [email protected] chown glance:glance /etc/ceph/ceph.client.glance.keyring
#ceph auth get-or-create client.cinder | ssh [email protected]  tee /etc/ceph/ceph.client.cinder.keyring
#ssh [email protected]  chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring
#ceph auth get-or-create client.cinder-backup    |     ssh [email protected]  tee  /etc/ceph/ceph.client.cinder-backup.keyring
#ssh [email protected]  chown cinder:cinder /etc/ceph/ceph.client.cinder-backup.keyring
#ceph auth get-key client.cinder | ssh [email protected] tee client.cinder.key

接下來與雲平臺進行對接
以下操作在openstack的控制節點上執行
ceph與glance對接

#更改glance默認存儲爲ceph
#修改/etc/glance/glance-api.conf文件,添加一下內容
[DEFAULT]
default_store = rbddefault_store = rbd
show_image_direct_url = True
show_image_direct_url = True
[glance_store]
#stores = file,http
#default_store = file
#filesystem_store_datadir = /var/lib/glance/images/
stores = rbd
default_store = 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-glance-registry

ceph與nova對接,在computer節點上操作
使用uuidgen獲取密鑰信息

ceph與openstack的對接集成

編輯一個secret.xml文檔 
<secret ephemeral='no' private='no'>
  <uuid>545ec73d-06b8-462e-8494-cbf1317dbc1a</uuid>
  <usage type='ceph'>
    <name>client.cinder secret</name>
  </usage>
</secret> 
virsh secret-define --file secret.xml
virsh secret-set-value --secret 545ec73d-06b8-462e-8494-cbf1317dbc1a --base64 AQAVkeJcqR2/GxAAtuPMq1MqF5wUBYTeDuDuiw==
注意--base64後面要跟的參數爲ceph.client.cinder.keyring文件中的密鑰信息,在cinder節點中將信息複製到此處

如果openstack有多個計算節點,所有的計算節點節點使用同一個UUID來進行標識
virsh secret-list 使用命令進行查看

ceph與openstack的對接集成
在computer節點的ceph配置文件裏添加一下內容

[client]
rbd cache = true
rbd cache writethrough until flush = true
admin socket = /var/run/ceph/guests/$cluster-$type.$id.$pid.$cctid.asok
log file = /var/log/qemu/qemu-guest-$pid.log
rbd concurrent management ops = 20
[client.cinder]
keyring = /etc/ceph/ceph.client.cinder.keyring

#重啓服務
systemctl restart libvirtd.service openstack-nova-compute.service

ceph與cinder對接

#修改/etc/cinder/cinder.conf配置文件,注意:將之前的lvm的配置都刪掉
[DEFAULT]
#enabled_backends = lvm
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 = ff2e1190-30f5-4849-9c1c-886b1e1ee181
 #重啓服務   
systemctl restart openstack-cinder-volume.service

ceph與openstack的對接集成
在執行命令時如果出現下面的命令則說明認證信息出現錯誤,需要把ceph.client.admin.keyring文件拷貝到控制節點下。

創建一個新的虛擬機映像
glance image-create --name cirros_image --disk-format=qcow2 --container-format=bare < cirros-0.3.1-x86_64-disk.img

ceph與openstack的對接集成

創建一個2G大小的cinder卷組
cinder create --display-name ceph-volume01 --display-description "cinder volume on CEPH storage" 2

創建完之後可以在ceph集羣的控制檯看到Pools選項下面出現volumes以及images池
ceph與openstack的對接集成
然後登錄雲平臺進行虛擬機創建
ceph與openstack的對接集成
ceph與openstack的對接集成

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章