openstack glance 运维命令

简介: Glance是OpenStack的镜像服务,负责虚拟机镜像的查找、注册和检索,不存储镜像但保存到多种后端存储。

Glance是OpenStack镜像服务组件,负责虚拟机镜像的查找、注册和检索。简单来说,Glance就是我们用来查找、注册和检索虚拟机镜像的地方。这个镜像并不是我们常见的操作系统的ISO镜像,而是特定制作的,用于产生虚拟机系统盘的模板。Glance提供RESTful API来查询虚拟机镜像的metadata及获取镜像。值得注意的是,Glance并不负责镜像的存储,而是将镜像保存到多种后端存储上,比如简单的文件存储或者对象存储。

创建一个centos7.2的镜像

[root@localhost ~(keystone_admin)]# ls
anaconda-ks.cfg  Desktop    Downloads         keystonerc_demo  original-ks.cfg                        Pictures  Templates
CentOS7.2.qcow2  Documents  keystonerc_admin  Music            packstack-answers-20240318-231803.txt  Public    Videos
[root@localhost ~(keystone_admin)]# glance image-create --name "centos7.2" --disk-format  qcow2 --container-format bare --progress  < CentOS7.2.qcow2
[=============================>] 100%
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | ad11feb5af04f08d74ff6f4cb14527fa                                                 |
| container_format | bare                                                                             |
| created_at       | 2024-03-22T06:48:07Z                                                             |
| disk_format      | qcow2                                                                            |
| id               | 1f9b092d-68fa-4856-a61c-cf51330789ff                                             |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | centos7.2                                                                        |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 113e5609932b8c161fd4717896c4583f35efeeacc3b8c44380acc4381cc2a1d4121b38a03b03815f |
|                  | 1868e008e1e30d03b9cf5a3ec6129987f20f33fb77d27bad                                 |
| os_hidden        | False                                                                            |
| owner            | 009a94428fb84a0db16aa4a1adab9a35                                                 |
| protected        | False                                                                            |
| size             | 1373306880                                                                       |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2024-03-22T06:48:18Z                                                             |
| virtual_size     | Not available                                                                    |
| visibility       | shared                                                                           |
+------------------+----------------------------------------------------------------------------------+
[root@localhost ~(keystone_admin)]#

列出所有的镜像


[root@localhost ~(keystone_admin)]# glance image-list 
+--------------------------------------+-----------+
| ID                                   | Name      |
+--------------------------------------+-----------+
| 1f9b092d-68fa-4856-a61c-cf51330789ff | centos7.2 |
| 112198be-3c42-43e8-ba57-5cc87d651876 | cirros    |
+--------------------------------------+-----------+
[root@localhost ~(keystone_admin)]#

查看某个镜像详情
名称用不了用ID号


[root@localhost ~(keystone_admin)]# glance image-show centos7.2
HTTP 404 Not Found: No image found with ID centos7.2
[root@localhost ~(keystone_admin)]# glance image-show  1f9b092d-68fa-4856-a61c-cf51330789ff 
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | ad11feb5af04f08d74ff6f4cb14527fa                                                 |
| container_format | bare                                                                             |
| created_at       | 2024-03-22T06:48:07Z                                                             |
| disk_format      | qcow2                                                                            |
| id               | 1f9b092d-68fa-4856-a61c-cf51330789ff                                             |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | centos7.2                                                                        |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 113e5609932b8c161fd4717896c4583f35efeeacc3b8c44380acc4381cc2a1d4121b38a03b03815f |
|                  | 1868e008e1e30d03b9cf5a3ec6129987f20f33fb77d27bad                                 |
| os_hidden        | False                                                                            |
| owner            | 009a94428fb84a0db16aa4a1adab9a35                                                 |
| protected        | False                                                                            |
| size             | 1373306880                                                                       |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2024-03-22T06:48:18Z                                                             |
| virtual_size     | Not available                                                                    |
| visibility       | shared                                                                           |
+------------------+----------------------------------------------------------------------------------+

修改镜像指定大小信息

[root@localhost ~(keystone_admin)]# glance image-update --min-disk=15 1f9b092d-68fa-4856-a61c-cf51330789ff
+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | ad11feb5af04f08d74ff6f4cb14527fa                                                 |
| container_format | bare                                                                             |
| created_at       | 2024-03-22T06:48:07Z                                                             |
| disk_format      | qcow2                                                                            |
| id               | 1f9b092d-68fa-4856-a61c-cf51330789ff                                             |
| min_disk         | 15                                                                               |
| min_ram          | 0                                                                                |
| name             | centos7.2                                                                        |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 113e5609932b8c161fd4717896c4583f35efeeacc3b8c44380acc4381cc2a1d4121b38a03b03815f |
|                  | 1868e008e1e30d03b9cf5a3ec6129987f20f33fb77d27bad                                 |
| os_hidden        | False                                                                            |
| owner            | 009a94428fb84a0db16aa4a1adab9a35                                                 |
| protected        | False                                                                            |
| size             | 1373306880                                                                       |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2024-03-22T07:01:37Z                                                             |
| virtual_size     | Not available                                                                    |
| visibility       | shared                                                                           |
+------------------+----------------------------------------------------------------------------------+

删除镜像


[root@localhost ~(keystone_admin)]# glance  image-list 
+--------------------------------------+-----------+
| ID                                   | Name      |
+--------------------------------------+-----------+
| 1f9b092d-68fa-4856-a61c-cf51330789ff | centos7.2 |
| 112198be-3c42-43e8-ba57-5cc87d651876 | cirros    |
+--------------------------------------+-----------+
[root@localhost ~(keystone_admin)]# 
[root@localhost ~(keystone_admin)]# glance image-delete   1f9b092d-68fa-4856-a61c-cf51330789ff 
[root@localhost ~(keystone_admin)]# glance  image-list 
+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 112198be-3c42-43e8-ba57-5cc87d651876 | cirros |
+--------------------------------------+--------+
[root@localhost ~(keystone_admin)]#

openstack 命令执行创建镜像

[root@localhost ~(keystone_admin)]# openstack image  create centos7 --disk-format qcow2 --container-format bare --file CentOS7.2.qcow2
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | ad11feb5af04f08d74ff6f4cb14527fa                                                                                                                                                           |
| container_format | bare                                                                                                                                                                                       |
| created_at       | 2024-03-22T07:14:10Z                                                                                                                                                                       |
| disk_format      | qcow2                                                                                                                                                                                      |
| file             | /v2/images/1d83e2a5-88c0-40c1-a4f7-2cbb72387b6b/file                                                                                                                                       |
| id               | 1d83e2a5-88c0-40c1-a4f7-2cbb72387b6b                                                                                                                                                       |
| min_disk         | 0                                                                                                                                                                                          |
| min_ram          | 0                                                                                                                                                                                          |
| name             | centos7                                                                                                                                                                                    |
| owner            | 009a94428fb84a0db16aa4a1adab9a35                                                                                                                                                           |
| properties       | os_hash_algo='sha512', os_hash_value='113e5609932b8c161fd4717896c4583f35efeeacc3b8c44380acc4381cc2a1d4121b38a03b03815f1868e008e1e30d03b9cf5a3ec6129987f20f33fb77d27bad', os_hidden='False' |
| protected        | False                                                                                                                                                                                      |
| schema           | /v2/schemas/image                                                                                                                                                                          |
| size             | 1373306880                                                                                                                                                                                 |
| status           | active                                                                                                                                                                                     |
| tags             |                                                                                                                                                                                            |
| updated_at       | 2024-03-22T07:14:20Z                                                                                                                                                                       |
| virtual_size     | None                                                                                                                                                                                       |
| visibility       | shared                                                                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@localhost ~(keystone_admin)]#

openstack 命令修改磁盘大小、查看镜像列表

[root@localhost ~(keystone_admin)]# openstack image set  --min-disk=15 centos7
[root@localhost ~(keystone_admin)]# openstack image show  centos7
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum         | ad11feb5af04f08d74ff6f4cb14527fa                                                                                                                                                           |
| container_format | bare                                                                                                                                                                                       |
| created_at       | 2024-03-22T07:14:10Z                                                                                                                                                                       |
| disk_format      | qcow2                                                                                                                                                                                      |
| file             | /v2/images/1d83e2a5-88c0-40c1-a4f7-2cbb72387b6b/file                                                                                                                                       |
| id               | 1d83e2a5-88c0-40c1-a4f7-2cbb72387b6b                                                                                                                                                       |
| min_disk         | 15                                                                                                                                                                                         |
| min_ram          | 0                                                                                                                                                                                          |
| name             | centos7                                                                                                                                                                                    |
| owner            | 009a94428fb84a0db16aa4a1adab9a35                                                                                                                                                           |
| properties       | os_hash_algo='sha512', os_hash_value='113e5609932b8c161fd4717896c4583f35efeeacc3b8c44380acc4381cc2a1d4121b38a03b03815f1868e008e1e30d03b9cf5a3ec6129987f20f33fb77d27bad', os_hidden='False' |
| protected        | False                                                                                                                                                                                      |
| schema           | /v2/schemas/image                                                                                                                                                                          |
| size             | 1373306880                                                                                                                                                                                 |
| status           | active                                                                                                                                                                                     |
| tags             |                                                                                                                                                                                            |
| updated_at       | 2024-03-22T07:15:56Z                                                                                                                                                                       |
| virtual_size     | None                                                                                                                                                                                       |
| visibility       | shared                                                                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@localhost ~(keystone_admin)]# 
[root@localhost ~(keystone_admin)]# openstack image list
+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| 1d83e2a5-88c0-40c1-a4f7-2cbb72387b6b | centos7 | active |
| 112198be-3c42-43e8-ba57-5cc87d651876 | cirros  | active |
+--------------------------------------+---------+--------+
目录
相关文章
|
24天前
|
运维 监控 网络协议
|
10天前
|
缓存 运维 监控
【运维必备知识】Linux系统平均负载与top、uptime命令详解
系统平均负载是衡量Linux服务器性能的关键指标之一。通过使用 `top`和 `uptime`命令,可以实时监控系统的负载情况,帮助运维人员及时发现并解决潜在问题。理解这些工具的输出和意义是确保系统稳定运行的基础。希望本文对Linux系统平均负载及相关命令的详细解析能帮助您更好地进行系统运维和性能优化。
29 3
|
3月前
|
图形学 开发者 存储
超越基础教程:深度拆解Unity地形编辑器的每一个隐藏角落,让你的游戏世界既浩瀚无垠又细节满满——从新手到高手的全面技巧升级秘籍
【8月更文挑战第31天】Unity地形编辑器是游戏开发中的重要工具,可快速创建复杂多变的游戏环境。本文通过比较不同地形编辑技术,详细介绍如何利用其功能构建广阔且精细的游戏世界,并提供具体示例代码,展示从基础地形绘制到植被与纹理添加的全过程。通过学习这些技巧,开发者能显著提升游戏画面质量和玩家体验。
151 3
|
3月前
|
SQL 运维 监控
DM日常运维高频命令总结
DM日常运维高频命令总结
101 3
|
3月前
|
运维 Oracle 前端开发
Oracle 11g RAC集群日常运维命令总结
Oracle 11g RAC集群日常运维命令总结
96 2
|
3月前
|
SQL 运维 调度
DM8日常运维命令总结(二)
DM8日常运维命令总结(二)
88 2
|
3月前
|
SQL 运维 Oracle
入门级Oracle 11g日常运维命令总结
入门级Oracle 11g日常运维命令总结
121 1
|
3月前
|
SQL 运维 数据库
DM8日常运维必须要懂的几个命令
DM8日常运维必须要懂的几个命令
73 1
|
3月前
|
移动开发 运维 网络协议
运维必备 | Linux netstat命令详解
运维必备 | Linux netstat命令详解
100 8
|
3月前
|
运维 Rust 监控
Linux高效运维必备:fd命令深度解析,文件描述符管理从此得心应手!
【8月更文挑战第23天】本文介绍了一款名为fd的命令行工具,该工具基于Rust语言开发,旨在以更直观的语法和更快的速度替代传统的`find`命令。通过本文,您可以了解到如何安装fd以及一些基本用法示例,比如使用正则表达式匹配文件名、排除特定目录等。此外,文章还展示了如何结合`ps`和`lsof`命令来查找特定文件并显示其文件描述符,从而帮助您更好地管理和监控Linux系统中的文件与进程。
130 0