
OpenStack——glance镜像管理
Glance介绍
Glance 是 OpenStack 负责 管理虚拟机的镜像
管理镜像
查看镜像
[root@controller ~]# glance image-list
+--------------------------------------+--------------+
| ID | Name |
+--------------------------------------+--------------+
| 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4 | cirros |
| 96d10cf1-8ae5-4950-ac91-e1d30caac147 | cirros_0.3.5 |
+--------------------------------------+--------------+
[root@controller ~]# openstack image list
+--------------------------------------+--------------+--------+
| ID | Name | Status |
+--------------------------------------+--------------+--------+
| 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4 | cirros | active |
| 96d10cf1-8ae5-4950-ac91-e1d30caac147 | cirros_0.3.5 | active |
+--------------------------------------+--------------+--------+
查看镜像的详细信息:
[root@controller ~]# glance image-show cirros
HTTP 404 Not Found: No image found with ID cirros
[root@controller ~]# glance image-show 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4
+------------------+----------------------------------------------------------------------------------+
| Property | Value |
+------------------+----------------------------------------------------------------------------------+
| checksum | b874c39491a2377b8490f5f1e89761a4 |
| container_format | bare |
| created_at | 2024-10-13T06:04:57Z |
| disk_format | qcow2 |
| id | 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| os_hash_algo | sha512 |
| os_hash_value | 6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe3622 |
| | 5e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869 |
| os_hidden | False |
| owner | b47ea8448d9344b995deed86f68a8560 |
| protected | False |
| size | 16300544 |
| status | active |
| tags | [] |
| updated_at | 2024-10-13T06:05:01Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+----------------------------------------------------------------------------------+
[root@controller ~]# openstack image show 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | b874c39491a2377b8490f5f1e89761a4 |
| container_format | bare |
| created_at | 2024-10-13T06:04:57Z |
| disk_format | qcow2 |
| file | /v2/images/7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4/file |
| id | 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | b47ea8448d9344b995deed86f68a8560 |
| properties | os_hash_algo='sha512', os_hash_value='6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 16300544 |
| status | active |
| tags | |
| updated_at | 2024-10-13T06:05:01Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~]# openstack image show cirros
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | b874c39491a2377b8490f5f1e89761a4 |
| container_format | bare |
| created_at | 2024-10-13T06:04:57Z |
| disk_format | qcow2 |
| file | /v2/images/7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4/file |
| id | 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | b47ea8448d9344b995deed86f68a8560 |
| properties | os_hash_algo='sha512', os_hash_value='6b813aa46bb90b4da216a4d19376593fa3f4fc7e617f03a92b7fe11e9a3981cbe8f0959dbebe36225e5f53dc4492341a4863cac4ed1ee0909f3fc78ef9c3e869', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 16300544 |
| status | active |
| tags | |
| updated_at | 2024-10-13T06:05:01Z |
| virtual_size | None |
| visibility | shared |
+------------------+------------------------
- 以上指令可以看出,
glance
命令可以查看镜像详情只能使用 id 而不能使用 名称,openstack image
却可以 glance
与openstack image
最大的区别在于,glance
的信息比较简略
修改镜像
修改镜像的命令为:glacne image-update
参数说明:
- --min-disk:镜像启动最小硬盘大小。
- --name:镜像名称。
- --disk-format:镜像格式。
- --min-ram:镜像启动最小内存大小。
- --container-format:镜像在项目中可见性。
如:如果需要改变镜像启动硬盘最低要求值(min-disk)1G,min-disk默认单位为G。使用glance image-update更新镜像信息操作如下:
glance image-update --min-disk=1 96d10cf1-8ae5-4950-ac91-e1d30caac147
+------------------+----------------------------------------------------------------------------------+
| Property | Value |
+------------------+----------------------------------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2024-10-13T06:11:54Z |
| disk_format | qcow2 |
| id | 96d10cf1-8ae5-4950-ac91-e1d30caac147 |
| min_disk | 1 |
| min_ram | 0 |
| name | cirros_0.3.5 |
| os_hash_algo | sha512 |
| os_hash_value | 1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f7 |
| | 39d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2 |
| os_hidden | False |
| owner | b47ea8448d9344b995deed86f68a8560 |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2024-10-13T23:03:26Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+----------------------------------------------------------------------------------+
如果需要改变镜像内存最低要求值(min-ram)1G,min-ram。使用glance image-update更新镜像信息操作如下:
glance image-update --min-ram=1 96d10cf1-8ae5-4950-ac91-e1d30caac147
+------------------+----------------------------------------------------------------------------------+
| Property | Value |
+------------------+----------------------------------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2024-10-13T06:11:54Z |
| disk_format | qcow2 |
| id | 96d10cf1-8ae5-4950-ac91-e1d30caac147 |
| min_disk | 1 |
| min_ram | 1 |
| name | cirros_0.3.5 |
| os_hash_algo | sha512 |
| os_hash_value | 1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f7 |
| | 39d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2 |
| os_hidden | False |
| owner | b47ea8448d9344b995deed86f68a8560 |
| protected | False |
| size | 13287936 |
| status | active |
| tags | [] |
| updated_at | 2024-10-13T23:03:45Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+----------------------------------------------------------------------------------+
删除镜像
glance image-delete id
[root@controller ~]# glance image-list
+--------------------------------------+--------------+
| ID | Name |
+--------------------------------------+--------------+
| 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4 | cirros |
| 96d10cf1-8ae5-4950-ac91-e1d30caac147 | cirros_0.3.5 |
+--------------------------------------+--------------+
[root@controller ~]# glance image-delete 7ff6f9fa-44e3-4d76-9adf-c02fb3e2a5d4
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 zxb
评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果