五、安装Glance服务
1、安装软件包和修改配置文件
yum install openstack-glance python-glance python-glanceclient
2、修改配置文件
vim /etc/glance/glance-api.conf
[database]
connection = mysql+pymysql://glance:glance@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
####这段要直接复制进去,不要去一个个改
[paste_deploy]
flavor = keystone
[glance_store]
default_store = file
filesystem_store_datadir = /var/lib/glance/images/ #镜像存储位置
vim /etc/glance/glance-registry.conf
[database]
connection = mysql+pymysql://glance:glance@controller/glance
[keystone_authtoken]
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance
#这段要直接复制进去,不要去一个个改
[paste_deploy]
flavor = keystone
同步数据库
su -s /bin/sh -c "glance-manage db_sync" glance
3、创建glance用户并关联service项目
source admin-openrc.sh
创建glance用户
openstack user create --domain default --password=glance glance
将此用户加入到项目里面并给它赋予admin的权限
openstack role add --project service --user glance admin
glance服务创建
openstack service create --name glance --description "OpenStack Image service" image
注册glance的三种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
echo "export OS_IMAGE_API_VERSION=2" | tee -a admin-openrc.sh demo-openrc.sh
4、启动glance服务并设置开机启动
一定要在opesntack-glance-api.service服务启动之前部署好存储设备,因为该服务在启动时会加载存储驱动检索存储设备,如果事先不存在,就意味着该服务没有识别到任何可用的存储设备,即便是后来你又新增了存储,仍然是无效的,最终导致你上传镜像失败
一定要赋予opesntack-glance-api.service服务对存储设备的可写权限。
mkdir /var/lib/glance/images
chown -R glance.glance /var/lib/glance/images
systemctl enable openstack-glance-api
systemctl enable openstack-glance-registry
systemctl restart openstack-glance-api openstack-glance-registry
5、镜像管理
下载
wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
openstack image create "cirros" \
--file cirros-0.3.5-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public
openstack image list