openstack-glance上传镜像
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%都需要的我们在上传镜像更加我们需求选择相对应的参数就好了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | --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
执行过程如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | [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
执行过程如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | [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
执行过程如下:
1 2 3 4 5 6 7 8 9 | [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 | +--------------------------------------+--------------+--------+ |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端