赞
踩
节点规划见表1。
表1 节点规划
IP | 主机名 | 节点 |
---|---|---|
10.24.195.98 | controller | IaaS-allinone |
使用平台提供的OpenStack平台作为实验节点。
(1)下载CirrOS镜像文件
CirrOS是一个极小的云操作系统,可以使用这个小的操作系统来进行Glance服务组件的操作练习。将提供的cirros-0.3.4-x86_64-disk.img镜像上传到controller节点的root目录下面。
[root@controller ~]# curl -O http://mirrors.douxuedu.com/newcloud/cirros-0.3.4-x86_64-disk.img
[root@controller ~]# ls
…
cirros-0.3.4-x86_64-disk.img
将镜像上传至controller节点后,通过file命令查看镜像文件信息。
[root@controller ~]# file cirros-0.3.4-x86_64-disk.img
cirros-0.3.4-x86_64-disk.img: QEMU QCOW Image (v2), 41126400 bytes
(2)创建镜像
通过命令创建镜像,命令的格式如下:
[root@controller ~]# glance help image-create
usage: glance image-create [--architecture <ARCHITECTURE>]
[--protected [True|False]] [--name <NAME>]
[--instance-uuid <INSTANCE_UUID>]
[--min-disk <MIN_DISK>] [--visibility <VISIBILITY>]
[--kernel-id <KERNEL_ID>]
[--tags <TAGS> [<TAGS> ...]]
[--os-version <OS_VERSION>]
[--disk-format <DISK_FORMAT>]
[--os-distro <OS_DISTRO>] [--id <ID>]
[--owner <OWNER>] [--ramdisk-id <RAMDISK_ID>]
[--min-ram <MIN_RAM>]
[--container-format <CONTAINER_FORMAT>]
[--property <key=value>] [--file <FILE>]
[--progress]
参数说明:
● --disk-format:镜像格式。
● --container-format:镜像在其他项目中可见性。
● --progress:显示上传镜像的进度。
● --file:选择本地镜像文件。
● --name:上传后镜像的名称。
使用镜像cirros-0.3.4-x86_64-disk.img通过命令上传镜像至OpenStack中。
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# glance image-create --name cirros-0.3.4 --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img
[=============================>] 100%
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed
2d6f919ca35d9046d4 |
| | 37c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:15:29Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
(1)查看镜像
通过命令可以在OpenStack平台中查看当前Glance中所上传的镜像名称。具体命令如下:
[root@controller ~]# glance image-list
+--------------------------------------+--------------+
| ID | Name |
+--------------------------------------+--------------+
| 32a2513c-e5ba-438b-a5ee-63c35c03b284 | cirros-0.3.4 |
+--------------------------------------+--------------+
也可以使用命令查看镜像的详细信息。具体命令如下:
[root@controller ~]# glance image-show 32a2513c-e5ba-438b-a5ee-63c35c03b284
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d
6f919ca35d9046d4 |
| | 37c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:15:29Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
(2)修改镜像
可以使用glance image-update更新镜像信息,命令的格式如下:
[root@controller ~]# glance help image-update
usage: glance image-update [--architecture <ARCHITECTURE>]
[--protected [True|False]] [--name <NAME>]
[--instance-uuid <INSTANCE_UUID>]
[--min-disk <MIN_DISK>] [--visibility <VISIBILITY>]
[--kernel-id <KERNEL_ID>]
[--os-version <OS_VERSION>]
[--disk-format <DISK_FORMAT>]
[--os-distro <OS_DISTRO>] [--owner <OWNER>]
[--ramdisk-id <RAMDISK_ID>] [--min-ram <MIN_RAM>]
[--container-format <CONTAINER_FORMAT>]
[--property <key=value>] [--remove-property key]
<IMAGE_ID>
参数说明:
● --min-disk:镜像启动最小硬盘大小。
● --name:镜像名称。
● --disk-format:镜像格式。
● --min-ram:镜像启动最小内存大小。
● --container-format:镜像在项目中可见性。
如果需要改变镜像启动硬盘最低要求值(min-disk)1G,min-disk默认单位为G。使用glance image-update更新镜像信息操作如下:
[root@controller ~]# glance image-update --min-disk=1 32a2513c-e5ba-438b-a5ee-63c35c03b284
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 1 |
| min_ram | 0 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed
2d6f919ca35d9046d4 |
| | 37c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:16:59Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
也可以使用命令更新镜像启动内存最低要求值(min-ram)为1G,min-ram默认单位为M。使用glance image-update更新镜像信息操作如下:
[root@controller ~]# glance image-update --min-ram=1024 32a2513c-e5ba-438b-a5ee-63c35c03b284
+------------------+--------------------------------------------------------------------+
| Property | Value |
+------------------+--------------------------------------------------------------------+
| checksum | f8ab98ff5e73ebab884d80c9dc9c7290 |
| container_format | bare |
| created_at | 2022-02-10T03:15:29Z |
| disk_format | qcow2 |
| id | 32a2513c-e5ba-438b-a5ee-63c35c03b284 |
| min_disk | 1 |
| min_ram | 1024 |
| name | cirros-0.3.4 |
| os_hash_algo | sha512 |
| os_hash_value | f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2
d6f919ca35d9046d4 |
| | 37c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232 |
| os_hidden | False |
| owner | 1776912d52a7444d8b2d09eb86e8d1d9 |
| protected | False |
| size | 13267968 |
| status | active |
| tags | [] |
| updated_at | 2022-02-10T03:17:21Z |
| virtual_size | Not available |
| visibility | shared |
+------------------+--------------------------------------------------------------------+
(3)删除镜像
可以使用glance image-delete删除上传至OpenStack平台中的镜像,使用命令格式如下:
[root@controller ~]# glance help image-delete
usage: glance image-delete <IMAGE_ID> [<IMAGE_ID> ...]
Delete specified image.
Positional arguments:
<IMAGE_ID> ID of image(s) to delete.
Run `glance --os-image-api-version 1 help image-delete` for v1 help
只需要在命令后跟上镜像ID即可。命令如下:
[root@controller ~]# glance image-delete 32a2513c-e5ba-438b-a5ee-63c35c03b284
[root@controller ~]# glance image-list
+--------------------------------------+-------------------------------+
| ID | Name |
+--------------------------------------+-------------------------------+
+--------------------------------------+-------------------------------+
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。