OpenStack鏡像服務基本操作


 查詢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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM