安装及配置Glance
安装Glance软件包
yum -y install openstack-glance
cat /etc/passwd | grep glance
cat /etc/group | grep glance
创建Glance数据库并授权
mysql -uroot -p000000 -e "CREATE DATABASE glance";
mysql -uroot -p000000 -e "grant all privileges on glance.* to glance@'%' identified by '000000';"
mysql -uroot -p000000 -e "grant all privileges on glance.* to glance@localhost identified by '000000';"
修改Glance配置文件
备份
cp /etc/glance/glance-api.conf /etc/glance/glance-api.bak
去掉配置文件的所有注释和空行,生成新的配置文件
grep -Ev '^$|#' /etc/glance/glance-api.bak > /etc/glance/glance-api.conf
编辑配置文件就行编辑
vi /etc/glance/glance-api.conf
修改[database]部分
[database]
connection = mysql+pymysql://glance:000000@controller/glance
修改[keystong_authtoken],修改[paste_deploy]
[keystong_authtoken]
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
username = glance
password = 000000
project_name = project
user_domain_name = Default
project_domain_name = Default
[paste_deploy]
flavor = keystone
修改[glance_store]
[glance_store]
stores = file
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
初始化Glance数据库
同步数据库
su glance -s /bin/sh -c "glance-manage db_sync"
检查数据库
mysql -uroot -p000000
use glance;
show tables;
Glance组件初始化
创建Glance用户并分配角色
创建用户并授权
openstack user create --domain default --password 000000 glance
openstack role add --project project --user glance admin
创建Glance服务及服务端点
创建一个名字为Glance,类型为image的服务
openstack service create --name glance image
创建镜像服务端点
openstack endpoint create --region RegionOne glance public http://controller:9292
创建内部组件的服务端点
openstack endpoint create --region RegionOne glance internal http://controller:9292
创建admin用户访问的端点
openstack endpoint create --region RegionOne glance admin http://controller:9292
启动服务并设置开机自启
systemctl enable openstack-glance-api.service && systemctl start openstack-glance-api.service
验证Glance服务
查看端口占用情况
netstat -tnlup | grep 9292
查看服务运行状态
systemctl status openstack-glance-api.service
用Glance制作镜像
下载CirrOS文件
下载地址:https://llwp.linlink.xyz/cloudcompute/cirros-0.5.1-x86_64-disk.img
上传文件到/root目录下
制作镜像
openstack image create --file cirros-0.5.1-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
查看镜像
openstack image list
常见问题
问题一:HTTP 410 Gone: Error in store configuration. Adding images to store is disabled.
修改文件夹权限
cd /var/lib/glance
chown -R glance:glance images/
修改配置文件参数,注释掉default_store = file后重启服务
vi /etc/glance/glance-api.conf
[DEFAULT]
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:000000@controller/glance
[file]
[glance.store.http.store]
[glance.store.rbd.store]
[glance.store.sheepdog.store]
[glance.store.swift.store]
[glance.store.vmware_datastore.store]
[glance_store]
stores = file
#default_store = file
filesystem_store_datadir = /var/lib/glance/images
[image_format]
[keystone_authtoken]
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
username = glance
password = 000000
project_name = project
user_domain_name = Default
project_domain_name = Default
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
systemctl restart openstack-glance-api.service