1. 檢查cinder當前backend配置
使用cinder service-list,查看cinder-volume服務的Host字段格式。
舊版格式:
新版格式:
舊版中Host字段是cinder-volume服務所在節點的HOSTNAME,新版中Host字段是HOSTNAME@BACKEND。
如果是舊版,需要先修改為新版,見步驟2。
如果是新版,不需要修改,直接執行步驟3。
2. 修改舊版backend配置為新版
編輯/etc/cinder/cinder.conf文件,刪除其中原有的ceph backend相關配置:
[DEFAULT] rbd_store_chunk_size = 4 rbd_max_clone_depth = 5 rbd_flatten_volume_from_snapshot = true rbd_ceph_conf = /etc/ceph/ceph.conf rbd_pool = volumes rados_connect_timeout = -1 volume_driver = cinder.volume.drivers.rbd.RBDDriver
添加如下配置:
[DEFAULT] enabled_backends = ceph [ceph] rbd_pool = volumes rbd_ceph_conf = /etc/ceph/ceph.conf rbd_flatten_volume_from_snapshot = true rbd_max_clone_depth = 5 rbd_store_chunk_size = 4 rados_connect_timeout = -1 glance_api_version = 2 volume_backend_name=ceph volume_driver = cinder.volume.drivers.rbd.RBDDriver
重啟cinder-volume服務:
# service cinder-volume restart # 對於Ubuntu 14.04 # systemctl restart openstack-cinder-volume # 對於CentOS 7
執行cinder service-list,查看cinder-volume的Host字段是否變為新版格式。
然后更新已經創建的volume的host屬性:
# cinder-manage volume update_host --currenthost HOSTNAME --newhost HOSTNAME@BACKEND
例如:
# cinder-manage volume update_host --currenthost node-1.domain.tld --newhost node-1.domain.tld @ceph
查看volume 的os-vol-host-attr:host屬性已經變為HOSTNAME@BACKEND#RBD的格式:
到此,舊版配置格式已經改成新版配置格式,進行步驟3添加另一個ceph后端。
3. 添加一個ceph后端
將新的ceph集群的配置文件復制到所有openstack節點(包括控制節點和計算節點)。
注意:不同ceph集群依靠配置文件的名字區分,如:已有ceph集群的配置文件為/etc/ceph/ceph.conf,如果新集群全用SAS盤,配置文件可以命名為:/etc/ceph/ceph-sas.conf。
然后編輯/etc/cinder/cinder.conf,添加新的ceph backend,編輯完后的相關配置如下:
[DEFAULT] enabled_backends = ceph,ceph-sas [ceph] rbd_pool = volumes rbd_ceph_conf = /etc/ceph/ceph.conf rbd_flatten_volume_from_snapshot = true rbd_max_clone_depth = 5 rbd_store_chunk_size = 4 rados_connect_timeout = -1 glance_api_version = 2 volume_backend_name=ceph volume_driver = cinder.volume.drivers.rbd.RBDDriver [ceph-sas] rbd_pool = volumes rbd_ceph_conf = /etc/ceph/ceph-sas.conf rbd_flatten_volume_from_snapshot = true rbd_max_clone_depth = 5 rbd_store_chunk_size = 4 rados_connect_timeout = -1 glance_api_version = 2 volume_backend_name=ceph-sas volume_driver = cinder.volume.drivers.rbd.RBDDriver
重啟cinder-volume服務:
# service cinder-volume restart # 對於Ubuntu 14.04 # systemctl restart openstack-cinder-volume # 對於CentOS 7
執行cinder service-list命令,可以看到每個后端對應一個cinder-volume服務:
4. 配置volume-type
對於每個ceph后端,創建一個volume type,並將volume type關聯配置文件中的volume_backend_name:
# cinder type-create ceph # cinder type-key ceph set volume_backend_name=ceph # cinder type-create ceph-sas # cinder type-key ceph-sas set volume_backend_name=ceph-sas
然后執行cinder type-list可以看到配置的volume type:
5. 創建卷
此后創建卷時,可以指定volume type,將卷創建到指定的ceph后端:
# cinder create 10 --name vol-01 --volume-type ceph-sas
前端也可選則volume type:
注:如果不指定volume type,cinder-scheduler會忽略volume type,按默認的調度器從所有cinder-volume調度。