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

glance-registry
glance-registry 是系统后台运行的服务进程。 负责处理和存取 image 的 metadata,例如 image 的大小和类型

Store backend
Glance 自己并不存储 image。 真正的 image 是存放在 backend 中的。 Glance 支持多种 backend,包括:
--A directory on a local file system(这是默认配置)
--GridFS
--Ceph RBD
--Amazon S3
--Sheepdog
--OpenStack Block Storage (Cinder)
--OpenStack Object Storage (Swift)
--VMware ESX

stack@controller:~$ openstack image list
+--------------------------------------+--------------------------+--------+
| ID                                   | Name                     | Status |
+--------------------------------------+--------------------------+--------+
| fc8eecbe-9f86-4f64-b753-397a0f4104b6 | amphora-x64-haproxy      | active |
| cc3ce379-33e0-4e51-876a-57f2d80f88f0 | cirros-0.4.0-x86_64-disk | active |
+--------------------------------------+--------------------------+--------+

存放路径:
stack@controller:~$ ll /opt/stack/data/glance/images/
total 333920
drwxr-xr-x 2 stack stack      4096 6月  15 23:44 ./
drwxr-xr-x 5 stack stack      4096 6月  15 23:42 ../
-rw-r--r-- 1 stack stack  12716032 6月  15 23:42 cc3ce379-33e0-4e51-876a-57f2d80f88f0
-rw-r--r-- 1 stack stack 329206784 6月  15 23:44 fc8eecbe-9f86-4f64-b753-397a0f4104b6

stack@controller:~$ openstack image show -f json cirros-0.4.0-x86_64-disk
{
  "checksum": "443b7623e27ecf03dc9e01ee93f67afe",
  "container_format": "bare",
  "created_at": "2020-06-15T15:42:35Z",
  "disk_format": "qcow2",
  "file": "/v2/images/cc3ce379-33e0-4e51-876a-57f2d80f88f0/file",
  "id": "cc3ce379-33e0-4e51-876a-57f2d80f88f0",
  "min_disk": 0,
  "min_ram": 0,
  "name": "cirros-0.4.0-x86_64-disk",
  "owner": "19e61e26bddc4dd9a942c7f7b936cff2",
  "properties": {
    "os_hidden": false,
    "os_hash_algo": "sha512",
    "os_hash_value": "6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78",
    "owner_specified.openstack.md5": "",
    "owner_specified.openstack.sha256": "",
    "owner_specified.openstack.object": "images/cirros-0.4.0-x86_64-disk",
    "hw_rng_model": "virtio"
  },
  "protected": false,
  "schema": "/v2/schemas/image",
  "size": 12716032,
  "status": "active",
  "tags": [],
  "updated_at": "2020-06-15T15:42:35Z",
  "visibility": "public"
}

查看glance的log
sudo journalctl -f --unit devstack@g-*

devstack的默认配置
stack@controller:~/devstack$ cat /etc/glance/glance-api.conf  | grep -v ^$ | grep -v '#'
[DEFAULT]
logging_exception_prefix = ERROR %(name)s %(instance)s
logging_default_format_string = %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s
logging_context_format_string = %(color)s%(levelname)s %(name)s [%(global_request_id)s %(request_id)s %(project_name)s %(user_name)s%(color)s] %(instance)s%(color)s%(message)s
logging_debug_format_suffix = {{(pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d}}
public_endpoint = http://192.168.101.11/image
registry_host = 192.168.101.11
enable_v1_api = False
transport_url = rabbit://stackrabbit:admin@192.168.101.11:5672/
image_cache_dir = /opt/stack/data/glance/cache/
use_syslog = False
debug = True
[database]
connection = mysql+pymysql://root:admin@127.0.0.1/glance?charset=utf8
[oslo_concurrency]
lock_path = /opt/stack/data/glance/locks
[paste_deploy]
flavor = keystone+cachemanagement
[keystone_authtoken]
memcached_servers = localhost:11211
cafile = /opt/stack/data/ca-bundle.pem
project_domain_name = Default
project_name = service
user_domain_name = Default
password = admin
username = glance
auth_url = http://192.168.101.11/identity
auth_type = password
[oslo_messaging_notifications]
driver = messagingv2
[glance_store]
filesystem_store_datadir = /opt/stack/data/glance/images/
[cors]
allowed_origin = http://192.168.101.11
[key_manager]
backend = barbican

主要参数解释,其余可以参考 https://docs.openstack.org/glance/ussuri/configuration/glance_api.html
image_cache_dir
Base directory for image cache.
This is the location where image data is cached and served out of. All cached images are stored directly under this directory. This directory also contains three subdirectories, namely, incomplete, invalid and queue.
The incomplete subdirectory is the staging area for downloading images. An image is first downloaded to this directory. When the image download is successful it is moved to the base directory. However, if the download fails, the partially downloaded image file is moved to the invalid subdirectory.
The queue``subdirectory is used for queuing images for download. This is used primarily by the cache-prefetcher, which can be scheduled as a periodic task like cache-pruner and cache-cleaner, to cache images ahead of their usage. Upon receiving the request to cache an image, Glance touches a file in the ``queue directory with the image id as the file name. The cache-prefetcher, when running, polls for the files in queue directory and starts downloading them in the order they were created. When the download is successful, the zero-sized file is deleted from the queue directory. If the download fails, the zero-sized file remains and it’ll be retried the next time cache-prefetcher runs.
stack@controller:~$ ll /opt/stack/data/glance/cache/
total 12452
drwxr-xr-x 5 stack stack     4096 6月  20 23:16 ./
drwxr-xr-x 5 stack stack     4096 6月  15 23:42 ../
-rw-r--r-- 1 stack stack    12288 6月  20 23:16 cache.db
-rw-r--r-- 1 stack stack 12716032 6月  16 10:21 cc3ce379-33e0-4e51-876a-57f2d80f88f0
drwxr-xr-x 2 stack stack     4096 6月  16 10:21 incomplete/
drwxr-xr-x 2 stack stack     4096 6月  15 23:42 invalid/
drwxr-xr-x 2 stack stack     4096 6月  15 23:42 queue/

paste_deploy -- flavor(default: keystone)
Deployment flavor to use in the server application pipeline.
Provide a string value representing the appropriate deployment flavor used in the server application pipleline. This is typically the partial name of a pipeline in the paste configuration file with the service name removed.
For example, if your paste section name in the paste configuration file is [pipeline:glance-api-keystone], set flavor to keystone.

glance_store -- filesystem_store_datadir(default: /var/lib/glance/images)
Directory to which the filesystem backend store writes images.
Upon start up, Glance creates the directory if it doesn’t already exist and verifies write access to the user under which glance-api runs. If the write access isn’t available, a BadStoreConfiguration exception is raised and the filesystem store may not be available for adding new images.
NOTE: This directory is used only when filesystem store is used as a storage backend. Either filesystem_store_datadir or filesystem_store_datadirs option must be specified in glance-api.conf. If both options are specified, a BadStoreConfiguration will be raised and the filesystem store may not be available for adding new images.

stack@controller:~$ cat /etc/glance/glance-registry.conf  | grep -v ^$ | grep -v '#'
[DEFAULT]
logging_exception_prefix = ERROR %(name)s %(instance)s
logging_default_format_string = %(color)s%(levelname)s %(name)s [-%(color)s] %(instance)s%(color)s%(message)s
logging_context_format_string = %(color)s%(levelname)s %(name)s [%(global_request_id)s %(request_id)s %(project_name)s %(user_name)s%(color)s] %(instance)s%(color)s%(message)s
logging_debug_format_suffix = {{(pid=%(process)d) %(funcName)s %(pathname)s:%(lineno)d}}
graceful_shutdown_timeout = 5
transport_url = rabbit://stackrabbit:admin@192.168.101.11:5672/
use_syslog = False
workers = 2
bind_host = 0.0.0.0
debug = True
[database]
connection = mysql+pymysql://root:admin@127.0.0.1/glance?charset=utf8
[paste_deploy]
flavor = keystone
[keystone_authtoken]
memcached_servers = localhost:11211
cafile = /opt/stack/data/ca-bundle.pem
project_domain_name = Default
project_name = service
user_domain_name = Default
password = admin
username = glance
auth_url = http://192.168.101.11/identity
auth_type = password
[oslo_messaging_notifications]
driver = messagingv2

主要参数解释,其余可以参考 https://docs.openstack.org/glance/ussuri/configuration/glance_registry.html
workers
Number of Glance worker processes to start.
Provide a non-negative integer value to set the number of child process workers to service requests. By default, the number of CPUs available is set as the value for workers limited to 8. For example if the processor count is 6, 6 workers will be used, if the processor count is 24 only 8 workers will be used. The limit will only apply to the default value, if 24 workers is configured, 24 is used.
Each worker process is made to listen on the port set in the configuration file and contains a greenthread pool of size 1000.
NOTE: Setting the number of workers to zero, triggers the creation of a single API process with a greenthread pool of size 1000.
root@controller:~# ps -ef | grep glance-registry
stack      6560      1  0 02:19 ?        00:07:59 /usr/bin/python3.6 /usr/local/bin/glance-registry --config-file=/etc/glance/glance-registry.conf
stack      6671   6560  0 02:20 ?        00:00:00 /usr/bin/python3.6 /usr/local/bin/glance-registry --config-file=/etc/glance/glance-registry.conf
stack      6672   6560  0 02:20 ?        00:00:00 /usr/bin/python3.6 /usr/local/bin/glance-registry --config-file=/etc/glance/glance-registry.conf
1个父进程2个子进程

bind_host(default: 0.0.0.0)
IP address to bind the glance servers to.
Provide an IP address to bind the glance server to. The default value is 0.0.0.0.
Edit this option to enable the server to listen on one particular IP address on the network card. This facilitates selection of a particular network interface for the server.

数据库访问
stack@controller:~$ mysql
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| barbican           |
| cinder             |
| glance             |
| keystone           |
| mysql              |
| neutron            |
| nova_api           |
| nova_cell0         |
| nova_cell1         |
| octavia            |
| performance_schema |
| placement          |
| sys                |
+--------------------+
mysql> use glance
mysql> show tables;
+----------------------------------+
| Tables_in_glance                 |
+----------------------------------+
| alembic_version                  |
| 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                            |
+----------------------------------+
mysql> select * from images;
+--------------------------------------+--------------------------+-----------+--------+---------------------+---------------------+------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+------------+-----------+--------------+----------------------------------------------------------------------------------------------------------------------------------+
| id                                   | name                     | size      | status | created_at          | updated_at          | deleted_at | deleted | disk_format | container_format | checksum                         | owner                            | min_disk | min_ram | protected | virtual_size | visibility | os_hidden | os_hash_algo | os_hash_value                                                                                                                    |
+--------------------------------------+--------------------------+-----------+--------+---------------------+---------------------+------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+------------+-----------+--------------+----------------------------------------------------------------------------------------------------------------------------------+
| cc3ce379-33e0-4e51-876a-57f2d80f88f0 | cirros-0.4.0-x86_64-disk |  12716032 | active | 2020-06-15 15:42:35 | 2020-06-15 15:42:35 | NULL       |       0 | qcow2       | bare             | 443b7623e27ecf03dc9e01ee93f67afe | 19e61e26bddc4dd9a942c7f7b936cff2 |        0 |       0 |         0 |         NULL | public     |         0 | sha512       | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 |
| fc8eecbe-9f86-4f64-b753-397a0f4104b6 | amphora-x64-haproxy      | 329206784 | active | 2020-06-15 15:44:29 | 2020-06-15 15:44:33 | NULL       |       0 | qcow2       | bare             | 2e0880d1540b939d59b00e98756ccc5c | 19e61e26bddc4dd9a942c7f7b936cff2 |        0 |       0 |         0 |         NULL | public     |         0 | sha512       | a67d0e98046a28b5571ee89d0ee51600f5276ef654c7a6dd0ee726e08b35e7dd22166c85d9818ea6a52ac1572e99a8ecbbd85d0ab63ff7ec0bbf07eb1c09d755 |
+--------------------------------------+--------------------------+-----------+--------+---------------------+---------------------+------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+------------+-----------+--------------+----------------------------------------------------------------------------------------------------------------------------------+

API访问
stack@controller:~/devstack$ openstack token issue -f value -c id
gAAAAABe9LHutvUf7-HnnewthBIdqg58Ra5VVkAcRKA8wfyjz-cDzocbktW7SO8dUkwygu2u_J0fecf1DXO3WzktbOU1idpSlt9E1MCjGSm1hcVsPCbwgazwVe51pYaeDV_3tN-eaFsdun2laz1_Vx5nryHm3pdK1FjJtXRrFwQu2lRmJR33cew

stack@controller:~/devstack$ TOKEN='gAAAAABe9LHutvUf7-HnnewthBIdqg58Ra5VVkAcRKA8wfyjz-cDzocbktW7SO8dUkwygu2u_J0fecf1DXO3WzktbOU1idpSlt9E1MCjGSm1hcVsPCbwgazwVe51pYaeDV_3tN-eaFsdun2laz1_Vx5nryHm3pdK1FjJtXRrFwQu2lRmJR33cew'

stack@controller:~/devstack$ curl http://192.168.101.11/image/v2/images -H "x-auth-token: $TOKEN" -X GET
{"images": [{"hw_rng_model": "virtio", "owner_specified.openstack.md5": "", "owner_specified.openstack.sha256": "", "owner_specified.openstack.object": "images/amphora-x64-haproxy", "hw_architecture": "x86_64", "name": "amphora-x64-haproxy", "disk_format": "qcow2", "container_format": "bare", "visibility": "public", "size": 329206784, "virtual_size": null, "status": "active", "checksum": "2e0880d1540b939d59b00e98756ccc5c", "protected": false, "min_ram": 0, "min_disk": 0, "owner": "19e61e26bddc4dd9a942c7f7b936cff2", "os_hidden": false, "os_hash_algo": "sha512", "os_hash_value": "a67d0e98046a28b5571ee89d0ee51600f5276ef654c7a6dd0ee726e08b35e7dd22166c85d9818ea6a52ac1572e99a8ecbbd85d0ab63ff7ec0bbf07eb1c09d755", "id": "fc8eecbe-9f86-4f64-b753-397a0f4104b6", "created_at": "2020-06-15T15:44:29Z", "updated_at": "2020-06-15T15:44:33Z", "tags": ["amphora"], "self": "/v2/images/fc8eecbe-9f86-4f64-b753-397a0f4104b6", "file": "/v2/images/fc8eecbe-9f86-4f64-b753-397a0f4104b6/file", "schema": "/v2/schemas/image"}, {"hw_rng_model": "virtio", "owner_specified.openstack.md5": "", "owner_specified.openstack.sha256": "", "owner_specified.openstack.object": "images/cirros-0.4.0-x86_64-disk", "name": "cirros-0.4.0-x86_64-disk", "disk_format": "qcow2", "container_format": "bare", "visibility": "public", "size": 12716032, "virtual_size": null, "status": "active", "checksum": "443b7623e27ecf03dc9e01ee93f67afe", "protected": false, "min_ram": 0, "min_disk": 0, "owner": "19e61e26bddc4dd9a942c7f7b936cff2", "os_hidden": false, "os_hash_algo": "sha512", "os_hash_value": "6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78", "id": "cc3ce379-33e0-4e51-876a-57f2d80f88f0", "created_at": "2020-06-15T15:42:35Z", "updated_at": "2020-06-15T15:42:35Z", "tags": [], "self": "/v2/images/cc3ce379-33e0-4e51-876a-57f2d80f88f0", "file": "/v2/images/cc3ce379-33e0-4e51-876a-57f2d80f88f0/file", "schema": "/v2/schemas/image"}], "first": "/v2/images", "schema": "/v2/schemas/images"}

openstack学习笔记 glance相关推荐

  1. openstack 学习笔记 虚拟机的基础安装sql glance nova keystone 。。。。。

    专业综合设计与开发 目 录 1.虚拟机的安装 6 1.1 虚拟机安装配置 6 1.2 安装epel仓库 6 1.3 克隆前的其它准备工作 6 2.Open Stack 7 2.1 OpenStack是 ...

  2. openstack学习笔记六 多节点部署之keystone

    keystone    对用户进行验证,每个组件必须得实用一个用户向keystone进行注册,只有成功了,那么这个组件才能正常工作.所以当我们在创建其他组件的时候,也包括keystone本身,都得为这 ...

  3. openstack的逻辑概念_精通openstack学习笔记(一)

    第一章 OpenStack参考架构设计 当前很多企业都是自建昂贵的IT系统,多年持续开发以及运维,架构臃肿,不具有可持续性.openstack是一种解决方案,通过软件定义基础架构,让企业可以快速.灵活 ...

  4. openstack学习笔记之一:基础知识

    1.什么是openstack openstack是一套iaas解决方案 OpenStack是由美国国家宇航局(NASA)和RackSpace合作开发的旨在为公有云和私有云提供软件的开源项目,其目的在于 ...

  5. openstack学习笔记之keystone

    keystone 作为 OpenStack 的基础支持服务,Keystone 做下面这几件事情: --管理用户及其权限 --维护 OpenStack Services 的 Endpoint --Aut ...

  6. openstack学习笔记之三:keystone简介与手动安装部署

    1.Keystone的架构 Keystone(OpenStack Identity Service)是 OpenStack 框架中负责管理身份验证.服务规则和服务令牌功能的模块.Keystone作为O ...

  7. openstack学习笔记五 多节点部署之 rabbitmq信息中枢与元数据

    元数据 rabbitmq信息中枢 rabbitmq信息中枢 所有组件通信的时候 实用 AMQP 高级消息队列 qpid rabbitmq    端口5672       sll加密 5671 1 2 ...

  8. openstack学习笔记三 创建第一个实例

    登陆admin 创建一个基本网络 镜像   已经安装好操作系统的硬盘文件 计算--镜像--创建镜像 名称  centos7.2-1511 镜像源  镜像地址 镜像地址    http://mirror ...

  9. openstack 学习笔记-flavor 操作

    nova flavor  创建和删除: 1)查看flavor nova flavor-list 2)创建flavor(建议FLAVOR_ID为auto,ROOT_DISK_IN_GB为0) nova ...

最新文章

  1. python array_python数组array.array(转帖)
  2. SringBoot+Redis整合
  3. 大飞鸽传书!小飞鸽传书!
  4. java页面间面向对象的方法面试题_JAVA面向对象面试题带答案(墙裂推荐)
  5. java volatile实例_Java的Volatile实例用法及讲解
  6. 435. 无重叠区间(JavaScript)
  7. log4net异步写入日志_redis学习笔记(三)RDB日志
  8. Linux nmon 命令
  9. 博为峰JavaEE技术文章 ——MyBatis RowBounds分页
  10. IntelliJ IDEA Maven安装配置
  11. 如何使用dosbox运行程序——步骤详解
  12. js利用CLodop实现打印功能
  13. Android MeasureSpec解析
  14. vs2013连接access2016
  15. 在matlab使用矩阵的方法计算DFT
  16. 中国Linux内核开发者大会
  17. SQL语句中,有了别名不能再用原名,需要使用别名
  18. 重写和重载有什么区别
  19. matlab 正交多项式,常用正交多项式
  20. OSPF虚链接的基本配置

热门文章

  1. 55个有关高考的经典幽默搞笑话段子
  2. 苹果微信王者荣耀哪个服务器人多,王者荣耀,微信区和QQ区谁更厉害,为什么QQ区人更多呢...
  3. 联想r480安全模式_联想R480怎么改造(学生党)?
  4. c语言调汇编程序比较字符串,用汇编语言实现两个字符串的输入并比较,输出不同字符的个数,要用MACRO比较...
  5. 苹果iPad 2十大亮点与5大遗憾
  6. moto+早期android手机,中坚力量:摩托罗拉XT701
  7. RMAN正确地删除Archivelog以及设置有备库的归档删除策略
  8. 机器学习导论(张志华)笔记
  9. iphone获取当前系统的语言
  10. 什么是客户端负载均衡