Openstack ocata+Ceph12+centos7

本文基於Openstack ocata+Ceph12+centos7

1、創建一個POOL
ceph osd pool create volumes 64
ceph osd pool create images 64
ceph osd pool create vms 64

2、配置OPENSTACK CEPH CLIENTS
環境的準備,需要事先在ceph管理節點到openstack各服務節點間建立起免密鑰登錄的關係,且需有使用sudo的權限。

安裝ceph客戶端軟件包:
在glance-api,nova-compute, and on the cinder-volume節點:
sudo yum install ceph python-rbd

在OpenStack中運行glance-api, cinder-volume, nova-compute 服務的主機節點,都屬於Ceph的客戶端。需要配置ceph.conf.
使用以下命令把ceph.conf複製到每個ceph客戶端節點:
ssh {your-openstack-server} sudo tee /etc/ceph/ceph.conf </etc/ceph/ceph.conf

3、設置Ceph Client Authentication
如果啓用了cephx認證,那麼就需要爲Nova/Cinder創建一個新用戶:
$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)分發至對應的主機節點,並調整屬主權限:
ceph auth get-or-create client.glance | ssh {your-glance-api-server} sudo tee /etc/ceph/ceph.client.glance.keyring
ssh {your-glance-api-server} sudo chown glance:glance /etc/ceph/ceph.client.glance.keyring
ceph auth get-or-create client.cinder | ssh {your-volume-server} sudo tee /etc/ceph/ceph.client.cinder.keyring
ssh {your-cinder-volume-server} sudo chown cinder:cinder /etc/ceph/ceph.client.cinder.keyring

也可生成keyring,使用scp拷貝到其他節點
ceph auth get-or-create client.glance > /etc/ceph/ceph.client.glance.keyring
ceph auth get-or-create client.cinder > /etc/ceph/ceph.client.cinder.keyring

運行nova-compute的節點需要使用cinder密鑰:
ceph auth get-or-create client.cinder | ssh {your-nova-compute-server} sudo tee /etc/ceph/ceph.client.cinder.keyring

libvirt同樣也要使用client.cinder密鑰:
Libvirt進程在從Cinder掛載一個塊設備時,需要使用該密鑰訪問Ceph存儲集羣。
先要在運行nova-compute的節點上創建一個密鑰的臨時拷貝:
ceph auth get-key client.cinder | ssh {your-compute-node} tee client.cinder.key

然後登錄到compute節點上,將密鑰增加到libvirt配置文件中並刪除上面的臨時文件:

cat > secret.xml <<EOF
<secret ephemeral='no' private='no'>
<uuid>22003ebb-0f32-400e-9584-fa90b6efd874</uuid>
<usage type='ceph'>
<name>client.cinder secret</name>
</usage>
</secret>
EOF
]# virsh secret-define --file secret.xml
#Secret 22003ebb-0f32-400e-9584-fa90b6efd874 created
]# virsh secret-set-value --secret 22003ebb-0f32-400e-9584-fa90b6efd874 --base64 $(cat client.cinder.key) && rm client.cinder.key secret.xml
Secret value set

在有多個計算節點時,在compute節點上執行相同的操作。

4、設置Glance集成Ceph

vi /etc/glance/glance-api.conf
[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

啓用copy-on-write功能:
在[DEFAULT]中增加以下參數,
show_image_direct_url = True

怎樣關閉Glance的鏡像緩存:
修改以下參數如以下所示,
[paste_deploy]flavor = keystone

5、設置Cinder集成Ceph
vi /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

在啓用了cephx認證時,還需要配置認證信息:
[ceph]
...
rbd_user = cinder
rbd_secret_uuid = 22003ebb-0f32-400e-9584-fa90b6efd874

注:如果你需要配置多個cinder back ends,一定要在 [DEFAULT] 部分設置glance_api_version = 2 。

6、設置NOVA集成Ceph
爲了直接基於Ceph存儲啓動虛機,還需要爲Nova配置一個臨時的存儲後端。同時,建議使用RBD緩存,啓用admin socket。
admin socket可以通過以下方法訪問:
ceph daemon /var/run/ceph/ceph-client.cinder.19195.32310016.asok help

在你的每個compute節點上,編輯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

調整權限:
mkdir -p /var/run/ceph/guests/ /var/log/qemu/
chown qemu:libvirt /var/run/ceph/guests /var/log/qemu/

注:以上的qemu用戶和libvirt組是基於RedHat相關係統的。

以配置好後,如果虛機已經在運行,則可以重啓使上面的配置生效。

在每個compute節點上編輯/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 = 22003ebb-0f32-400e-9584-fa90b6efd874
disk_cachemodes="network=writeback"

建議關閉nova的密鑰注入功能,而是使用基於metadata服務、cloud-init實現類似功能:
在每個計算節點上,編輯/etc/nova/nova.conf:
inject_password = false
inject_key = false
inject_partition = -2

啓動熱遷移支持:
在[libvirt]部分增加:
live_migration_flag="VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST,VIR_MIGRATE_TUNNELLED"

7、重啓OpenStack服務

systemctl restart openstack-glance-api
systemctl restart openstack-nova-compute
systemctl restart openstack-cinder-volume

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