作者:张华 发表于:2021-12-17
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
( http://blog.csdn.net/quqi99 )
本文是将image存储到cinder的LVM存储中,主要为了测试:https://review.opendev.org/c/openstack/charm-glance/+/814882
注:其实这个标题叫’Glance with Cinder iSCSI/FC-backed storage’比’Glance with Cinder LVM-backed storage’要更合适,因为:
- cinder支持iscsi, ceph, 虽然glance可以直接使用ceph,但这里却没有测试glance->cinder->ceph这条路径,所以保险起见,应该排除cinder ceph
- lvm是本地存储,远程使用需结合iscsi, 使用’iSCSI/FC’也算是包括了lvm吧,至于nfs也可通过iscsi来使用的
Setup test env
使用juju来部署的话,“juju config cinder block-device=‘None’”将确保cinder charm默认创建LVM-default这个backend, 除了部署cinder-lvm, "juju add-relation cinder:cinder-volume-service glance:cinder-volume-service"这句也很重要
juju config cinder block-device='None'
juju deploy glance
juju add-relation glance keystone
juju add-relation glance mysql
juju add-relation glance nova-cloud-controller
juju add-relation cinder:image-service glance:image-service
juju add-relation cinder:cinder-volume-service glance:cinder-volume-service
juju add-relation cinder-lvm:storage-backend cinder:storage-backend
# First create a common openstack env with cinder and glance, but without ceph
juju deploy cinder-lvm
juju config cinder-lvm block-device='/tmp/vol1|4G'
juju config cinder-lvm overwrite=true
juju config cinder-lvm ephemeral-unmount='/mnt'
juju config cinder-lvm allocation-type='auto'
juju config cinder block-device='None'
juju add-relation cinder-lvm cinder
juju add-relation cinder:cinder-volume-service glance:cinder-volume-service
#https://review.opendev.org/c/openstack/charm-glance/+/814882
git clone https://github.com/openstack/charm-glance.git glance
cd glance
git fetch https://review.opendev.org/openstack/charm-glance refs/changes/82/814882/11 && git checkout FETCH_HEAD
juju upgrade-charm glance --path $PWD
#openstack volume type create cinder --property volume_backend_name=LVM-default
cinder type-create cinder && cinder type-key cinder set volume_backend_name=LVM-default
cinder service-list
cinder create --display_name test_volume --volume_type cinder 1
juju config glance cinder-volume-types='cinder'# Glance with Multiple Backend Stores
#http_proxy=http://squid.internal:3128 wget http://download.cirros-cloud.net/0.5.1/cirros-0.5.1-x86_64-disk.img
#openstack image create --disk-format=qcow2 --container-format=bare --public cirros --file ./cirros-0.5.1-x86_64-disk.img
glance --os-image-api-version 2 image-create --name cirros --disk-format qcow2 --container-format bare --file ./cirros-0.5.1-x86_64-disk.img --store cinder
Verify configuration
cinder.conf
[DEFAULT]
enabled_backends = LVM-default
[LVM-default]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volumes_dir = /var/lib/cinder/volumes
volume_name_template = volume-%s
volume_group = cinder-volumes-default
volume_backend_name = LVM-default
lvm_type = auto
volume_clear = zero
volume_clear_size = 0glance-api.conf
[DEFAULT]
enabled_backends = local:file, cinder:cinder
[glance_store]
default_backend = cinder
[cinder]
cinder_volume_type = cinderjuju run -u mysql/leader leader-get mysql.passwd
sudo mysql -uroot -p
select * from images;
mysql> select image_id,value from image_locations;
+--------------------------------------+-----------------------------------------------+
| image_id | value |
+--------------------------------------+-----------------------------------------------+
| 7b6d1e53-6bc0-4080-b7d5-5563c306706f | cinder://d6c1d34d-9ae6-40d8-a7ec-448c6c96e1fb |
+--------------------------------------+-----------------------------------------------+