基于卷的镜像

OpenStack 块存储可以快速从引用存储镜像数据的卷(镜像-卷)创建卷。与文件和 Swift 等其他存储相比,如果块存储驱动程序支持高效的卷克隆,则从基于卷的镜像创建卷的性能更好。

如果镜像在 Image 服务中设置为公开,则卷数据可以在项目之间共享。

配置基于卷的镜像

基于卷的镜像功能需要来自 Image 服务的 cinder 存储的位置信息。要启用 Image 服务使用 cinder 存储,请将 cinder 添加到 glance-api.conf 文件的 stores 选项中

stores = file, http, swift, cinder

要暴露位置信息,请在 glance-api.conf 文件的 DEFAULT 部分中设置以下选项

show_multiple_locations = True

要启用块存储服务通过克隆镜像-卷来创建新卷,请在 cinder.conf 文件的 DEFAULT 部分中设置以下选项。例如

allowed_direct_url_schemes = cinder

要启用 openstack image create --volume <volume> 命令来创建引用 Image-Volume 的镜像,请在 cinder.conf 文件的每个后端部分中设置以下选项

image_upload_use_cinder_backend = True

默认情况下,openstack image create --volume <volume> 命令在当前项目中创建镜像-卷。要将镜像-卷存储到内部项目,请在 cinder.conf 文件的每个后端部分中设置以下选项

image_upload_use_internal_tenant = True

要使 Image 服务可以访问内部项目中的镜像-卷,请在 glance-api.conf 文件的 glance_store 部分中设置以下选项

  • cinder_store_auth_address

  • cinder_store_user_name

  • cinder_store_password

  • cinder_store_project_name

创建基于卷的镜像

要将现有卷注册为新的基于卷的镜像,请使用以下命令

$ openstack image create --disk-format raw --container-format bare IMAGE_NAME

$ glance location-add <image-uuid> --url cinder://<volume-uuid>

如果启用了 image_upload_use_cinder_backend 选项,则以下命令通过克隆指定的卷来创建新的镜像-卷,然后将其位置注册到新镜像。磁盘格式和容器格式必须为 raw 和 bare(默认)。否则,镜像将上传到 Image 服务的默认存储。

$ openstack image create --volume SOURCE_VOLUME IMAGE_NAME