本文共 1506 字,大约阅读时间需要 5 分钟。
镜像服务(Glance)是OpenStack生态系统中的重要组成部分,主要功能是允许用户发现、注册和获取虚拟机镜像。以下是配置Glance的详细步骤指南。
镜像服务通过REST API提供虚拟机镜像的元数据查询功能,并支持将镜像存储在本地文件系统或对象存储系统中(如OpenStack Swift对象存储)。默认镜像存储类型为文件存储(file
),镜像文件路径默认位于/var/lib/glance/images
。
安装Glance镜像服务前,确保已安装必要的依赖包:
yum install openstack-glance -y
编辑镜像服务配置文件/etc/glance/glance-api.conf
,确保数据库连接信息正确:
# 示例配置:[database]connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
配置Keystone认证服务访问参数:
[keystone_authtoken]auth_uri = http://controller:5000auth_url = http://controller:35357memcached_servers = controller:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = glancepassword = GLANCE_PASS
配置本地文件系统存储:
# 示例配置:storage = filedefault_store = filefile_store_datadir = /var/lib/glance/images/
Glance服务监听地址及端口:
# 默认配置:glance-api地址:9292glance-registry地址:9191
执行数据库同步并启动Glance服务:
# 同步数据库:su -s /bin/sh -c "glance-manage db_sync" glance# 启动服务:systemctl enable openstack-glance-api.service openstack-glance-registry.servicesystemctl start openstack-glance-api.service openstack-glance-registry.service
上传镜像并创建镜像资源:
# 下载镜像文件:wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img# 上传镜像并创建镜像资源:openstack image create "cirros" \--file cirros-0.3.4-x86_64-disk.img \--disk-format qcow2 --container-format bare \--public
/var/lib/glance/images
。转载地址:http://ciwwz.baihongyu.com/