OpenStack 镜像服务Glance [三]
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack 镜像服务Glance [三]相关的知识,希望对你有一定的参考价值。
OpenStack 镜像服务Glance [三]
OpenStack 镜像服务Glance [三]
openstack
时间:2016年11月28日
OpenStack镜像服务Glance介绍
创建虚拟机我们需要有glance
的支持,因为glance
是提供镜像服务 glance
有两个比较重要的服务 Glance-api
接受云系统镜像的构建、删除、读取请求 Glance-Registry
云系统的镜像注册服务
我们需要配置glance-api
的配置文件和glance-registry
配置文件
glance
不需要配置消息队列
,但是glance需要配置keystone(认证中心)
提示:默认情况下上传镜像存放在/var/lib/glance/images
下
安装glance
创建数据库和在keystone上穿件glance用户我们已经创建完成
安装软件包
[[email protected] ~]# yum install openstack-glance -y
修改数据库地址
[[email protected] ~]# vim /etc/glance/glance-api.conf[database]…connection = mysql+pymysql://glance:[email protected]/glance…[[email protected] ~]# vim /etc/glance/glance-registry.conf[database]…connection = mysql+pymysql://glance:[email protected]/glance…#打开注释,写mysql地址,注意是在database默认下
修改完之后我们需要同步数据库
[[email protected] ~]# su -s /bin/sh -c "glance-manage db_sync" glance#替我们去创建表结构,openstack有警告没有关系,只要不是error就可以
同步完数据库之后我们进行检查
[[email protected] ~]# mysql -h 192.168.56.11 -u glance -pglance -e "use glance;show tables;"+----------------------------------+| Tables_in_glance |+----------------------------------+| artifact_blob_locations || artifact_blobs || artifact_dependencies || artifact_properties || artifact_tags || artifacts || image_locations || image_members || image_properties || image_tags || images || metadef_namespace_resource_types || metadef_namespaces || metadef_objects || metadef_properties || metadef_resource_types || metadef_tags || migrate_version || task_info || tasks |+----------------------------------+
我们要确保数据库可以进行同步
设置keystone
在[keystone_authtoken]
进行设置
[[email protected] ~]# vim /etc/glance/glance-api.conf…[keystone_authtoken]auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password #验证类型为密码project_domain_name = default #默认域user_domain_name = default #用户默认域project_name = service #项目名称username = glance #用户password = glance #密码
提示:必须复制在[keystone_authtoken]
模块下,否则不生效
还需要设置[paste_deploy]
模块
[paste_deploy]flavor = keystone#去掉注释并修改为keystone
设置registry
,和api
的设置一样
[[email protected] ~]# vim /etc/glance/glance-registry.conf…[keystone_authtoken]auth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance …[paste_deploy]flavor = keystone
配置镜像路径
在glance-api
配置本地文件系统存储和镜像文件位置
[[email protected] ~]# vim /etc/glance/glance-api.conf…[glance_store]stores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/images#以上配置都是打开注释就可以
检查
glance-api配置文件配置小结:
[[email protected] ~]# grep ‘^[a-z]‘ /etc/glance/glance-api.conf connection = mysql+pymysql://glance:[email protected]/glancestores = file,httpdefault_store = filefilesystem_store_datadir = /var/lib/glance/imagesauth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password project_domain_name = default user_domain_name = defaultproject_name = service username = glancepassword = glanceflavor = keystone
registry配置如下
[[email protected] ~]# grep ‘^[a-z]‘ /etc/glance/glance-registry.conf connection = mysql+pymysql://glance:[email protected]/glanceauth_uri = http://192.168.56.11:5000auth_url = http://192.168.56.11:35357memcached_servers = 192.168.56.11:11211auth_type = password project_domain_name = defaultuser_domain_name = default project_name = service username = glance password = glance flavor = keystone提示:registry和api的配置跟我一样现在我们就可以启动了
设置开启启动并开启服务
[[email protected] ~]# systemctl enable openstack-glance-api.service [[email protected] ~]# systemctl enable openstack-glance-registry.service [[email protected] ~]# systemctl start openstack-glance-api.service [[email protected] ~]# systemctl start openstack-glance-registry.service
提示:9292
是glance-api
的端口,9191
是glance-registry
的端口
在keystone上设置服务注册
1.创建服务
[[email protected] ~]# source admin-openstack.sh [[email protected] ~]# openstack service create --name glance --description "OpenStack Image" image+-------------+----------------------------------+| Field | Value |+-------------+----------------------------------+| description | OpenStack Image || enabled | True || id | c9fd28645efe45faa2a9cf2f2cce623e || name | glance || type | image |+-------------+----------------------------------+
2.创建镜像服务的API端点
[[email protected] ~]# openstack endpoint create --region RegionOne \> image public http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | cabb8016fef74b438a341866ef10917f || interface | public || region | RegionOne || region_id | RegionOne || service_id | c9fd28645efe45faa2a9cf2f2cce623e || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+[[email protected] ~]# openstack endpoint create --region RegionOne image internal http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 0bafb4e5d90745d789a16c97fc3f5688 || interface | internal || region | RegionOne || region_id | RegionOne || service_id | c9fd28645efe45faa2a9cf2f2cce623e || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+[[email protected] ~]# openstack endpoint create --region RegionOne image admin http://192.168.56.11:9292+--------------+----------------------------------+| Field | Value |+--------------+----------------------------------+| enabled | True || id | 911d06d783094d62bf2cf97e4dd3fed6 || interface | admin || region | RegionOne || region_id | RegionOne || service_id | c9fd28645efe45faa2a9cf2f2cce623e || service_name | glance || service_type | image || url | http://192.168.56.11:9292 |+--------------+----------------------------------+
测试
我们可以使用openstack list
或者glance list
进行查看
[[email protected] ~]# openstack image list[[email protected] ~]# glance image-list+----+------+| ID | Name |+----+------++----+------+
提示:如果此处没有出现空,那么这时候就需要看日志了。
最后我们可以上传一个镜像进行测试
[[email protected] ~]# wget http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img
我们下载上面的镜像进行测试
[[email protected] ~]# openstack image create "cirros" \> --file cirros-0.3.4-x86_64-disk.img \> --disk-format qcow2 --container-format bare \> --public+------------------+------------------------------------------------------+| Field | Value |+------------------+------------------------------------------------------+| checksum | ee1eca47dc88f4879d8a229cc70a07c6 || container_format | bare || created_at | 2016-11-17T10:34:14Z || disk_format | qcow2 || file | /v2/images/fc67361d-ad30-40b2-9d96-941e50fc17f5/file || id | fc67361d-ad30-40b2-9d96-941e50fc17f5 || min_disk | 0 || min_ram | 0 || name | cirros || owner | 026a58f98402437fa95ef4a21fbd4d1a || protected | False || schema | /v2/schemas/image || size | 13287936 || status | active || tags | || updated_at | 2016-11-17T10:34:14Z || virtual_size | None || visibility | public |+------------------+------------------------------------------------------+
#提示:如果没有环境变量还需要source
一下
检查是否上传成功
[[email protected] ~]# openstack image list+--------------------------------------+--------+--------+| ID | Name | Status |+--------------------------------------+--------+--------+| fc67361d-ad30-40b2-9d96-941e50fc17f5 | cirros | active |+--------------------------------------+--------+--------+[[email protected] ~]# glance image-list+--------------------------------------+--------+| ID | Name |+--------------------------------------+--------+| fc67361d-ad30-40b2-9d96-941e50fc17f5 | cirros |+--------------------------------------+--------+[[email protected] ~]# ls /var/lib/glance/images/fc67361d-ad30-40b2-9d96-941e50fc17f5镜像存放在/var/lib/glance/images下
[M版本]
官方中文文档:http://docs.openstack.org/mitaka/zh_CN/install-guide-rdo/keystone-install.html
本文出自 “abcdocker” 博客,请务必保留此出处http://abcdocker.blog.51cto.com/11255059/1877381
以上是关于OpenStack 镜像服务Glance [三]的主要内容,如果未能解决你的问题,请参考以下文章
Openstack云计算 Openstack Rocky部署三: glance 部署与验证