1、安装配置VMraer-ESXi平台并创建虚拟机
安装
https://blog.csdn.net/qq_41548028/article/details/124054189
https://blog.csdn.net/kakaops_qing/article/details/110037834?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-8-110037834-blog-124054189.pc_relevant_multi_platform_whitelistv4&spm=1001.2101.3001.4242.5&utm_relevant_index=11
部署好后浏览器输入VMraer-ESXi的IP地址即可访问:
在ESXi上安装虚拟机 配置网络
https://blog.csdn.net/m0_51996190/article/details/114298585
2、配置v2v转换服务器
yum install -y qemu-kvm libvirt virt-manager virt-v2v
需要迁移win虚机的话,还需安装:
yum install -y libguestfs-winsupport
3、查看源主机的虚拟机
$ virsh -c esx://root@192.168.30.177?no_verify=1 list --all
# 192.168.30.177 为宿主机的ip或者URL</pre>
[root@compute data]# virsh -c esx://root@192.168.30.177?no_verify=1 list --all
Enter root's password for 192.168.30.177:
Id Name State
-----------------------
- guest shut off
4、迁移vm
使用virt-v2v-copy-to-local命令即可把对应的VM迁移到本地,其中需要输入两次密码,两次的密码均为esxi宿主机的登录密码(注意:vm要为shut off状态)
$ virt-v2v-copy-to-local -ic esx://root@192.168.30.177?no_verify=1 guest
# 192.168.30.177 为宿主机的ip或者URL
# guest为迁移的VM名称</pre>
[root@-compute vms]# virt-v2v-copy-to-local -ic esx://root@192.168.30.177?no_verify=1 guest
[ 5.3] Parsing the remote libvirt XML metadata ...
Enter host password for user 'root':
Enter host password for user 'root':
[ 16.9] Copying remote disk 1/1 to guest-disk1
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
5 16.0G 5 875M 0 0 45.1M 0 0:06:03 0:00:19 0:05:44 45.5M
迁移完成后会在当前目录生成一个xml文件和disk1磁盘文件
5、格式转换
迁移完成后,就需要把磁盘文件的格式转换成OpenStack能够识别的格式
$ virt-v2v -i libvirtxml guest.xml -o local -os /data/vms -of raw
#guest.xml为刚才迁移时生成的xml文件
# -o <glance|libvirt|local|null|openstack|qemu|rhv|rhv-upload|vdsm>
#-os为转换格式后存放的路径
#-of为指定转换的格式为raw <raw|qcow2> </pre>
[root@compute data]# virt-v2v -i libvirtxml guest.xml -o local -os /data/vms/ -of raw
[ 0.0] Opening the source -i libvirtxml guest.xml
[ 0.0] Creating an overlay to protect the source from being modified
[ 0.2] Opening the overlay
[ 4.2] Inspecting the overlay
[ 17.2] Checking for sufficient free disk space in the guest
[ 17.2] Estimating space required on target for each disk
[ 17.2] Converting CentOS Linux release 7.9.2009 (Core) to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 66.0] Mapping filesystem data to avoid copying unused and blank areas
[ 66.6] Closing the overlay
[ 66.8] Assigning disks to buses
[ 66.8] Checking if the guest needs BIOS or UEFI to boot
[ 66.8] Initializing the target -o local -os /data/vms/
[ 66.8] Copying disk 1/1 to /data/vms/guest-sda (raw)
(100.00/100%)
[ 69.0] Creating output metadata
[ 69.0] Finishing off
[root@compute data]# ll -h vms
total 1.3G
-rw-r--r-- 1 root root 16G Feb 27 10:02 guest-sda
-rw-r--r-- 1 root root 1.5K Feb 27 10:02 guest.xml
会在/data/vms下生成一个raw格式的OpenStack镜像,上传到OpenStack环境中即可使用。
6、上传镜像到openstack
glance image-create --name vmware_guest --disk-format=raw --container-format=bare --file guest-sda