1、ESXI将虚拟机导出

ESXI迁移至KVM (V2V迁移) - 图1
导出ova模板
ESXI迁移至KVM (V2V迁移) - 图2
将导出的ova模板导入到KVM环境中。

2、配置KVM环境

详情参考:http://www.cnblogs.com/clsn/p/8366251.html
安装所需要的组件

  1. [root@clsn7 ~]# yum install libvirt* virt-* qemu-kvm* -y

配置桥接网卡

  1. [root@clsn7 ~]# virsh iface-bridge eth1 br1
  2. 使用附加设备 br1 生成桥接 eth1 失败
  3. 已启动桥接接口 br1

3、导入虚拟机

启动kvm管理程序,并设置开机自启动

  1. [root@clsn7 ~]# systemctl start libvirtd.service
  2. [root@clsn7 ~]# systemctl enable libvirtd.service

创建虚拟机存放目录

  1. [root@clsn7 ~]# virt-v2v -i ova centos-dev-test01-v2v.ova -o local -os /vmhost/dev/dev-test01 -of qcow2
  2. [ 0.0] Opening the source -i ova centos-dev-test01-v2v.ova
  3. virt-v2v: warning: making OVA directory public readable to work around
  4. libvirt bug https://bugzilla.redhat.com/1045069
  5. [ 23.1] Creating an overlay to protect the source from being modified
  6. [ 23.4] Initializing the target -o local -os /vmhost/dev/dev-test01
  7. [ 23.4] Opening the overlay
  8. [ 41.4] Inspecting the overlay
  9. [ 57.5] Checking for sufficient free disk space in the guest
  10. [ 57.5] Estimating space required on target for each disk
  11. [ 57.5] Converting CentOS release 6.9 (Final) to run on KVM
  12. virt-v2v: This guest has virtio drivers installed.
  13. [ 178.6] Mapping filesystem data to avoid copying unused and blank areas
  14. [ 178.9] Closing the overlay
  15. [ 179.4] Checking if the guest needs BIOS or UEFI to boot
  16. [ 179.4] Assigning disks to buses
  17. [ 179.4] Copying disk 1/1 to /vmhost/dev/dev-test01/centos-dev-test01-v2v-sda (qcow2)
  18. (100.00/100%)
  19. [ 216.1] Creating output metadata
  20. [ 216.1] Finishing off

导入完成后在 /vmhost/dev/dev-test01 目录下会生成文件

  1. [root@clsn7 dev-test01]# pwd
  2. /vmhost/dev/dev-test01
  3. [root@clsn7 dev-test01]# ls
  4. centos-dev-test01-v2v-sda centos-dev-test01-v2v.xml

修改网卡配置
  修改网卡source network 为桥接
  修改网卡使用virtio

  1. [root@clsn7 dev-test01]# cat centos-dev-test01-v2v.xml
  2. <?xml version='1.0' encoding='utf-8'?>
  3. <domain type='kvm'>
  4. <!-- generated by virt-v2v 1.36.3rhel=7,release=6.el7_4.3,libvirt -->
  5. <name>centos-dev-test01-v2v</name>
  6. <memory unit='KiB'>524288</memory>
  7. <currentMemory unit='KiB'>524288</currentMemory>
  8. <vcpu>1</vcpu>
  9. <features>
  10. <acpi/>
  11. <apic/>
  12. </features>
  13. <os>
  14. <type arch='x86_64'>hvm</type>
  15. </os>
  16. <on_poweroff>destroy</on_poweroff>
  17. <on_reboot>restart</on_reboot>
  18. <on_crash>restart</on_crash>
  19. <devices>
  20. <disk type='file' device='disk'>
  21. <driver name='qemu' type='qcow2' cache='none'/>
  22. <source file='/vmhost/dev/dev-test01/centos-dev-test01-v2v-sda'/>
  23. <target dev='vda' bus='virtio'/>
  24. </disk>
  25. <disk device='cdrom' type='file'>
  26. <driver name='qemu' type='raw'/>
  27. <target dev='hda' bus='ide'/>
  28. </disk>
  29. <disk device='floppy' type='file'>
  30. <driver name='qemu' type='raw'/>
  31. <target dev='fda'/>
  32. </disk>
  33. <interface type='bridge'>
  34. <source bridge='br1'/>
  35. <model type='virtio'/>
  36. <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
  37. </interface>
  38. <video>
  39. <model type='qxl' ram='65536' heads='1'/>
  40. </video>
  41. <graphics type='vnc' autoport='yes' port='-1'/>
  42. <input type='tablet' bus='usb'/>
  43. <input type='mouse' bus='ps2'/>
  44. <console type='pty'/>
  45. </devices>
  46. </domain>

4、启动虚拟机

导入主机

  1. [root@clsn7 dev-test01]# virsh define centos-dev-test01-v2v.xml
  2. 定义域 centos-dev-test01-v2v(从 centos-dev-test01-v2v.xml

查看主机列表

  1. [root@clsn7 dev-test01]# virsh list --all
  2. Id 名称 状态
  3. ----------------------------------------------------
  4. - centos-dev-test01-v2v 关闭

启动主机

  1. [root@clsn7 dev-test01]# virsh start centos-dev-test01-v2v
  2. centos-dev-test01-v2v 已开始

5、测试可用性

登陆迁移后的虚拟机测试

  1. [root@clsn7 ~]# ssh root@192.168.19.123
  2. The authenticity of host '192.168.19.123 (192.168.19.123)' can't be established.
  3. RSA key fingerprint is SHA256:iRmghFzgRIJy5+v8p4lqi8DyUG8F0hXR/qNdDZ2J6RY.
  4. RSA key fingerprint is MD5:37:b8:56:3b:b7:85:fa:cb:d9:55:a7:44:d5:de:f8:d9.
  5. Are you sure you want to continue connecting (yes/no)? yes
  6. Warning: Permanently added '192.168.19.123' (RSA) to the list of known hosts.
  7. root@192.168.19.123's password:
  8. Last login: Mon Mar 5 10:30:02 2018 from 192.168.19.9
  9. [root@dev-test01 ~]# hostname -I
  10. 192.168.19.123

设置虚拟机开机自启动。

  1. [root@clsn7 ~]# virsh autostart centos-dev-test01-v2v
  2. centos-dev-test01-v2v标记为自动开始

至此一台机器的迁移完成,后续按照相同的方式将其他的虚拟机进行迁移即可。