手动部署OpenStack(四)之“glance安装与配置”

详细配置步骤

笔记链接:http://note.youdao.com/noteshare?id=709b1c1fc4e6cc434ec95c001e0f3abc

四、glance安装与配置

Image Service镜像服务主要用于创建instance时提供镜像的发现,注册,检索服务, nova启动instance时,会向glance请求对应的image,然后下载对应的image到本地。glance的镜像支持多种存储方式,如常见的本地文件系统,分布式存储ceph,glusterfs上,或者存储在swift上,默认存放在controller的本地文件系统上,存储的路径是: /var/lib/glance/images,为了确保有足够的空间,建议修改路径,或者划分个单独的空间给glance使用。
glance由两个服务组成: glance api和glance-registry,其中,glance-api负责接收外部发送的请求, glance-registry接收用户发送的请求后,完成向后端镜像的存储,检索镜像和元数据等功能。此外,镜像的所有信息,包括镜像的元数据信息,都会以持久化的方式保存在数据库中。
1、glance的安装
★该项的所有操作步骤需要使用root用户进行
★此项在controller0主机上进行操作
①创建数据库
#mysql -uroot -popenstack
mysql>create database glance;

mysql> grant all privileges on glance.* to ‘glance’@‘localhost’ identified by ‘GLANCE_DBPASS’;
mysql> grant all privileges on glance.* to ‘glance’@’%’ identified by ‘GLANCE_DBPASS’;

#mysql -uglance -pGLANCE_DBPASS -e ‘show databases;’
(测试查看新建的数据库)
②创建keystone认证的用户
a. 创建用户
#source /root/admin-openrc.sh
#keystone user-create --name glance --pass GLANCE_PASS --email glance@example.com --enabled true
#keystone user-list

b. 授予glance权限
#keystone user-role-add --user glance --tenant service --role admin
keystone user-role-list --user glance --tenant service

c. 创建glance服务
#keystone service-create --type image --name glance --description “Openstack Glance Image Service”
#keystone service-list

d. 将glance服务路径注册到keystone
#keystone endpoint-create --service-id $(keystone service-list|awk ‘/ image / {print $2}’) --publicurl http://controller0:9292 --internalurl http://controller0:9292 --adminurl http://controller0:9292 --region regionOne(创建image服务的api 端口)
#keystone endpoint-list

③安装glance服务
#yum update(首先系统更新)
#yum -y install openstack-glance python-glanceclient

2、配置glance-api服务
★该项的所有操作步骤需要使用root用户进行
★此项在controller0主机上进行操作
a. 配置数据库连接
[root@controller0 ~]# openstack-config --set /etc/glance/glance-api.conf database connection mysql://glance:GLANCE_DBPASS@controller0/glance
#cat /etc/glance/glance-api.conf|more

b. 配置keystone
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller0:5000/v2.0
#openstack-config --set /etc/glance/glance-api.conf identity_uri http://controller0:35357
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance
#openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password GLANCE_PASS
(以上keystone验证)
#openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
(keystone服务入口)
#cat /etc/glance/glance-api.conf|more

c. 配置image存储位置,使用本地的文件系统存储
[root@controller0 ~]# openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
[root@controller0 ~]# openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
(上述为镜像存储配置)
[root@controller0 ~]# openstack-config --set /etc/glance/glance-api.conf DEFAULT verbose True
(启动详细日志记录)

④配置glance-registy服务
★该项的所有操作步骤需要使用root用户进行
★此项在controller0主机上进行操作
a. 配置数据库连接
#openstack-config --set /etc/glance/glance-registry.conf database connection mysql://glance:GLANCE_DBPASS@controller0/glance

b. 配置keystone认证
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller0:5000/v2.0
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf keystone_authtoken identity_uri http://controller0:35357
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf keystone_authtoken admin_password GLANCE_PASS
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf paste_deploy flavor keystone
[root@controller0~]#openstack-config–set /etc/glance/glance-registry.conf DEFAULT verbose True

c. 建立glance数据库中所需的表
#mysql -uroot -popenstack
mysql> alter table migrate_version convert to character set ‘utf8’;
[root@controller0 ~]# mysql -uglance -pGLANCE_DBPASS -e “show tables from glance;”

⑤启动并校验glance服务
★该项的所有操作步骤需要使用root用户进行
★此项在controller0主机上进行操作
a. 启动glance服务
[root@controller0 ~]# service openstack-glance-api start
[root@controller0 ~]# chkconfig openstack-glance-api on
[root@controller0 ~]# service openstack-glance-registry start
[root@controller0 ~]# chkconfig openstack-glance-registry on
查看日志校验服务是否有异常
[root@controller0 ~]# tail -f /var/log/glance/api.log
[root@controller0 ~]# tail -f /var/log/glance/registry.log

b. 校验glance服务
将镜像文件cirros-0.3.0-x86_64-disk.img上传到/root根目录下
[root@controller0 ~]# file cirros-0.3.0-x86_64-disk.img
cirros-0.3.0-x86_64-disk.img: Qemu Image, Format: Qcow , Version: 2
[root@controller0 ~]# source admin-openrc.sh
[root@controller0 ~]# glance image-create --name cirrors --disk-format qcow2 --container-format bare --file /root/cirros-0.3.0-x86_64-disk.img --is-public True --is-protected False --human-readable --progress

校验image是否上传成功
#glance image-list
#glance image-show 264c6a2a-1119-425f-b2d7-4aeecbb4773f

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值