官网地址:https://docs.openstack.org/glance/stein/install/install-rdo.html
#:创建glance库,并授权
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'glance123';
#:加载环境变量
[root@localhost ~]# source scripts/admin-stein.sh
#:创建glance用户
[root@localhost ~]# openstack user create --domain default --password-prompt glance
#:给admin项目添加一个glance用户,并加入到service角色
[root@localhost ~]# openstack role add --project service --user glance admin
#:创建一个类型为image的service
[root@localhost ~]# openstack service create --name glance --description "OpenStack Image" image
#: 注册API
[root@localhost ~]# openstack endpoint create --region RegionOne image public http://www.magedu.net:9292
[root@localhost ~]# openstack endpoint create --region RegionOne image internal http://www.magedu.net:9292
[root@localhost ~]# openstack endpoint create --region RegionOne image admin http://www.magedu.net:9292
#:安装glance包
[root@localhost ~]# yum install openstack-glance -y
#:配置
[root@localhost ~]# vim /etc/glance/glance-api.conf
[database]
#
connection = mysql+pymysql://glance:glance123@www.magedu.net/glance
[keystone_authtoken]
#
www_authenticate_uri = http://www.magedu.net:5000
auth_url = http://www.magedu.net:5000
memcached_servers = www.magedu.net:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance
[paste_deploy]
#
flavor = keystone
[root@localhost ~]# vim /etc/glance/glance-registry.conf
[database]
#
connection = mysql+pymysql://glance:glance123@www.magedu.net/glance
[keystone_authtoken]
#
www_authenticate_uri = http://www.magedu.net:5000
auth_url = http://www.magedu.net:5000
memcached_servers = www.magedu.net:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = glance
[paste_deploy]
#
flavor = keystone
#:修改haproxy配置文件
[root@localhost ~]# vim /etc/haproxy/haproxy.cfg
listen mysqlserver
bind 192.168.7.101:11211
mode tcp
server mysql 192.168.7.105:11211 check inter 2s fall 3 rise 5
#:重启服务
[root@localhost ~]# systemctl restart haproxy
#:初始化数据库
[root@localhost ~]# su -s /bin/sh -c "glance-manage db_sync" glance
#:启动服务
[root@localhost ~]# systemctl enable openstack-glance-api.service openstack-glance-registry.service
[root@localhost ~]# systemctl start openstack-glance-api.service openstack-glance-registry.service
官网地址:https://docs.openstack.org/glance/stein/install/verify.html
#:测试
#: 加载环境变量
[root@localhost ~]# source scripts/admin-stein.sh
#:下载镜像
[root@localhost ~]# wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img
#:创建镜像
[root@localhost ~]# openstack image create "cirros-0.4.0" --file /root/cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public
#:列出镜像
[root@localhost ~]# openstack image list