什么是OpenStack的Glance镜像服务(概念,文件格式,组件工作流程及访问权限)

名为glance,在早期的openstack版本中,glance只有管理镜像的功能,
并不具备镜像存储功能。现在,glance已发展成为集镜像上传,检索,
管理和存储等多种功能的openstack核心服务。

上一篇keystone组件部署,点这里

一,glance镜像服务

1,如何理解镜像?

通常是指一系列文件或一个磁盘驱动器的精确副本,镜像文件其实和ZIP压缩包类似,它将特定的一系列文件按照一定的格式制作成单一的文件,以方便用户下载和使用。

2,情景深入理解镜像

例如:GHOST是使用镜像文件的经典软件,其镜像文件可以包含更多信息,如系统文件,引导文件,分区别信息等,这样镜像文件就可以包含一个分区甚至是一块硬盘所有信息,ghost可基于镜像文件快速安装操作系统和应用程序
打个比方:vmware的虚拟机模板

3,如何理解glance镜像服务
  • 镜像服务就是用来管理镜像的,让用户能够发现,获取和保存镜像, 在openstack中提供镜像服务的是glance,其主要功能如下:

    • 查询和获取镜像的元数据和镜像本身
    • 注册和上传虚拟机镜像,包括镜像的创建,上传下载和管理
    • 维护镜像信息,包括元数据和镜像本身
    • 支持多种方式存储镜像,包括普通的文件系统,swift,amazon s3等
    • 对虚拟机示例执行创建快照命令来创建新的镜像,或者备份虚拟机的状态。
  • images API的版本

    • 有两个版本:api v1 和api v2
    • v1只 提供基本的镜像和成员 操作功能, 包括镜像创建,删除,下载,列表,详细信息查询, 更新,以及镜像租户成员的创建,删除和列表。
    • v2除了支持v1的所有功能外,主要增加了镜像位置的添加,删除,修改,元数据和名称空间操作,以及镜像标记操作。
      总结:两个版本对镜像存储支持相同,v1从n版开始已经过时,还迁移路径使用v2进行替代
  • 镜像文件格式

镜像文件容器格式

+ bare:没有容器或元数据“信封”
+ ovf:开放虚拟化格式
+ ova:在glance中存储的amazon内核格式
+ ari:在glance中存储的amazon虚拟内存盘(Ramdlsk)格式
+ aki:在glance中存储的amazon内核格式
+ docker:在glance中存储的容器文件系统的docker的tar归档

如果不能确定选择哪种容器格式,那么简单的容器格式指定为bare是安全。

虚拟机镜像文件磁盘格式

+ raw:无结构的磁盘格式
+ vhd:该格式通用于VMware、Xen、VirtualBox以及其他虚拟机管理程序
+ vhdx:vhd格式的增强版本,支持更大的磁盘尺寸
+ vmdk:—种比较通用的虚拟机磁盘格式
+ vdi:由VirtuaBox虚拟机监控程序和QEMU仿真器支持的磁盘格式
+ iso:用于光盘(CD-ROM)数据内容的档案格式
+ ploop:由Virtuozzo支持,用于运行OS容器的磁盘格式
+ qcow2:由QEMU仿真支持,可动态扩展,支持写时复制(Copy on Write)的磁盘格式aki:在Glance中存储的Amazon内核格式
+ ari:在Glance中存储的Amazon虚拟内存盘(Ramdisk)格式ami:在Glance中存储的Amazon机器格式
4,镜像状态
 + queued:这是一种初始化状态,镜像文件刚被创建,在glance数据库只有其元数据,镜像数据还没有上传至数据库中
 + saving:是镜像的原始数据在上传到数据库中的一种过渡状态,表示正在上传镜像
 + uploading指示已进行导入数据提交调用,此状态下不允许调用put/file(saving状态会执行put/file,这是另外一种上传的方法)
 + deleted : 镜像将在不久后被自动删除,该镜像不可再用,但是目前Glance仍然保留该镜像的相关信息和原始数据
 + pending_delete:与deleted相似,Glance还没有清除镜像数据,但处于该状态的镜像不可恢复
+ active:表示当镜像数据成功上传完毕,成为Glance中可用的镜像
+ deactivated:表示任何非管理员用户都无权访问镜像数据,禁止下载镜像,禁止镜像导出和镜像克隆之类的操作
+ killed:表示镜像上传过程中发生错误,镜像不可读
5,访问权限
  • Public(公共的):可以被所有的项目使用
  • Private (私有的):只有被镜像所有者所在的项目使用
  • Shared(共享的):一个非共有的镜像可以共享给其他项目,这是通过项目成员(member-*)操作来实现的
  • Protected(受保护的):这种镜像不能被删除

二,glance架构详解

架构图如下:

在这里插入图片描述

  • 客户端是Glance服务应用程序使用者,是OpenStack命令行工具、Horizon或Nova服务

  • glance-api是系统后台运行的服务进程。是进入Glance的入口。它对外提供REST API,负责接收用户的RESTul请求,响应镜像查询、获取和存储的调用。

  • glance-registry是系统后台运行的glancei注册服务进程,负责处理与镜像元数据相关的RESTful请求,元数据包括镜像大小、类型等信息。Glance-api接收的请求如果是与镜像的元数据相关的操作, glance-api会把请求转发给glance-registry.glance-registry会解析请求内容,并与数据库交互。存储,处理、检索镜像的元数据。glance-api对外提供API。而gllance-registry的API只由glance-api使用。

  • Glance的DB模块存储的是镜像的元数据,可以选用MYSQL、MariaDB、SQLite等数据库。镜像的元数据通过glance-registry存放在数据库中。注意,镜像本身(chunk数据)是通过glance存储驱动存放到各种存储后端中的。

  • 存储后端(Store Backend) Glance自身并不存储镜像,它将镜像存放在后端存储系统中。镜像本身的数据通过glance_store存放在各种后端,并可从中获取。支持本地存储、对象存储、RBD块设备、Sheepdog分布式存储、Cinder块存储、VMware数据存储。
    具体使用哪种backend,是在

/etc/glancelglance-api.conf 中配置的[glance_store]

三,glance工作流程

工作流程及模块图如下:

在这里插入图片描述

  • 1,OpenStack的操作都需经Keystone进行身份认证(AuthN)并授权(AuthZ),Glance也不例外。Glance是一个C/S架构,提供一个REST API,用户就通过RESTAPI来执行镜像的各种操作。[Glance Domain Controller是一个主要的中间件,相当于调度器,作用是将Glance内部服务的操作分发到以下各个功能层

  • 2,Auth(授权):用来控制镜像的访问权限,决定镜像自己或者它的属性是否可以被修改,只有管理员或镜像的拥有者才可以执行修改操作。roperty Protection(属性保护):这是个可选层,要在Glance配置文件中设置了
    property_protection_file参数才会生效。它提供两种类型的镜像属性,一种是核心属性,在镜像参数中指定;另一种是元数据属性,可以被附加到一个镜像上的任一键值对。该层通过调用Glance的public API管理对meta属性的访问,也可以在配置文件中限制该访问。

  • 3,Notifier(消息通知):将镜像变化的消息和使用镜像时发生的错误和警告添加到消息队列中。

  • 4,Policyx(规则定义):定义镜像操作的访问规则,这些规则在/etc/policy.json文件中定义,该层对其进行监视并实施。

  • 5,Quota(配额限制):如果管理员对某用户定义了镜像大小的镜像上传上限,则该用户上传了超过该限额的镜像时会上传失败。

  • 6,Location(定位):通过glance_store与后台存储进行交互,例如上传、下载镜像,管理镜像存储位置。该层还能够在添加新位置时检查位置URI是否正确;镜像位置改变时删除存储后端保存的镜像数据;防止镜像位置重复。

  • 7,DB(数据库):实现与数据库进行交互的API,一方面将镜像转换为相应的格式以存储在数据库中,另一方面将从数据库读取的信息转换为可操作的镜像对象。

  • 8,Registry Layer(注册层):是一个可选层,通过使用单独的服务控制Glance Domain Controller与GlanceDB之间的安全交互。

  • 9,Glance DB:是Glance服务使用的核心库,该库对Glance内部所有依赖数据库的组件是共享的。(这个库是存一些元数据信息的,不是真正存镜像的数据库)

  • 10,Glance Store:用来组织处理Glance和各种存储后端的交互,提供了一个统一的接口来访问后端的存储。所有的镜像文件操作都是通过调用Glance Store库来执行的,它负责与外部存储端或本地文件存储系统的交互。

注意:

1, glance-api是系统后台运行的服务进程。对外提供 REST API,响应image查询、获取和存储的调用。glance-api不会真正处理请求。
2,如果是与image metadata (元数据)相关的操作,glance-api 会把请求转发给glance-registry;
3,如果是与image自身存取相关的操作,glance-api会把请求转发给该image的store backend。
4,查看glance-api进程:ps -ef | grep glance-api 

五,镜像节点配置:

####### 创建数据库实例和数据库用户##########


[root@ct ~]# mysql -u root -p    
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.3.20-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE glance;
Query OK, 1 row affected (0.353 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.003 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> exit
Bye



######### 创建用户,修改配置文件###########



 1,创建OpenStack的Glance用户
 
#创建用户前,需要首先执行管理员环境变量脚本(此处已经在~/.bashrc 中定义过了)
[root@ct ~]# openstack user create --domain default --password GLANCE_PASS glance     ###创建glance用户


+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 0860b30245654ef3b2bb801ace6ffdf0 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
[root@ct ~]# openstack role add --project service --user glance admin     #将glance用户添加到service项目中,并且针对这个项目拥有admin权限;注册glance的API,需要对service项目有admin权限


[root@ct ~]# openstack service create --name glance --description "OpenStack Image" image    ####创建一个service服务,service名称为glance,类型为image;创建完成后可以通过 openstack service list 
查看


+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image                  |
| enabled     | True                             |
| id          | 4f2b91b55bfa4b2c8d26b76b06419270 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+


2,创建镜像服务 API 端点,OpenStack使用三种API端点代表三种服务:admin、internal、public


[root@ct ~]#  openstack endpoint create --region RegionOne image public http://ct:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | fd55b782020a40278fe99ceafaf5b8b9 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4f2b91b55bfa4b2c8d26b76b06419270 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://ct:9292                   |
+--------------+----------------------------------+
[root@ct ~]#  openstack endpoint create --region RegionOne image internal http://ct:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 8c448938ed6e43cdabe2366fb3a451de |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4f2b91b55bfa4b2c8d26b76b06419270 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://ct:9292                   |
+--------------+----------------------------------+
[root@ct ~]#  openstack endpoint create --region RegionOne image admin http://ct:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 2e95963f067148b480fe3738164cedae |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | 4f2b91b55bfa4b2c8d26b76b06419270 |
| service_name | glance                           |
| service_type | image                            |
| url          | http://ct:9292                   |
+--------------+----------------------------------+



3,安装 openstack-glance 软件包

[root@ct ~]# yum -y install openstack-glance 


4,修改glance配置文件,glance有两个配置文件:/etc/glance/glance-api.conf  和/etc/glance/glance-registry.conf


[root@ct ~]# cp -a /etc/glance/glance-api.conf{,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf
[root@ct ~]# cd /etc/glance/
[root@ct glance]# ls
glance-api.conf           glance-registry.conf  policy.json
glance-api.conf.bak       glance-scrubber.conf  rootwrap.conf
glance-cache.conf         glance-swift.conf     rootwrap.d
glance-image-import.conf  metadefs              schema-image.json


5,添加glance-api.conf配置

  ###### 相关的配置文件参数如下:
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
ce/glance-api.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ct: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 GLANCE_PASS
openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
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/[root@ct glance]# openstack-config -one_authtoken www_authenticate_uri http://ct:5000
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://ct:5000
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers ct:11211
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf glance_store default_store file
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
[root@ct glance]# openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/

###### 查看传入的参数

[root@ct glance]# cat glance-api.conf
[DEFAULT]
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
[file]
[glance.store.http.store]
[glance.store.rbd.store]
[glance.store.sheepdog.store]
[glance.store.swift.store]
[glance.store.vmware_datastore.store]
[glance_store]
stores = file,http             #存储类型,file:文件,http:基于api调用的方式,把镜像放到其他存储上
default_store = file          #默认存储方式
filesystem_store_datadir = /var/lib/glance/images/       ##指定镜像存放的本地目录
[image_format]
[keystone_authtoken]
www_authenticate_uri = http://ct:5000     ##指定认证的keystone的URL
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service       #glance用户针对service项目拥有admin权限
username = glance
password = GLANCE_PASS
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone          #指定提供认证的服务器为keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
[root@ct glance]# 

###### 修改glance-registry.conf 配置文件

[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf database connection mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
 /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ct: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 GLANCE_PASS
openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
openstack-config --set /etc/glance/glance-registry.conf glance_store stores file,http
openstack-config --set /etc/glance/glance-registry.conf glance_store default_store file
openstack-config --set /etc/glance/glance-registry.conf glance_store filesystem_store_datadir /var/lib/glance/images/[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken www_authenticate_uri http://ct:5000
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_url http://ct:5000
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken memcached_servers ct:11211
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_type password
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_domain_name Default
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken user_domain_name Default
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken project_name service
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken username glance
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken password GLANCE_PASS
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf glance_store stores file,http
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf glance_store default_store file
[root@ct glance]# openstack-config --set /etc/glance/glance-registry.conf glance_store filesystem_store_datadir /var/lib/glance/images/

##### 查看传参结果:

[root@ct glance]# cat glance-registry.conf
[DEFAULT]
[database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ct/glance
[keystone_authtoken]
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]

6,初始化glance数据库,生成相关表结构;(不管有多少个controler,只需要初始化一次即可

[root@ct glance]# su -s /bin/sh -c "glance-manage db_sync" glance
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
/usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1280, u"Name 'alembic_version_pkc' ignored for PRIMARY key.")
  result = self._query(query)
INFO  [alembic.runtime.migration] Running upgrade  -> liberty, liberty initial
INFO  [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of 'images' table
INFO  [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server
INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images
INFO  [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01
INFO  [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01
INFO  [alembic.runtime.migration] Running upgrade queens_expand01 -> rocky_expand01, add os_hidden column to images table
INFO  [alembic.runtime.migration] Running upgrade rocky_expand01 -> rocky_expand02, add os_hash_algo and os_hash_value columns to images table
INFO  [alembic.runtime.migration] Running upgrade rocky_expand02 -> train_expand01, empty expand for symmetry with train_contract01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: train_expand01, current revision(s): train_expand01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Database migration is up to date. No migration needed.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images
INFO  [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables
INFO  [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01
INFO  [alembic.runtime.migration] Running upgrade queens_contract01 -> rocky_contract01
INFO  [alembic.runtime.migration] Running upgrade rocky_contract01 -> rocky_contract02
INFO  [alembic.runtime.migration] Running upgrade rocky_contract02 -> train_contract01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Upgraded database to: train_contract01, current revision(s): train_contract01
INFO  [alembic.runtime.migration] Context impl MySQLImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
Database is synced successfully.




7,开启glance服务(此处开启之后会生成存放镜像的目录/var/lib/glance/image)
[root@ct glance]# systemctl enable openstack-glance-api.service
Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service.
[root@ct glance]# systemctl start openstack-glance-api.service
[root@ct glance]# netstat -anpt | grep 9292   ## 查看
tcp        0      0 0.0.0.0:9292            0.0.0.0:*               LISTEN      33079/python2       

[root@ct glance]# lsof -i:9292   ## 用lsof查看
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
glance-ap 33079 glance    4u  IPv4 100952      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 33093 glance    4u  IPv4 100952      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 33094 glance    4u  IPv4 100952      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 33095 glance    4u  IPv4 100952      0t0  TCP *:armtechdaemon (LISTEN)
glance-ap 33096 glance    4u  IPv4 100952      0t0  TCP *:armtechdaemon (LISTEN)


[root@ct glance]# ss -natp | grep 9292    ##用ss查看
LISTEN     0      128          *:9292                     *:*                   users:(("glance-api",pid=33096,fd=4),("glance-api",pid=33095,fd=4),("glance-api",pid=33094,fd=4),("glance-api",pid=33093,fd=4),("glance-api",pid=33079,fd=4))



8,赋予openstack-glance-api.service服务对存储设备的可写权限(-h:值对符号连接/软链接的文件修改)


[root@ct glance]# chown -hR glance:glance /var/lib/glance/

9,镜像导入

[root@ct ~]# ls
anaconda-ks.cfg  cirros-0.3.5-x86_64-disk.img  original-ks.cfg
[root@ct ~]# mv cirros-0.3.5-x86_64-disk.img /etc/glance
[root@ct ~]# ls
anaconda-ks.cfg  original-ks.cfg
[root@ct ~]# cd /etc/glance/
[root@ct glance]# ls
cirros-0.3.5-x86_64-disk.img  glance-api.conf.bak  glance-image-import.conf  glance-registry.conf.bak  glance-swift.conf  policy.json    rootwrap.d
glance-api.conf               glance-cache.conf    glance-registry.conf      glance-scrubber.conf      metadefs           rootwrap.conf  schema-image.json


10,然后导入glance,最后查看是否创建成功

[root@ct glance]# openstack image create --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | f8ab98ff5e73ebab884d80c9dc9c7290                                                                                                                                                           |
| container_format | bare                                                                                                                                                                                       |
| created_at       | 2020-12-21T07:32:16Z                                                                                                                                                                       |
| disk_format      | qcow2                                                                                                                                                                                      |
| file             | /v2/images/1059de74-161c-4aa3-b246-ae125283113a/file                                                                                                                                       |
| id               | 1059de74-161c-4aa3-b246-ae125283113a                                                                                                                                                       |
| min_disk         | 0                                                                                                                                                                                          |
| min_ram          | 0                                                                                                                                                                                          |
| name             | cirros                                                                                                                                                                                     |
| owner            | df0c649971b7417882e31c937b52c1a0                                                                                                                                                           |
| properties       | os_hash_algo='sha512', os_hash_value='f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f919ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232', os_hidden='False' |
| protected        | False                                                                                                                                                                                      |
| schema           | /v2/schemas/image                                                                                                                                                                          |
| size             | 13267968                                                                                                                                                                                   |
| status           | active                                                                                                                                                                                     |
| tags             |                                                                                                                                                                                            |
| updated_at       | 2020-12-21T07:32:16Z                                                                                                                                                                       |
| virtual_size     | None                                                                                                                                                                                       |
| visibility       | public                                                                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+



11,最后查看的两种方式
[root@ct glance]# openstack image list   ### 与下面的-list的区别就是一个可以看到状态,一个看不到状态
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| 1059de74-161c-4aa3-b246-ae125283113a | cirros | active |
+--------------------------------------+--------+--------+

[root@ct glance]# glance image-list
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 1059de74-161c-4aa3-b246-ae125283113a | cirros |
+--------------------------------------+--------+

下一篇博客Nova组件部署 点这里

猜你喜欢

转载自blog.csdn.net/Lihuihui006/article/details/111277955