导出glance 虚机 系统盘镜像

456 阅读1分钟

# 物理机 执行

pool='volumes'
vm_name='centos7-base'

. ~/admin-openrc
rbd_block_id="volume-$( nova show " ${vm_name} "  --all-tenants | grep volume | grep -oE '[a-z0-9-]{20,}')"
img_name="centos7-base.qcow2"

rm -rf ./image
mkdir -p image

cd image

# -m n 并发数   -W 允许 非顺序 写入, 与压缩 选项 -c 不可同时 使用
# time qemu-img convert -m 16  rbd:${pool}/${rbd_block_id} -c -p -O qcow2 ./${img_name}
nohup qemu-img convert -m 16   rbd:${pool}/${rbd_block_id} -c -p -O qcow2 ./${img_name} 2>&1 > convert.log &

wait
# 上传
f_path=${img_name}
f_name=${f_path##*/}
inner_ip='192.168.63.100'
curl  --progress-bar -o ./progress.log -u admin:brysjhhrhl356126155165352237656123565615 -T ${f_path} "http://${inner_ip}:50000/remote.php/dav/files/admin/iso/${f_name}"


常用资源

# ubuntu20_compose

http://192.168.63.100:50000/index.php/s/9UreDEVqpF8bkSB/download

性能 时间 测试



Parameters to convert subcommand:
  '-m' specifies how many coroutines work in parallel during the convert
       process (defaults to 8)
  '-W' allow to write to the target out of order rather than sequential

  qemu-img: Invalid number of coroutines. Allowed number of coroutines is between 1 and 16

qemu-img: Out of order write and compress are mutually exclusive


pool='nvme'

echo 3 > /proc/sys/vm/drop_caches

pool='nvme'
rbd_block_id='volume-49132db6-136a-4a9d-b55c-27bd439149df'
concurrent='8'
img_name="test_${concurrent}.qcow2"
time qemu-img convert -m ${concurrent}   rbd:${pool}/${rbd_block_id} -c -p -O qcow2 ./${img_name}


echo 3 > /proc/sys/vm/drop_caches

pool='nvme'
rbd_block_id='volume-49132db6-136a-4a9d-b55c-27bd439149df'
# 16 is max 
concurrent='16'
img_name="test_${concurrent}.qcow2"
time qemu-img convert -m ${concurrent}   rbd:${pool}/${rbd_block_id} -c -p -O qcow2 ./${img_name}
    (100.00/100%)
real    3m57.246s
user    5m11.829s
sys     0m39.621s

# 导入比对

echo 3 > /proc/sys/vm/drop_caches
concurrent='8'
img_name="test_${concurrent}"
time qemu-img convert -m ${concurrent}  -f qcow2 ./"${img_name}.qcow2"  -O raw  rbd:${pool}/${img_name}
real    0m32.675s
user    0m24.500s
sys     0m5.934s



echo 3 > /proc/sys/vm/drop_caches
concurrent='16'
img_name="test_${concurrent}"
rbd remove ${pool}/${img_name}
time qemu-img convert -m ${concurrent}  -f qcow2 ./"${img_name}.qcow2"  -O raw  rbd:${pool}/${img_name}

real    0m33.052s
user    0m24.434s
sys     0m5.853s


# Parameters to convert subcommand:
#   '-m' specifies how many coroutines work in parallel during the convert
#        process (defaults to 8)
#   '-W' allow to write to the target out of order rather than sequential
# -m   -W

echo 3 > /proc/sys/vm/drop_caches
concurrent='8'
img_name="test_${concurrent}"
rbd remove ${pool}/${img_name}
time qemu-img convert -m ${concurrent}  -W  -f qcow2 ./"${img_name}.qcow2"  -O raw  rbd:${pool}/${img_name}
real    0m32.675s
user    0m24.500s
sys     0m5.934s



echo 3 > /proc/sys/vm/drop_caches
concurrent='16'
img_name="test_${concurrent}"
rbd remove ${pool}/${img_name}
time qemu-img convert -m  ${concurrent}  -W -f qcow2 ./"${img_name}.qcow2"  -O raw  rbd:${pool}/${img_name}
real    0m19.716s
user    0m22.898s
sys     0m5.530s