一、安装Glance基本组件
-----------------controller节点---------------------------------
(1)查看opt下的centos目录下的安装包是否挂载成功,没成功重新挂载
#mount -o loop /opt/CentOS-7-x86_64-DVD-1511.iso /opt/centos/
#mount -o loop /opt/XianDian-IaaS-v2.2.iso /opt/iaas/
(2)安装glance
#yum install -y openstack-glance
二、创建Glance数据库并授权
(1)登录数据库
#mysql -u root -p
(2)创建glance数据库
CREATE DATABASE glance;
(3)创建glance用户,并赋予其glance数据库的操作权限(本地远程都可访问)
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '000000';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY '000000';
(4)退出mysql命令
exit;
三、修改Glance配置文件中数据连接的相关配置
(1)在glance-api.conf的[database]段落中添加数据库连接配置
#vi /etc/glance/glance-api.conf
connection = mysql+pymysql://glance:000000@controller/glance
(2)在glance-registry.conf的[database]段落中添加数据库连接配置
#vi /etc/glance/glance-registry.conf
connection = mysql+pymysql://glance:000000@controller/glance
四、同步数据库,为Glance服务创建数据库表
#su -s /bin/sh -c "glance-manage db_sync" glance
----忽略关于EngineFacade is deprecated;的信息
五、创建用户
(1)导入环境变量
#source admin-openrc.sh
(2)创建用户glance密码000000
#openstack user create --domain default --password 000000 glance
(3)关联角色、租户和用户
#openstack role add --project service --user glance admin
(4)创建镜像服务
#openstack service create --name glance --description "OpenStack Image" image
(5)注册Glance端点信息(三种权限)
#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
六、修改Glance配置文件
------------------------------第一种方法-------------------------------------
注:修改以下配置文件时如果文件内容前面有#注释的无须修改直接复制文章中已经修改好的内容粘贴在该段落下即可,温馨提示要特别特别认真仔细,多数报错问题都是配置文件问题。
(一)修改 /etc/glance/glance-api.conf文件
#vi /etc/glance/glance-api.conf
找到[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 = 000000
找到[paste_deploy],在下面添加:
flavor = keystone
config_file = /usr/share/glance/glance-api-dist-paste.ini
找到[glance_store],在下面添加:
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
(2)修改/etc/glance/glance-registry.conf文件
#vi /etc/glance/glance-registry.conf
找到[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 = 000000
找到[paste_deploy],在下面添加:
flavor = keystone
config_file = /usr/share/glance/glance-registry-dist-paste.ini
------------------------------第二种方法(命令修改配置)-------------------------------------
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller:5000
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:35357
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name default
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name default
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password 000000
#openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
#openstack-config --set /etc/glance/glance-api.conf paste_deploy config_file /usr/share/glance/glance-api-dist-paste.ini
#openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
#openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
#openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller:5000
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://controller:35357
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers controller:11211
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name default
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name default
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
#openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password 000000
#openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
#openstack-config --set /etc/glance/glance-registry.conf paste_deploy config_file /usr/share/glance/glance-registry-dist-paste.ini
七、启动服务
#systemctl enable openstack-glance-api.service openstack-glance-registry.service
#systemctl restart openstack-glance-api.service openstack-glance-registry.service
八、上传镜像
#source admin-openrc.sh
glance image-create --name "CentOS7.0" --disk-format qcow2 --container-format bare --progress < /opt/iaas/images/CentOS_7.2_x86_64_XD.qcow2
openstack image create "cirros" --file cirros-0.3.4-x86_64-disk.img --disk-format qcow2 --container-format bare --public
glance image-create --name "centos7.1" --file CentOS-7-x86_64-GenericCloud-1503.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
--------------注意tab补全命令去指定镜像名
----------------验证镜像是否成功上传
#openstack image list
有任何疑问或建议欢迎留言讨论,下一节进行Nova计算服务的安装欢迎访问,点击传送。