openstack-glance上傳映象
阿新 • • 發佈:2021-07-08
openstack 中怎麼上傳image ?
1. 需要我們提前準備好映象,具體的映象可以自己在官網下載,國內的建議在 (中科大)https://mirrors.ustc.edu.cn/
2. 在命令列通過glance 上傳映象
命令:
glance image-create --name "ubuntu14-04" --file ubuntu-14.04.6-server-amd64.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
glance 可以使用以下引數: ps:這些引數不是100%都需要的我們在上傳映象更加我們需求選擇相對應的引數就好了
--id <IMAGE_ID> #映象的ID --name <NAME> #映象的名稱 --store <STORE> #儲存的映象上傳到 --disk-format <DISK_FORMAT> #映象的格式。可以接受的格式包含: ami,ari, aki, vhd, vmdk, raw, qcow2, vdi, and iso. --container-format <CONTAINER_FORMAT> #映象容器的格式。可以接受的格式包含:ami,ari, aki, bare, and ovf. --owner <TENANT_ID> # 擁有該映象的租戶 --size <SIZE> #映象的大小(以bytes表示). 一般只與'--location'和'--copy_from'一起使用。 --min-disk <DISK_GB> #啟動映象所需的最小硬碟空間(用gigabytes表示). --min-ram <DISK_RAM> #啟動映象所需的最小記憶體數量(用megabytes表示). --location <IMAGE_URL> #映象所在位置的URL。例如,如果映象儲存在swift中, --file <FILE> #在建立過程中將要被上傳的本地檔案(包括硬碟映象)。另外,映象也可以通過stdin傳遞給客戶端。 --checksum <CHECKSUM> #被Glance使用的可用於認證的映象資料的雜湊值,在此請提供一個md5校驗值。 --copy-from <IMAGE_URL> #用法和'--location'引數相似,但表明Glance伺服器應該能立即從映象所儲存的地方拷貝資料並儲存。 --is-public [True|False] #表示映象是否能被公眾訪問。 --is-protected [True|False] #用於避免映象被刪除。 --property <key=value> #與映象有關的任意的屬性。可以使用很多次。 --human-readable #用對人友好的格式列印映象的尺寸。 --progress #顯示上傳的進度條
3、樣例,下載並上傳centons7的操作過程
下載映象到本地 命令:wget https://mirrors.ustc.edu.cn/centos-cloud/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2
執行過程如下:
[root@node152 ~]# wget https://mirrors.ustc.edu.cn/centos-cloud/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2 --2021-07-08 18:11:46-- https://mirrors.ustc.edu.cn/centos-cloud/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2 Resolving mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)... 202.141.176.110, 2001:da8:d800:95::110 Connecting to mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)|202.141.176.110|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 888995840 (848M) [application/octet-stream] Saving to: ‘CentOS-7-x86_64-GenericCloud-2009.qcow2’ 22% [======================> ] 198,885,082 2.73MB/s in 68s 2021-07-08 18:27:54 (2.79 MB/s) - Read error at byte 198885082/888995840 (Success). Retrying. --2021-07-08 18:27:55-- (try: 2) https://mirrors.ustc.edu.cn/centos-cloud/centos/7/images/CentOS-7-x86_64-GenericCloud-2009.qcow2 Connecting to mirrors.ustc.edu.cn (mirrors.ustc.edu.cn)|202.141.176.110|:443... connected. HTTP request sent, awaiting response... 206 Partial Content Length: 888995840 (848M), 690110758 (658M) remaining [application/octet-stream] Saving to: ‘CentOS-7-x86_64-GenericCloud-2009.qcow2’ 100%[+++++++++++++++++++++++================================================================================>] 888,995,840 2.84MB/s in 3m 55s 2021-07-08 18:31:51 (2.80 MB/s) - ‘CentOS-7-x86_64-GenericCloud-2009.qcow2’ saved [888995840/888995840]
上傳映象到glance,命令glance image-create --name "centos7laste" --file CentOS-7-x86_64-GenericCloud-2009.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress
執行過程如下:
[root@node152 ~]# glance image-create --name "centos7laste" --file CentOS-7-x86_64-GenericCloud-2009.qcow2 --disk-format qcow2 --container-format bare --visibility public --progress [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 8b9411110b8cc5596eb17c60c991ef03 | | container_format | bare | | created_at | 2021-07-08T10:36:34Z | | disk_format | qcow2 | | id | 822e5cb0-c744-441a-b723-9f24775fb622 | | min_disk | 0 | | min_ram | 0 | | name | centos7laste | | owner | 8e4dd46886834371b71984245a143f58 | | protected | False | | size | 888995840 | | status | active | | tags | [] | | updated_at | 2021-07-08T10:36:37Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------+
驗證映象,命令openstack image list
執行過程如下:
[root@node152 ~]# openstack image list +--------------------------------------+--------------+--------+ | ID | Name | Status | +--------------------------------------+--------------+--------+ | 4ba5d2d5-7880-48ab-b383-fa8f62277aef | centos6-init | active | | 38e8b762-79dd-45f5-be11-73e732663614 | centos6.9 | active | | 822e5cb0-c744-441a-b723-9f24775fb622 | centos7laste | active | | 348896ad-1403-4d21-9a1d-c78526bdc6ae | cirros | active | +--------------------------------------+--------------+--------+