镜像文件默认所在目录为/var/lib/glance/images/
在数据库中创建glance库和用户并授权
[root@con01 ~]# mysql -uroot -ptest.2018
Welcome to the MariaDBmonitor. Commands end with ; or \g.
Your MariaDB connection idis 27
Server version:10.1.20-MariaDB MariaDB Server
Copyright (c) 2000, 2016,Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' forhelp. Type '\c' to clear the current input statement.
MariaDB [(none)]>CREATE DATABASE glance;
Query OK, 1 row affected(0.00 sec)
MariaDB [(none)]> GRANTALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
-> IDENTIFIED BY 'test.2018';
Query OK, 0 rows affected(0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO'glance'@'%' \
-> IDENTIFIED BY 'test.2018';
Query OK, 0 rows affected(0.00 sec)
在keystone中创建glance用户 手动输入密码
openstack user create--domain default --password-prompt glance
将glance用户关联在admin角色和service项目中
openstack role add--project service --user glance admin
创建glance服务
[root@con01 ~]# openstackservice create --name glance \
> --description"OpenStack Image" image
创建glance服务的api接口(公共接口 内部接口 管理员接口)
[root@con01 ~]# openstackendpoint create --region RegionOne \
> imagepublic http://controller:9292
[root@con01 ~]# openstackendpoint create --region RegionOne \
> imageinternal http://controller:9292
[root@con01 ~]# openstackendpoint create --region RegionOne \
> image adminhttp://controller:9292
查看所有的api
openstackendpoint list
安装
yum installopenstack-glance -y
修改配置文件
vim/etc/glance/glance-api.conf
[database]
# ...
connection = mysql+pymysql://glance:test.2018@controller/glance
[keystone_authtoken]
# ...
auth_uri=http://controller:5000
auth_url=http://controller:5000
memcached_servers=controller:11211
auth_type=password
project_domain_name=Default
user_domain_name=Default
project_name=service
username=glance
password=test.2018
[paste_deploy]
# ...
flavor=keystone
[glance_store]
# ...
stores=file,http
default_store=file
filesystem_store_datadir=/var/lib/glance/images/
Vim /etc/glance/glance-registry.conf
[database]
# ...
connection = mysql+pymysql://glance:test.2018@controller/glance
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers =controller:11211
auth_type = password
project_domain_name =Default
user_domain_name = Default
project_name = service
username = glance
password = test.2018
[paste_deploy]
# ...
flavor=keystone
初始化glance的数据库
su -s/bin/sh -c "glance-manage db_sync" glance
……..
启动服务
# systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
# systemctlstart openstack-glance-api.service \
openstack-glance-registry.service