码迷,mamicode.com
首页 > 其他好文 > 详细

OpenStack镜像服务基本操作

时间:2019-01-26 20:01:41      阅读:862      评论:0      收藏:0      [点我收藏+]

标签:cow   date   inf   com   img   code   分享   nload   图片   

 查询Glance服务状态

#glance-control all status

[root@controller ~]# 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

[root@controller ~]# glance-api --version
2014.1.3

查询glance-control版本

# glance-control --version

[root@controller ~]# 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

[root@controller ~]# 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

[root@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

[root@controller ~]# 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

[root@controller ~]# 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

[root@controller ~]# 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

[root@controller ~]# glance image-delete cirros-0.3.4-x86_64-disk
[root@controller ~]# 
[root@controller ~]# 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镜像服务基本操作

标签:cow   date   inf   com   img   code   分享   nload   图片   

原文地址:https://www.cnblogs.com/djlsunshine/p/10324716.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!