云计算OpenStack核心组件---glance镜像服务(6)
一、glance介绍:
Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找、注册和检索等。 Glance提供Restful API可以查询虚拟机镜像的metadata及获取镜像。 Glance可以将镜像保存到多种后端存储上,比如简单的文件存储或者对象存储。
1、Image
- 如果要安装的系统多了效率就很低
- 时间长,工作量大
- 安装完还要进行手工配置,比如安装其他的软件,设置 IP 等
- 备份和恢复系统不灵活
- 先手工安装好这么一个虚机
- 然后对虚机执行 snapshot,这样就得到了一个 image
- 当有新员工入职需要办公环境时,立马启动一个或多个该 image 的 instance(虚机)就可以了
2、Image Service
- 提供 REST API 让用户能够查询和获取 image 的元数据和 image 本身
- 支持多种方式存储 image,包括普通的文件系统、Swift、Amazon S3 等
- 对 Instance 执行 Snapshot 创建新的 image
3、Glance架构
glance的架构图如下:
4、glance-api
5、glance-registry
glance-registry 是系统后台运行的服务进程。 负责处理和存取 image 的 metadata,例如 image 的大小和类型。在控制节点上可以查看 glance-registry 进程
Glance 支持多种格式的 image,包括
6、Database
Image 的 metadata 会保持到 database 中,默认是 MySQL。 在控制节点上可以查看 glance 的 database 信息
7、Store backend
- A directory on a local file system(这是默认配置)
- GridFS
- Ceph RBD
- Amazon S3
- Sheepdog
- OpenStack Block Storage (Cinder)
- OpenStack Object Storage (Swift)
- VMware ESX
查看保存目录
每个 image 在目录下都对应有一个文件,文件以 image 的 ID 命名。
二、glance创建镜像:
(1)Web UI创建image
(2)CLI创建image
将上传的镜像传到控制节点
openstack image create "cirros" --file cirros-0.3.3-x86_64-disk.img.img --disk-format qcow2 --container-format bare --public
三、安装配置glance服务(控制节点)
https://docs.openstack.org/ocata/install-guide-rdo/glance-install.html
1、在数据库中创建glance服务的数据库及用户,并设置权限
(1)使用root用户登录数据库
[root@ren3 ~]# mysql -u root -proot
(2)创建glance数据库
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| keystone |
| mysql |
| performance_schema |
+--------------------+
4 rows in set (0.05 sec) MariaDB [(none)]> create database glance;
Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| glance |
| information_schema |
| keystone |
| mysql |
| performance_schema |
+--------------------+
5 rows in set (0.00 sec)
(3)创建glance用户并授权
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> select user,host,password from mysql.user;
+----------+-----------+-------------------------------------------+
| user | host | password |
+----------+-----------+-------------------------------------------+
| root | localhost | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | 127.0.0.1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| root | ::1 | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| glance | localhost | *C0CE56F2C0C7234791F36D89700B02691C1CAB8E |
| keystone | localhost | *442DFE587A8B6BE1E9538855E8187C1EFB863A73 |
| keystone | % | *442DFE587A8B6BE1E9538855E8187C1EFB863A73 |
| glance | % | *C0CE56F2C0C7234791F36D89700B02691C1CAB8E |
+----------+-----------+-------------------------------------------+
7 rows in set (0.00 sec)
退出数据库
2、加载OpenStack系统变量文件
[root@ren3 ~]# ls
anaconda-ks.cfg openrc yum-repo.sh
[root@ren3 ~]# source openrc
3、创建服务凭证
(1)创建glance用户:
[root@ren3 ~]# openstack user create --domain default --password=glance glance
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 2807e20f8405473e831602b6b12588c7 |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@ren3 ~]# openstack user list
+----------------------------------+--------+
| ID | Name |
+----------------------------------+--------+
| 2807e20f8405473e831602b6b12588c7 | glance |
| 372fccfd264c4edfb600af3f56052ec7 | admin |
| 37c7c00d574146e8817413b7a091f594 | demo |
+----------------------------------+--------+
(2)添加admin角色和服务项目到glance用户:
[root@ren3 ~]# openstack role add --project service --user glance admin
(3)创建glance服务
[root@ren3 ~]# openstack service create --name glance \
--description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | a7cf08799d4b4b509530ae6c21453b08 |
| name | glance |
| type | image |
+-------------+----------------------------------+
[root@ren3 ~]# openstack service list
+----------------------------------+----------+----------+
| ID | Name | Type |
+----------------------------------+----------+----------+
| a7cf08799d4b4b509530ae6c21453b08 | glance | image |
| ab70227ae28c4fb7a774ed4808489e76 | keystone | identity |
+----------------------------------+----------+----------+
4、创建image服务API端点
[root@ren3 ~]# openstack endpoint list
+----------+----------+--------------+--------------+---------+-----------+----------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------+----------+--------------+--------------+---------+-----------+----------+
| 26d8cf53 | RegionOn | keystone | identity | True | public | http://r |
| 020e4e2b | e | | | | | en3:5000 |
| a2c1ee0f | | | | | | /v3/ |
| a962137a | | | | | | |
| 721facd6 | RegionOn | keystone | identity | True | internal | http://r |
| 645b4efb | e | | | | | en3:5000 |
| b7fd6956 | | | | | | /v3/ |
| 42c156d4 | | | | | | |
| 91bf5a46 | RegionOn | keystone | identity | True | admin | http://r |
| 04e74aa2 | e | | | | | en3:3535 |
| bb229f96 | | | | | | 7/v3/ |
| 58bddc26 | | | | | | |
+----------+----------+--------------+--------------+---------+-----------+----------+
[root@ren3 ~]# openstack endpoint create --region RegionOne \
image public http://ren3:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | cfe4773e4a3b480e8bdb2062fbdcdd33 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a7cf08799d4b4b509530ae6c21453b08 |
| service_name | glance |
| service_type | image |
| url | http://ren3:9292 |
+--------------+----------------------------------+
[root@ren3 ~]# openstack endpoint create --region RegionOne \
image internal http://ren3:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 80f23b7a63c1416da77841119d5b5169 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a7cf08799d4b4b509530ae6c21453b08 |
| service_name | glance |
| service_type | image |
| url | http://ren3:9292 |
+--------------+----------------------------------+
[root@ren3 ~]# openstack endpoint create --region RegionOne \
image admin http://ren3:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | a80b58f2db9c4aea9b8748914d16d028 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a7cf08799d4b4b509530ae6c21453b08 |
| service_name | glance |
| service_type | image |
| url | http://ren3:9292 |
+--------------+----------------------------------+
[root@ren3 ~]# openstack endpoint list
+----------+----------+--------------+--------------+---------+-----------+----------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------+----------+--------------+--------------+---------+-----------+----------+
| 26d8cf53 | RegionOn | keystone | identity | True | public | http://r |
| 020e4e2b | e | | | | | en3:5000 |
| a2c1ee0f | | | | | | /v3/ |
| a962137a | | | | | | |
| 721facd6 | RegionOn | keystone | identity | True | internal | http://r |
| 645b4efb | e | | | | | en3:5000 |
| b7fd6956 | | | | | | /v3/ |
| 42c156d4 | | | | | | |
| 80f23b7a | RegionOn | glance | image | True | internal | http://r |
| 63c1416d | e | | | | | en3:9292 |
| a7784111 | | | | | | |
| 9d5b5169 | | | | | | |
| 91bf5a46 | RegionOn | keystone | identity | True | admin | http://r |
| 04e74aa2 | e | | | | | en3:3535 |
| bb229f96 | | | | | | 7/v3/ |
| 58bddc26 | | | | | | |
| a80b58f2 | RegionOn | glance | image | True | admin | http://r |
| db9c4aea | e | | | | | en3:9292 |
| 9b874891 | | | | | | |
| 4d16d028 | | | | | | |
| cfe4773e | RegionOn | glance | image | True | public | http://r |
| 4a3b480e | e | | | | | en3:9292 |
| 8bdb2062 | | | | | | |
| fbdcdd33 | | | | | | |
+----------+----------+--------------+--------------+---------+-----------+----------+
5、安装glance软件包
[root@ren3 ~]# yum install openstack-glance -y
6、编辑/etc/glance/glance-api.conf文件
(1)在[database]部分,配置数据库访问:
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
(2)在[keystone_authtoken]和[paste_deploy]部分,配置身份服务访问:
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS [paste_deploy]
# ...
flavor = keystone
(3)在[glance_store]部分,配置本地文件系统存储和图像文件的位置:
[glance_store]
# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
编辑好的配置文件:
[root@ren3 ~]# vim /etc/glance/glance-api.conf
[DEFAULT] [cors] [cors.subdomain] [database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ren3/glance [glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/ [image_format] [keystone_authtoken]
auth_uri = http://ren3:5000
auth_url = http://ren3:35357
memcached_servers = ren3:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance [matchmaker_redis]
[DEFAULT] [cors] [cors.subdomain] [database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ren3/glance [glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/ [image_format] [keystone_authtoken]
auth_uri = http://ren3:5000
auth_url = http://ren3:35357
memcached_servers = ren3:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance [matchmaker_redis] [oslo_concurrency] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_middleware] [oslo_policy] [paste_deploy]
flavor = keystone [profiler] [store_type_location_strategy] [task] [taskflow_executor]
7、编辑/etc/glance/glance- registration .conf文件
(1)在[database]部分,配置数据库访问:
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
(2)在[keystone_authtoken]和[paste_deploy]部分,配置身份服务访问:
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = GLANCE_PASS [paste_deploy]
# ...
flavor = keystone
编辑好的配置文件:
[root@ren3 ~]# vim /etc/glance/glance-registry.conf
[DEFAULT] [database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ren3/glance [keystone_authtoken]
auth_uri = http://ren3:5000
[DEFAULT] [database]
connection = mysql+pymysql://glance:GLANCE_DBPASS@ren3/glance [keystone_authtoken]
auth_uri = http://ren3:5000
auth_url = http://ren3:35357
memcached_servers = ren3:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance [matchmaker_redis] [oslo_messaging_amqp] [oslo_messaging_kafka] [oslo_messaging_notifications] [oslo_messaging_rabbit] [oslo_messaging_zmq] [oslo_policy] [paste_deploy]
flavor = keystone [profiler]
8、同步数据库
[root@ren3 ~]# su -s /bin/sh -c "glance-manage db_sync" glance
[root@ren3 ~]# mysql -u glance -pGLANCE_DBPASS MariaDB [(none)]> use glance; MariaDB [glance]> show tables;
+----------------------------------+
| Tables_in_glance |
+----------------------------------+
| alembic_version |
| 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 |
+----------------------------------+
21 rows in set (0.00 sec)
9、启动glance服务
[root@ren3 ~]# systemctl enable openstack-glance-api.service \
openstack-glance-registry.service
[root@ren3 ~]# systemctl start openstack-glance-api.service \
openstack-glance-registry.service
[root@ren3 ~]# systemctl status openstack-glance-api.service \
openstack-glance-registry.service |grep active | wc -l
2
[root@ren3 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:9191 *:*
LISTEN 0 128 192.168.11.3:5672 *:*
LISTEN 0 128 *:25672 *:*
LISTEN 0 128 192.168.11.3:3306 *:*
LISTEN 0 128 192.168.11.3:11211 *:*
LISTEN 0 128 127.0.0.1:11211 *:*
LISTEN 0 128 *:9292 *:*
LISTEN 0 128 *:4369 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 128 *:15672 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::5000 :::*
LISTEN 0 128 ::1:11211 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::35357 :::*
[root@ren3 ~]# netstat -anp |grep 9191
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 13084/python2
[root@ren3 ~]# firewall-cmd --list-ports
4369/tcp 5672/tcp 15672/tcp 25672/tcp 3306/tcp 11211/tcp 80/tcp 35357/tcp 5000/tcp
[root@ren3 ~]# firewall-cmd --add-port=9292/tcp
success
[root@ren3 ~]# firewall-cmd --add-port=9292/tcp --permanent
success
[root@ren3 ~]# firewall-cmd --add-port=9191/tcp --permanent
success
[root@ren3 ~]# firewall-cmd --add-port=9191/tcp
success
10、下载源镜像
网络源:
wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
[root@ren3 ~]# wget http://download2.yunwei.edu/shell/openstack_app.tar.gz
[root@ren3 ~]# ls
anaconda-ks.cfg openrc yum-repo.sh
--description openstack_app.tar.gz
[root@ren3 ~]# tar xvf openstack_app.tar.gz
[root@ren3 ~]# ls
anaconda-ks.cfg openrc openstack-ocata
--description openstack_app.tar.gz yum-repo.sh
[root@ren3 ~]# cd openstack-ocata/
[root@ren3 openstack-ocata]# ls
cirros-0.3.3-x86_64-disk.img openstack-compute-yilai
11、使用QCOW2磁盘格式、bare容器格式和公共可见性将镜像上传至image服务,以便所有项目都可以访问:
[root@ren3 openstack-ocata]# openstack image create "cirros" --file cirros-0.3.3-x86_64-disk.img --disk-format qcow2 --container-format bare --public
+------------------+---------------------------------------------------+
| Field | Value |
+------------------+---------------------------------------------------+
| checksum | 133eae9fb1c98f45894a4e60d8736619 |
| container_format | bare |
| created_at | 2019-10-12T06:12:16Z |
| disk_format | qcow2 |
| file | /v2/images/d8e9a113-edef- |
| | 41a6-9778-622edf76de39/file |
| id | d8e9a113-edef-41a6-9778-622edf76de39 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 640da7a471524d35a3efca2692b9555a |
| protected | False |
| schema | /v2/schemas/image |
| size | 13200896 |
| status | active |
| tags | |
| updated_at | 2019-10-12T06:12:16Z |
| virtual_size | None |
| visibility | public |
+------------------+---------------------------------------------------+
12、确认镜像是否上传成功
[root@ren3 openstack-ocata]# glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| d8e9a113-edef-41a6-9778-622edf76de39 | cirros |
+--------------------------------------+--------+
[root@ren3 openstack-ocata]# cd /var/lib/glance/images/
[root@ren3 images]# ls
d8e9a113-edef-41a6-9778-622edf76de39
或者使用openstack命令:
[root@ren3 images]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| d8e9a113-edef-41a6-9778-622edf76de39 | cirros | active |
+--------------------------------------+--------+--------+
云计算OpenStack核心组件---glance镜像服务(6)的更多相关文章
- 云计算openstack核心组件——glance— 镜像服务(6)
一.glance介绍: Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚 ...
- openstack核心组件——glance— 镜像服务(6)
云计算openstack核心组件——glance— 镜像服务(6) 一.glance介绍: Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像 ...
- OpenStack核心组件-glance镜像服务
1. glance介绍 Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚拟机镜像的metadata ...
- 5 云计算系列之glance镜像服务安装
preface 在上节中我们了解了keystone服务,下面就看看glance管理镜像的服务吧. glance组成 glance有两部分组成: glance-api 接受云系统镜像的创建,删除,读取请 ...
- 云计算openstack核心组件--glance-镜像服务(6)
glance做什么 OpenStack 由 Glance 提供 Image 服务 获取镜像位置 https://docs.openstack.org/image-guide/obtain-images ...
- OpenStack组件——Glance镜像服务
1.glance介绍 Glance是Openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等. Glance提供Restful API可以查询虚拟机镜像的metadata及 ...
- 云计算openstack核心组件——nova计算服务(7)
一.nova介绍: Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源.OpenStack 作为 IaaS 的云操作系统,虚拟机生命周期管理也就是通过 Nova ...
- 云计算OpenStack核心组件---nova计算服务(7)
一.nova介绍 Nova 是 OpenStack 最核心的服务,负责维护和管理云环境的计算资源.OpenStack 作为 IaaS 的云操作系统,虚拟机生命周期管理也就是通过 Nova 来实现的. ...
- 云计算OpenStack核心组件---neutron网络服务(8)*****
一.neutron介绍 1.Neutron概述 传统的网络管理方式很大程度上依赖于管理员手工配置和维护各种网络硬件设备:而云环境下的网络已经变得非常复杂,特别是在多租户场景里,用户随时都可能需要创建. ...
随机推荐
- 关于js中this的指向详细总结、分析
目录 this的指向详细剖析 当作为函数直接调用时, this => window 当作为构造函数时,this => 构造出的实例对象 当作为对象的方法调用时,this => 调用方 ...
- MySQL提升笔记(3)日志文件详解
在MySQL数据库和InnoDB存储引擎中,有很多种文件,如:参数文件.日志文件.socket文件.pid文件.MySQL表结构文件.存储引擎文件. 本节重点关注日志文件,MySQL的复制.事务等重要 ...
- matlab mashgrid 函数
meshgrid 有三种语法,用来生成三维网格矩阵或二维网格矩阵 [X,Y] = meshgrid(x,y) , x和y 都是一维数组,如x=[1:3]; y= [4:5]; 则生成的 X 和 Y 都 ...
- 为什么 Spring Boot 2.3.0 放弃Maven最终拥抱Gradle
在 2.3.0 中对 Spring Boot 进行了相当重大的更改,这是使用 Gradle 而非 Maven 构建的项目的第一个版本. Spring 的每个项目都独立的项目组在开发运营,在用户最常使用 ...
- Java编程语言学习01-编写第1个Java程序
JVM/JRE/JDK JVMJava虚拟机(Java Virtual Machine)它是运行所有Java程序的虚拟计算机有的java程序会首先被编译为.class的类文件,这种类文件可以在虚拟机上 ...
- 开坑:mysql相关问题
一. 先过滤后连表和先连表后在mysql中选择的哪一种? 二. left join 和inner join使用场景有什么区别? 三. 第二个问题的衍生问题:left join中where 条件使用对n ...
- 构建基于表单配置的 Jenkins 测试项目(接口、UI、APP、Jmeter)
1. 第一个 hello world 项目 2. 构建自动触发的项目(接口测试) 1)新建测试项目(执行测试脚本) 2)新建 Maven 打包项目 3)手动执行构建 4)修改 Web 工程代码并 pu ...
- golang channel的行为
1. 读nil的channel是永远阻塞的.关闭nil的channel会造成panic. 2. closed channel的行为: (1)向close的channel发消息会panic,关闭一个已经 ...
- P7518 & 省选联考2021 宝石
这是一篇极其简单连像我这样省三参加不了省选的蒟蒻都能看懂的题解 前置知识: 倍增LCA 二分 栈 题意 PS:这是一篇完全面向初学者的题解,会非常细,大佬请无视 题目传送门 没有思路的时候, 我们往 ...
- Social engineering tookit 钓鱼网站
目录 Set 钓鱼攻击 网站克隆 Set Set(Social engineering tookit)是一款社会工程学工具,该工具用的最多的就是用来制作钓鱼网站. Kali中自带了该工具. 钓鱼攻击 ...