Image service (glance)是openstack中管理vm image的service。本文包含以下内容:
- overview
- install
overview
glance包含以下部分
glance-api
是glance的API接口。用户通过该接口发现,调用以及存取vm image。
glance-registry
主要用于处理存储vm image的metadata,如size,type。该service是openstack的内部服务。
database
存储 image metadata 。通常用mysql
Storage repository for image files
Storage repository 主要用来存储vm image。glance支持多种存储如 normal file systems, Object Storage, RADOS block devices, HTTP, and Amazon S3。
Metadata definition service
vendors, admins, services, and users可以自定义metadata。
install
install部分包括
>* prerequisite
>* keystone 设置
>* install and configure
>* verify
prerequisite
首先要为glance创建数据库
mysql -u root -p
CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost'
IDENTIFIED BY 'GLANCE_DBPASS';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%'
IDENTIFIED BY 'GLANCE_DBPASS';
keystone 设置
在keystone中创建glance用户
. admin-openrc
openstack user create --domain default --password-prompt glance
为glance用户在service project中添加admin role
openstack role add --project service --user glance admin
创建glance service
openstack service create --name glance
--description "OpenStack Image" image
为glance service 创建end points
openstack endpoint create --region RegionOne image public http://controller01:9292
openstack endpoint create --region RegionOne image internal http://controller01:9292
openstack endpoint create --region RegionOne image admin http://controller01:9292
install and configure
安装package
yum install openstack-glance
编辑文件 /etc/glance/glance-api.conf。配置glance-api 注意替换密码为你所使用的密码
[database]
...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller01/glance
[keystone_authtoken]
...
auth_uri = http://controller01:5000
auth_url = http://controller01:35357
memcached_servers = controller01:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
...
flavor = keystone
[glance_store]
...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
编辑文件/etc/glance/glance-registry.conf 配置glanceregistry
[database]
...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller01/glance
[keystone_authtoken]
...
auth_uri = http://controller01:5000
auth_url = http://controller01:35357
memcached_servers = controller01:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS
[paste_deploy]
...
flavor = keystone
创建glance 数据库
su -s /bin/sh -c "glance-manage db_sync" glance
对glance api,register服务启动并设置开机启动
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
verify
要verify最好的办法是用glance管理vm image试一下。首先下载一个image。
# load keystone 环境变量
. admin-openrc
# 下载一个小的image
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
upload image
openstack image create "cirros"
--file cirros-0.3.4-x86_64-disk.img
--disk-format qcow2 --container-format bare
--public
查看image
openstack image list
如果能够看见刚刚的vm镜像则说明没问题。