一,Glance 介绍 1.什么是Glance glance即image service(镜像服务),是为虚拟机的创建提供镜像服务 2. Glance服务组成 1 Image Service的功能是管理Image,让用户能够发现、获取和保存Image。 2 在Openstack中,提供Image Servce的是Glance,其具体功能如下: 提供REST API让用户能够查询和获取image的元数据和image本身。 支持多种方式存储image,包括普通的文件系统,Swift、Amazon S3等。 对Instance执行Snapshot创建新的image。 镜像格式 3. 虚拟机镜像文件磁盘格式 镜像文件容器格式 4.镜像状态 镜像从上传到可识别的几个状态 镜像在上载完成后的状态 5.访问权限 Public(公共的):可以被所有的项目使用 Private (私有的):只有被镜像所有者所在的项目使用 Shared (共享的):一 个非共有的镜像可以共享给其他项目,这是通过项目成员(member-*) 操作来实现 Protected (受保护的):这种镜像不能被删除
6,架构 二,部署 1、创建数据库实例和数据库用户
[root@ct ~]
MariaDB [(none)]> CREATE DATABASE glance;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
2、创建用户、修改配置文件 2.1、创建OpenStack的Glance用户 创建用户前,需要首先执行管理员环境变量脚本(此处已经在~/.bashrc 中定义过了)
[root@ct ~]
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 401ece6ae6a84306a6c7773449cbd2c6 |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@ct ~]
[root@ct ~]
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 7504ed8e58994340b85307ba66addf51 |
| name | glance |
| type | image |
+-------------+----------------------------------+
[root@ct ~]
+----------------------------------+----------+----------+
| ID | Name | Type |
+----------------------------------+----------+----------+
| 7504ed8e58994340b85307ba66addf51 | glance | image |
| ef633d69afdb401b9f39fb36af90db06 | keystone | identity |
+----------------------------------+----------+----------+
2.2,创建镜像服务 API 端点 OpenStack使用三种API端点代表三种服务:admin、internal、public
[root@ct ~]
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 62c305879da1447391bb94a2ec816a26 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7504ed8e58994340b85307ba66addf51 |
| service_name | glance |
| service_type | image |
| url | http://ct:9292 |
+--------------+----------------------------------+
[root@ct ~]
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 87715cc052c14c258ebbf25cb23da445 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7504ed8e58994340b85307ba66addf51 |
| service_name | glance |
| service_type | image |
| url | http://ct:9292 |
+--------------+----------------------------------+
[root@ct ~]
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 3a72c904739843a985b2461cdf9f92ea |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7504ed8e58994340b85307ba66addf51 |
| service_name | glance |
| service_type | image |
| url | http://ct:9292 |
+--------------+----------------------------------+
3、安装 openstack-glance 软件包 3.1.安装并修改glance配置文件,两个配置文件: /etc/glance/glance-api.conf /etc/glance/glance-registry.conf 安装 openstack-glance 软件包。
[root@ct ~]
3.2,修改glance配置文件,glance有两个配置文件:
/etc/glance/glance-api.conf /etc/glance/glance-registry.conf
[root@ct ~]
[root@ct ~]
3.3,添加glance-api.conf配置
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct ~]
[root@ct glance]
[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
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]
[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_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
4.初始化数据库
su -s /bin/sh -c "glance-manage db_sync" glance
5.开启glance服务
[root@ct ~]
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 ~]
[root@ct ~]
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 51179/python2
[root@ct ~]
6.赋予glance服务权限
[root@ct ~]
[root@ct ~]
总用量 0
drwxr-x---. 2 glance glance 6 8月 26 16:16 images
[root@ct ~]
7.镜像导入
[root@ct ~]
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2021-08-26T08:23:14Z |
| disk_format | qcow2 |
| file | /v2/images/bbdc00d8-e2ea-4d44-8aae-47aa80c6322f/file |
| id | bbdc00d8-e2ea-4d44-8aae-47aa80c6322f |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 06bda3fc6abd44b186f168002107c832 |
| 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 | 2021-08-26T08:23:14Z |
| virtual_size | None |
| visibility | public |
+------------------+-------------------------------------------
验证,查看镜像的两种方式
[root@ct ~]
[root@ct ~]# glance image-list
|