OpenStack镜像服务基本操作

Posted djlsunshine

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OpenStack镜像服务基本操作相关的知识,希望对你有一定的参考价值。

 查询Glance服务状态

#glance-control all status

[[email protected] ~]# glance-control all status
glance-api (pid 2074) is running...
glance-registry (pid 2344) is running...
glance-scrubber is stopped

 

查询glance-api版本

# glance-api --version

[[email protected] ~]# glance-api --version
2014.1.3

查询glance-control版本

# glance-control --version

[[email protected] ~]# glance-control --version
2014.1.3

下面的命令作用是启动相关服务,并设置为开机启动。

# service openstack-glance-api start

# service openstack-glance-registry start

# chkconfig openstack-glance-api on

# chkconfig openstack-glance-registry on

下载CirrOS镜像文件

# mkdir /tmp/images

# cd /tmp/images/

# wget http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img

查看文件信息

# file cirros-0.3.4-x86_64-disk.img

[[email protected] ~]# file cirros-0.3.4-x86_64-disk.img
cirros-0.3.4-x86_64-disk.img: Qemu Image, Format: Qcow , Version: 2

使用命令行创建镜像

# glance image-create --name "cirros-0.3.4-x86_64-disk" --disk-format qcow2 --container-format bare --is-public True --progress < cirros-0.3.4-x86_64-disk.img

[[email protected]controller ~]# glance image-create --name "cirros-0.3.4-x86_64-disk" --disk-format qcow2 --container-format bare --is-public True --progress < cirros-0.3.4-x86_64-disk.img
[=============================>] 100%
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2019-01-26T19:11:52                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | c0508642-29f2-4d57-b7ca-7417668e1908 |
| is_public        | True                                 |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | cirros-0.3.4-x86_64-disk             |
| owner            | 18e38545a20f4fbb8dba8944118d43bc     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| updated_at       | 2019-01-26T19:11:52                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+

创建成功后,可以登录界面,查看镜像信息

技术分享图片

查看镜像列表

# glance image-list

[[email protected] ~]# glance image-list
+--------------------------------------+--------------------------+-------------+------------------+------------+--------+
| ID                                   | Name                     | Disk Format | Container Format | Size       | Status |
+--------------------------------------+--------------------------+-------------+------------------+------------+--------+
| b3f9088f-ca51-4a03-ab9a-66e9c4baacce | cirros                   | qcow2       | bare             | 13287936   | active |
| c0508642-29f2-4d57-b7ca-7417668e1908 | cirros-0.3.4-x86_64-disk | qcow2       | bare             | 13287936   | active |
| b408a7da-7fff-4238-8f17-9e48f34553ef | cirros-test              | qcow2       | bare             | 22085632   | active |
| c6e2e980-935c-4337-94ae-0595988065d2 | Cloud_Centos6.5_64bit    | qcow2       | bare             | 3028287488 | active |
| 54e5faa2-2591-40de-89ce-4511623ce649 | Cloud_win7_64bit         | qcow2       | bare             | 7724400640 | active |
+--------------------------------------+--------------------------+-------------+------------------+------------+--------+

查看镜像的详细信息

参数可以是镜像id或者镜像名称

# glance image-show Cloud_Centos6.5_64bit

[[email protected] ~]# glance image-show Cloud_Centos6.5_64bit
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | d6e6a71c69f1996350970489f9513402     |
| container_format | bare                                 |
| created_at       | 2019-01-22T10:48:31                  |
| deleted          | False                                |
| disk_format      | qcow2                                |
| id               | c6e2e980-935c-4337-94ae-0595988065d2 |
| is_public        | False                                |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | Cloud_Centos6.5_64bit                |
| owner            | 18e38545a20f4fbb8dba8944118d43bc     |
| protected        | False                                |
| size             | 3028287488                           |
| status           | active                               |
| updated_at       | 2019-01-22T10:51:16                  |
+------------------+--------------------------------------+

 

更改镜像

如果需要改变镜像启动硬盘最低要求值(min-disk)时,min-disk默认单位为G

更新镜像信息

# glance image-update --min-disk=1 cirros-0.3.4-x86_64-disk

[[email protected] ~]# glance image-update --min-disk=1 cirros-0.3.4-x86_64-disk
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | ee1eca47dc88f4879d8a229cc70a07c6     |
| container_format | bare                                 |
| created_at       | 2019-01-26T19:11:52                  |
| deleted          | False                                |
| deleted_at       | None                                 |
| disk_format      | qcow2                                |
| id               | c0508642-29f2-4d57-b7ca-7417668e1908 |
| is_public        | True                                 |
| min_disk         | 1                                    |
| min_ram          | 0                                    |
| name             | cirros-0.3.4-x86_64-disk             |
| owner            | 18e38545a20f4fbb8dba8944118d43bc     |
| protected        | False                                |
| size             | 13287936                             |
| status           | active                               |
| updated_at       | 2019-01-26T19:26:36                  |
| virtual_size     | None                                 |
+------------------+--------------------------------------+

 

删除镜像

# glance image-delete cirros-0.3.4-x86_64-disk

[[email protected] ~]# glance image-delete cirros-0.3.4-x86_64-disk
[[email protected] ~]# 
[[email protected] ~]# glance image-list
+--------------------------------------+-----------------------+-------------+------------------+------------+--------+
| ID                                   | Name                  | Disk Format | Container Format | Size       | Status |
+--------------------------------------+-----------------------+-------------+------------------+------------+--------+
| b3f9088f-ca51-4a03-ab9a-66e9c4baacce | cirros                | qcow2       | bare             | 13287936   | active |
| b408a7da-7fff-4238-8f17-9e48f34553ef | cirros-test           | qcow2       | bare             | 22085632   | active |
| c6e2e980-935c-4337-94ae-0595988065d2 | Cloud_Centos6.5_64bit | qcow2       | bare             | 3028287488 | active |
| 54e5faa2-2591-40de-89ce-4511623ce649 | Cloud_win7_64bit      | qcow2       | bare             | 7724400640 | active |
+--------------------------------------+-----------------------+-------------+------------------+------------+--------+

end

以上是关于OpenStack镜像服务基本操作的主要内容,如果未能解决你的问题,请参考以下文章

Openstack(八)部署镜像服务glance

N版openstack——镜像服务glance

openstack第三天——Glance

OpenStack 镜像服务Glance [三]

OpenStack搭建企业私有云 二:镜像服务(持续更新...)

OpenStack—镜像服务