上传镜像到存储

发布时间 2024-01-09 18:02:17作者: 夜夜漫笔

邮储实际应用:

1. 创建镜像id

 

glance image-create --name "AX76-FT-150G-20210123"

--disk-format raw

--container-format bare --visibility public --protected False

--property hw_qemu_guest_agent=yes --property os_type="linux"

--property os_distro="corros" --property os_version="0.5.1"

--property hw_vif_multiqueue_enabled=true

--property ctcm_enabled=true --progress

 

 

参数说明:

--name  镜像名称,按照镜像实际名称命名即可

其他参数不用更改

2. 上传镜像到ceph

 

 glance image-upload --file /root/sc_image/AX76-FT-150G-202101.raw --backend netapp_A300_FC_az1_001 b1864532-af50-414e-a33a-a490e43e9b70 --progress

 

  1. --backend值改为ceph  空格后面为镜像id
  2. 如果是qcow2的镜像文件需要用以下命令进行转换,其他条件同理

 

qemu-img convert -f qcow2 -O raw CentOS-6.9.qcow2 CentOS-6.9.raw

3. 镜像分发到存储后端

 

使用说明

镜像分发命令行:

[root@controller ~]# glance help image-distribute

usage: glance image-distribute <IMAGE_ID> <DEST_IMAGE_ID> <backends>

                               [<backends> ...] <VOLUME_SIZE>

 

Distribute image to specific backends.

 

Positional arguments:

  <IMAGE_ID>       ID of src image to distribute.  //使用该镜像在cinder中创建可启动盘

  <DEST_IMAGE_ID>  ID of dest image to add location to.  //将创建出的可启动盘添加到location,注册到此镜像,作为生产用的镜像

  <backends>       Backends to distribute image to.  //glance stores-info返回的store id,store必须是cinder类型的,使用<IMAGE_ID>镜像在这些backends所对应的cinder-volume上创建可启动卷

  <VOLUME_SIZE>    Size in GiB of volume to be created in cinder.  //指定在cinder中创建可启动卷的大小,一般设置为镜像文件的virtual_size

 

 

 <backends> 可使用cinder type-list查询

 

设置镜像VOLUME_SIZE大小时,使用qemu-img info命令先查询大小 例如是23.3G取整为24G即可

 

使用说明:

glance要对接ceph rbd块存储,并配置为镜像默认存储。

先通过glance image-create命令创建镜像IMAGE_ID,container_format是bare,disk_format是raw,将此镜像上传到ceph rbd块存储中。

之后通过glance image-distribute命令将镜像分发到各个后端存储中,保存为镜像卷。

DEST_IMAGE_ID和IMAGE_ID设置为同一个。