Multi-backend这个功能是从grizzly 开始引入过来的, 它能使得Cinder同时能够配置多个后端,让cinder-scheduler根据用户需求灵活选择相应的存储.
当配置三个backend, 那么可以看到云环境中cinder-volume进程会有四个, 一个是主进程, 其余三个是针对每个backend出现的三个进程。
1. 修改cinder配置文件/etc/cinder/cinder.conf
在[default]部分修改enabled_backends配置
enabled_backends=lvmdriver-1,lvmdriver-2
[lvmdriver-1] volume_group=cinder-volumes volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver volume_backend_name=LVM_iSCSI [lvmdriver-2] volume_group=cinder-volumes-2 volume_driver=cinder.volume.drivers.lvm.LVMISCSIDriver volume_backend_name=LVM_iSCSI_b
dd if=/dev/zero of=/vol/cinder-volumes-2 bs=1 count=0 seek=10G # Mount the file. loopdev=`losetup -f` losetup $loopdev /vol/cinder-volumes-2 # Initialize as a physical volume. pvcreate $loopdev # Create the volume group. vgcreate cinder-volumes-2 $loopdev # Verify the volume has been created correctly. pvscan
for s in api scheduler volume; do service openstack-cinder-$s restart; done
针对不同的backend创建不同的volume type,
# 创建两个volume type。
cinder type-create test-type1
cinder type-key test-type1 set volume_backend_name=LVM_iSCSI
cinder type-create test-type2
#查看创建结果
cinder extra-specs-list
+--------------------------------------+------------+------------------------------------------+
| ID | Name | extra_specs |
+--------------------------------------+------------+------------------------------------------+
| 9bba220b-3764-4576-b596-4324b8b014cf | test-type1 | {u'volume_backend_name': u'LVM_iSCSI'} |
| f0946d39-92f2-42ef-808c-5f150fded32c | test-type2 | {u'volume_backend_name': u'LVM_iSCSI_b'} |
+--------------------------------------+------------+------------------------------------------+
#使用, 根据制定的volume type从而创建到特定的backend的块存储上
cinder create --display-name test-multi-backend --volume-type test-type2 1
本例中使用的都是lvm来模拟multi-backend, 所以结果可使用lvdisplay命令来查看,看存储卷是不是创建到了指定volume type所在的volume group。
5. 使用tempest测试Multi-backend
vi tempest.conf
# Name of the backend1 (must be declared in cinder.conf) # (string value) backend1_name=LVM_iSCSI # Name of the backend2 (must be declared in cinder.conf) # (string value) backend2_name=LVM_iSCSI_b # (boolean value) multi_backend=true开始进行tempest测试:
cd tempest/api/volume/admin/ nosetests -sv test_multi_backend result: ---------------------------------------------------------------------- Ran 2 tests in 44.527s OK