openstack之glance

1、创建glance用户并授权

[[email protected] ~]#  source admin-openrc.sh
[[email protected] ~]#  openstack user create --domain default --password=glance glance
+-----------+----------------------------------+
| Field     | Value                            |
+-----------+----------------------------------+
| domain_id | default                          |
| enabled   | True                             |
| id        | 9bf74a8f70b34886b89e8510eb21e5ab |
| name      | glance                           |
+-----------+----------------------------------+
[[email protected] ~]# openstack role add --project service --user glance admin

2、创建glance服务及apipoint

[[email protected] ~]# openstack service create --name glance --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | 63fa06d39ec049348a4381bd9f2d52d3 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne   image public http://172.16.80.130:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 6a716435ec7b4d7b8593f02a4bd89a57 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 63fa06d39ec049348a4381bd9f2d52d3 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://172.16.80.130:9292        |
+--------------+----------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne   image internal http://172.16.80.130:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | fcf98c96b25d4da5a1bf68ffafeaf832 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 63fa06d39ec049348a4381bd9f2d52d3 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://172.16.80.130:9292        |
+--------------+----------------------------------+
[[email protected] ~]# openstack endpoint create --region RegionOne   image admin http://172.16.80.130:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 03cbb947b93e43ea936ee6c54db63275 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 63fa06d39ec049348a4381bd9f2d52d3 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://172.16.80.130:9292        |
+--------------+----------------------------------+

3、安装配置glance

[[email protected] ~]# yum install openstack-glance python-glance python-glanceclient -y
[[email protected] glance]#  grep -n ‘^[a-z]‘ /etc/glance/glance-api.conf 
363:verbose=True
491:notification_driver = noop
538:connection=mysql://glance:[email protected]/glance
642:default_store=file
701:filesystem_store_datadir=/var/lib/glance/images/
974:uth_uri = http://172.16.80.130:5000
975:auth_url = http://172.16.80.130:35357
976:auth_plugin = password
977:project_domain_id = default
978:user_domain_id = default
979:project_name = service
980:username = glance
981:password = glance
1484:flavor=keystone

[[email protected] glance]# grep -n ‘^[a-z]‘ /etc/glance/glance-registry.conf 
188:verbose=True
316:notification_driver = noop
363:connection=mysql://glance:[email protected]/glance
763:uth_uri = http://172.16.80.130:5000
764:auth_url = http://172.16.80.130:35357
765:auth_plugin = password
766:project_domain_id = default
767:user_domain_id = default
768:project_name = service
769:username = glance
770:password = glance
1255:flavor=keystone

4、初始化glance数据库并检查配置

[[email protected] glance]# su -s /bin/sh -c "glance-manage db_sync" glance
[[email protected] glance]# mysql -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                            |
+----------------------------------+

5、启动glance服务

[[email protected] glance]# systemctl enable openstack-glance-api.service >   openstack-glance-registry.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service.
[[email protected] glance]# 
[[email protected] glance]# systemctl start openstack-glance-api.service >   openstack-glance-registry.service
[[email protected] glance]#  netstat -lntup|egrep "9191|9292" 
tcp        0      0 0.0.0.0:9191            0.0.0.0:*               LISTEN      96237/python2       
tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN      96236/python2

6、验证glance服务

[[email protected] ~]# echo "export OS_IMAGE_API_VERSION=2" >   | tee -a admin-openrc.sh demo-openrc.sh
export OS_IMAGE_API_VERSION=2
[[email protected] ~]# 
[[email protected] ~]# source admin-openrc.sh
[[email protected] ~]#  wget 

[[email protected] ~]# glance image-create --name "cirros" >   --file cirros-0.3.4-x86_64-disk.img >   --disk-format qcow2 --container-format bare >   --visibility public --progress
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2016-10-29T21:54:17Z                 |
| disk_format      | qcow2                                |
| id               | 6772deca-7b31-4f97-affa-668518b22972 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros                               |
| owner            | 8a3b7f9f1b2c4f7eaf7780d268e672d1     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2016-10-29T21:54:19Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+
[[email protected] ~]# 
[[email protected] ~]# 
[[email protected] ~]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 6772deca-7b31-4f97-affa-668518b22972 | cirros |
+--------------------------------------+--------+
时间: 2024-11-08 17:26:34

openstack之glance的相关文章

58 Openstack基础、openstack之glance、openstack之keystone

03 openstack之keystone 配置环境 Controller CentOS release 6.7 controller eth0:仅主机 192.168.28.121 eth1:桥接 192.168.1.121 node2 192.168.1.122 CentOS release 6.7 compute1 eth0:仅主机,eth1:VMnet2 不会直接与外部网络通信 node3 192.168.1.123 CentOS release 6.7 networking eth0:

Openstack liberty Glance上传镜像源码分析

该文同时发布在[ceph中国社区],署名为Thomas,另外截图不是很清晰,有需要的读者,可以留言索要,谢谢! 在Openstack中创建云主机,首先得有镜像,而Glance模块提供镜像服务功能,包括:镜像的发现.检索及存储等,主要包括:glance-api和glance-registery两个服务,分别负责镜像的存储和元数据管理.下面基于源码,分析下镜像的上传过程. 上传镜像 先通过glance CLI上传镜像,来直观的了解下镜像上传的过程: # glance --debug image-cr

云计算openstack核心组件——glance— 镜像服务(6)

一.glance介绍: Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚拟机镜像的metadata及获取镜像. Glance可以将镜像保存到多种后端存储上,比如简单的文件存储或者对象存储. 理解 Image 要理解 Image Service,先得搞清楚什么是 Image 以及为什么要用 Image? 在传统 IT 环境下,安装一个系统要么从安装 CD 从头安装,要么用 Ghost 等克隆工具恢

openstack (五) Glance 部署

1.glance组件详解 作用:主要用于帮助用户发现.注册及搜索VM实例映像文件(通过REST API的形式) 三大组件功能 磁盘映像文件的存储目录:/var/lib/glance/images 2.组件部署 数据库配置 创建glance数据库 CREATE DATABASE glance; 数据库赋权 GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'glance'; GRANT ALL PRIVIL

openstack中glance组件images的全部python API 汇总

感谢朋友支持本博客,欢迎共同探讨交流.因为能力和时间有限.错误之处在所难免,欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地址:http://blog.csdn.net/qq_21398167/article/details/46620025 Images class glanceclient.v1.images.Image(manager,info, loaded=False) Bases: glanceclient.

openstack中glance组件images的所有python API 汇总

Images class glanceclient.v1.images.Image(manager, info, loaded=False) Bases: glanceclient.openstack.common.apiclient.base.Resource data(**kwargs) delete(**kwargs) update(**fields) class glanceclient.v1.images.ImageManager(client) Bases: glanceclient

【N版】openstack——镜像服务glance(四)

[N版]openstack--镜像服务glance 一.openstack之glance镜像服务 1.1glance介绍 glance主要是由三部分组成 glance-api:接收云系统镜像的创建,删除,读取请求,类似nova-api,通过其他模块(glance-registry及image store)来完成诸如镜像的查找.获取.上传.删除等操作,api监听端口9292. glance-registry:云系统的镜像注册服务,用于与mysql数据库交互,存储或获取镜像的元数据(metadata

OpenStack —— 镜像服务Glance(三)

一.Glance介绍 Image service (glance)允许用户发现.注册和检索虚拟机映像.它提供了一个REST API,它允许你查询虚拟机镜像元数据来获取实际的镜像文件.你可以将Glance提供的虚拟机镜像像存储在各种位置,从简单的文件系统到对象存储系统. 在OpenStack整个云环境中,如果没有虚拟机镜像,就无法再计算节点上生成虚拟机,OpenStack基本上也是没有意义的,所以说镜像服务是OpenStack的一个核心服务. 生成虚拟机时,从Glance获取镜像也是比较简单的.当

openstack运维实战系列(十七)之glance与ceph结合

1. 需求说明 glance作为openstack中image服务,支持多种适配器,支持将image存放到本地文件系统,http服务器,ceph分布式文件系统,glusterfs和sleepdog等开源的分布式文件系统上,本文,通过将讲述glance如何和ceph结合. 目前glance采用的是本地filesystem的方式存储,存放在默认的路径/var/lib/glance/images下,当把本地的文件系统修改为分布式的文件系统ceph之后,原本在系统中镜像将无法使用,所以建议当前的镜像删除