glance对接cinder后端存储

glance对接cinder后端存储

案例准备

1.规划节点
IP 主机名 节点
192.168.100.10 controller Openstack Controller节点
2.基础准备

使用自行搭建的Openstack平台中修改相关参数,使glance可以使用cinder作为后端存储,将镜像存储于cinder卷中.

案例实施

(1)修改文件
修改glance配置文件
[root@controller ~]# vi /etc/glance/glance-api.conf 

#show_multiple_locations = false
改为
show_multiple_locations = true

stores = file,http,
改为
stores = file,http,cinder
# 重启服务
[root@controller ~]# systemctl restart openstack-glance-*
修改cinder配置文件
[root@controller ~]# vi /etc/cinder/cinder.conf 
# 使用cinder服务通过克隆创建镜像的新卷的配置是cinder
#allowed_direct_url_schemes =
改为
allowed_direct_url_schemes = cinder

#image_upload_use_internal_tenant = false
改为
image_upload_use_internal_tenant = True
# 重启服务
[root@controller ~]# systemctl restart openstack-cinder*
(2)创建镜像和卷
[root@controller ~]# openstack image create --disk-format qcow2 --container-format bare --file cirros-0.3.4-x86_64-disk.img cirros-image
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                                                                                                                                                           |
| container_format | bare                                                                                                                                                                                       |
| created_at       | 2023-02-09T10:29:14Z                                                                                                                                                                       |
| disk_format      | qcow2                                                                                                                                                                                      |
| file             | /v2/images/c6578213-6e25-487d-a1a2-2a8e3fa57d50/file                                                                                                                                       |
| id               | c6578213-6e25-487d-a1a2-2a8e3fa57d50                                                                                                                                                       |
| min_disk         | 0                                                                                                                                                                                          |
| min_ram          | 0                                                                                                                                                                                          |
| name             | cirros-image                                                                                                                                                                               |
| owner            | 78b8a589a6c746379f720b5664f21793                                                                                                                                                           |
| properties       | os_hash_algo='sha512', os_hash_value='1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f739d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2', os_hidden='False' |
| protected        | False                                                                                                                                                                                      |
| schema           | /v2/schemas/image                                                                                                                                                                          |
| size             | 13287936                                                                                                                                                                                   |
| status           | active                                                                                                                                                                                     |
| tags             |                                                                                                                                                                                            |
| updated_at       | 2023-02-09T10:29:14Z                                                                                                                                                                       |
| virtual_size     | None                                                                                                                                                                                       |
| visibility       | shared                                                                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~]# openstack image list
+--------------------------------------+---------------+--------+
| ID                                   | Name          | Status |
+--------------------------------------+---------------+--------+
| c6578213-6e25-487d-a1a2-2a8e3fa57d50 | cirros-image  | active |
+--------------------------------------+---------------+--------+
[root@controller ~]# openstack volume create --size 2 cirros-cinder
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| attachments         | []                                   |
| availability_zone   | nova                                 |
| bootable            | false                                |
| consistencygroup_id | None                                 |
| created_at          | 2023-02-09T10:31:08.000000           |
| description         | None                                 |
| encrypted           | False                                |
| id                  | 43598696-5a30-4708-96e0-b47d2bf42f80 |
| migration_status    | None                                 |
| multiattach         | False                                |
| name                | cirros-cinder                        |
| properties          |                                      |
| replication_status  | None                                 |
| size                | 2                                    |
| snapshot_id         | None                                 |
| source_volid        | None                                 |
| status              | creating                             |
| type                | None                                 |
| updated_at          | None                                 |
| user_id             | 7a6864328e63463daba4bb72dcb1faf3     |
+---------------------+--------------------------------------+
[root@controller ~]# openstack volume list
+--------------------------------------+---------------+-----------+------+-------------+
| ID                                   | Name          | Status    | Size | Attached to |
+--------------------------------------+---------------+-----------+------+-------------+
| 43598696-5a30-4708-96e0-b47d2bf42f80 | cirros-cinder | available |    2 |             |
+--------------------------------------+---------------+-----------+------+-------------+

[root@controller ~]# glance location-add c6578213-6e25-487d-a1a2-2a8e3fa57d50 --url cinder://43598696-5a30-4708-96e0-b47d2bf42f80
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6                                                 |
| container_format | bare                                                                             |
| created_at       | 2023-02-09T10:29:14Z                                                             |
| disk_format      | qcow2                                                                            |
| file             | /v2/images/c6578213-6e25-487d-a1a2-2a8e3fa57d50/file                             |
| id               | c6578213-6e25-487d-a1a2-2a8e3fa57d50                                             |
| locations        | [{"url": "file:///var/lib/glance/images/c6578213-6e25-487d-a1a2-2a8e3fa57d50",   |
|                  | "metadata": {}}, {"url": "cinder://43598696-5a30-4708-96e0-b47d2bf42f80",        |
|                  | "metadata": {}}]                                                                 |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | cirros-image                                                                     |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f7 |
|                  | 39d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2                                 |
| os_hidden        | False                                                                            |
| owner            | 78b8a589a6c746379f720b5664f21793                                                 |
| protected        | False                                                                            |
| schema           | /v2/schemas/image                                                                |
| size             | 13287936                                                                         |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2023-02-09T10:38:36Z                                                             |
| virtual_size     | None                                                                             |
| visibility       | shared                                                                           |
+------------------+----------------------------------------------------------------------------------+

你可能感兴趣的:(openstack,运维,开发语言,openstack)