控制节点:
一、安装及配置
1.创建数据库及管理用户
登录数据库
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';
2.生效admin变量
source admin-openrc.sh
3.创建glance用户
openstack user create --domain default --password-prompt glance
添加admin角色到glance用户及service项目
openstack role add --project service --user glance admin
创建glance服务实体
openstack service create --name glance --description "OpenStack Image service" image
4.创建服务API端点
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292
5.安装glance相关包
yum install openstack-glance python-glance python-glanceclient -y
6.配置/etc/glance/glance-api.conf
[database]
...
connection = mysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken] #先清除或注释此会话其他项
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = 111111
[paste_deploy]
...
flavor = keystone
[glance_store]
...
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[DEFAULT]
...
notification_driver = noop
verbose = True
7.配置/etc/glance/glance-registry.conf
[database]
...
connection = mysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken] #先清除或注释此会话其他项
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = glance
password = 111111
[paste_deploy]
...
flavor = keystone
[DEFAULT]
...
notification_driver = noop
verbose = True
8.同步glance数据库
su -s /bin/sh -c "glance-manage db_sync" glance
9.开启glance相关服务,并设置开机自启
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service
二、验证
1.客户端环境变量脚本增加Image服务变量
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
2.生效客户端admin环境变量脚本
source admin-openrc.sh
3.下载镜像文件到本地
wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
4.上传镜像到image服务
glance image-create --name "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility public --progress
5.查看上载的镜像
glance image-list