配置镜像 (glance) 服务¶
在单节点全合一部署中,镜像 (glance) 服务使用目标主机上的本地文件系统来存储镜像。在部署生产云时,我们建议使用 swift 后端或某种形式的共享存储来支持 glance。
配置默认存储和附加存储¶
OpenStack-Ansible 提供了两种配置来控制 glance 存储文件的位置:默认存储和附加存储。 glance 默认在基于文件的存储中存储镜像。 另外两个存储,http 和 cinder (块存储),也默认启用。
您可以选择替代的默认存储和替代的附加存储。 例如,使用 Ceph 的部署者可以配置以下 Ansible 变量
glance_default_store = rbd glance_additional_stores: - swift - http - cinder
上述配置将 glance 配置为默认使用 rbd (Ceph),但 glance_additional_stores 列表启用了 glance 配置文件中的 swift、http 和 cinder 存储。
以下示例将 glance 设置为使用 images 池。 此示例使用 cephx 身份验证,并且需要为 images 池的 glance 帐户。
在 user_variables.yml 中
glance_default_store: rbd ceph_mons: - 172.29.244.151 - 172.29.244.152 - 172.29.244.153
如果您不使用默认值,可以使用以下变量
glance_ceph_client: <glance-username> glance_rbd_store_pool: <glance-pool-name> glance_rbd_store_chunk_size: <chunk-size>
将镜像存储在 Cloud Files 中¶
以下过程描述了如何修改 /etc/openstack_deploy/user_variables.yml 文件以启用 Cloud Files 的使用。
将默认存储更改为使用对象存储 (swift),Cloud Files 的底层架构
glance_default_store: swift
设置适当的身份验证 URL 和版本
glance_swift_store_auth_version: 2 glance_swift_store_auth_address: https://127.0.0.1/v2.0
设置 swift 帐户凭据
# Replace this capitalized variables with actual data. glance_swift_store_user: GLANCE_SWIFT_TENANT:GLANCE_SWIFT_USER glance_swift_store_key: SWIFT_PASSWORD_OR_KEY
如果需要,将
glance_swift_store_endpoint_type从默认的internalURL设置更改为publicURL。glance_swift_store_endpoint_type: publicURL
定义存储名称
glance_swift_store_container: STORE_NAME
将
STORE_NAME替换为 swift 中用于存储镜像的容器名称。 如果容器不存在,则会自动创建。定义存储区域
glance_swift_store_region: STORE_REGION
如果需要,替换
STORE_REGION。(可选) 设置 paste 部署 flavor
glance_flavor: GLANCE_FLAVOR
默认情况下,glance 使用缓存并使用 Identity (keystone) 服务进行身份验证。 默认镜像缓存的最大大小为 10GB。 默认 glance 容器大小为 12GB。 在某些配置中,glance 尝试缓存超出可用磁盘空间限制的镜像。 如果需要,您可以禁用缓存。 例如,要使用不带缓存的 Identity,请将
GLANCE_FLAVOR替换为keystoneglance_flavor: keystone
或者,要禁用身份验证和缓存,请将
GLANCE_FLAVOR设置为空值glance_flavor:
此选项默认设置为在
playbooks/roles/os_glance/defaults/main.yml文件中使用身份验证和缓存管理。 要覆盖默认行为,请在/etc/openstack_deploy/user_variables.yml中将glance_flavor设置为不同的值。GLANCE_FLAVOR的可能值是(无)
cachingcachemanagementkeystonekeystone+cachingkeystone+cachemanagement(默认)trusted-authtrusted-auth+cachemanagement
特殊注意事项¶
如果 swift 密码或密钥包含美元符号 ($),则必须使用额外的美元符号 ($$) 进行转义。 例如,密码为 super$ecure 时,需要输入 super$$ecure。 这是由于 oslo.config 格式化字符串 的方式所致。