1.1.1 ESXI將虛擬機器匯出
匯出ova模板
將匯出的ova模板匯入到KVM環境中。
1.1.2 配置KVM環境
詳情參考:http://www.cnblogs.com/clsn/p/8366251.html
安裝所需要的元件
[root@clsn7 ~]# yum install libvirt* virt-* qemu-kvm* -y
配置橋接網路卡
[root@clsn7 ~]# virsh iface-bridge eth1 br1 使用附加裝置 br1 生成橋接 eth1 失敗 已啟動橋接介面 br1
1.1.3 匯入虛擬機器
啟動kvm管理程式,並設定開機自啟動
[root@clsn7 ~]# systemctl start libvirtd.service [root@clsn7 ~]# systemctl enable libvirtd.service
建立虛擬機器存放目錄
[root@clsn7 ~]# virt-v2v -i ova centos-dev-test01-v2v.ova -o local -os /vmhost/dev/dev-test01 -of qcow2 [ 0.0] Opening the source -i ova centos-dev-test01-v2v.ova virt-v2v: warning: making OVA directory public readable to work around libvirt bug https://bugzilla.redhat.com/1045069 [ 23.1] Creating an overlay to protect the source from being modified [ 23.4] Initializing the target -o local -os /vmhost/dev/dev-test01 [ 23.4] Opening the overlay [ 41.4] Inspecting the overlay [ 57.5] Checking for sufficient free disk space in the guest [ 57.5] Estimating space required on target for each disk [ 57.5] Converting CentOS release 6.9 (Final) to run on KVM virt-v2v: This guest has virtio drivers installed. [ 178.6] Mapping filesystem data to avoid copying unused and blank areas [ 178.9] Closing the overlay [ 179.4] Checking if the guest needs BIOS or UEFI to boot [ 179.4] Assigning disks to buses [ 179.4] Copying disk 1/1 to /vmhost/dev/dev-test01/centos-dev-test01-v2v-sda (qcow2) (100.00/100%) [ 216.1] Creating output metadata [ 216.1] Finishing off
匯入完成後在 /vmhost/dev/dev-test01 目錄下會生成檔案
[root@clsn7 dev-test01]# pwd /vmhost/dev/dev-test01 [root@clsn7 dev-test01]# ls centos-dev-test01-v2v-sda centos-dev-test01-v2v.xml
修改網路卡配置
修改網路卡source network 為橋接
修改網路卡使用virtio
[root@clsn7 dev-test01]# cat centos-dev-test01-v2v.xml <?xml version='1.0' encoding='utf-8'?> <domain type='kvm'> <!-- generated by virt-v2v 1.36.3rhel=7,release=6.el7_4.3,libvirt --> <name>centos-dev-test01-v2v</name> <memory unit='KiB'>524288</memory> <currentMemory unit='KiB'>524288</currentMemory> <vcpu>1</vcpu> <features> <acpi/> <apic/> </features> <os> <type arch='x86_64'>hvm</type> </os> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <disk type='file' device='disk'> <driver name='qemu' type='qcow2' cache='none'/> <source file='/vmhost/dev/dev-test01/centos-dev-test01-v2v-sda'/> <target dev='vda' bus='virtio'/> </disk> <disk device='cdrom' type='file'> <driver name='qemu' type='raw'/> <target dev='hda' bus='ide'/> </disk> <disk device='floppy' type='file'> <driver name='qemu' type='raw'/> <target dev='fda'/> </disk> <interface type='bridge'> <source bridge='br1'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <video> <model type='qxl' ram='65536' heads='1'/> </video> <graphics type='vnc' autoport='yes' port='-1'/> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <console type='pty'/> </devices> </domain>
1.1.4 啟動虛擬機器
匯入主機
[root@clsn7 dev-test01]# virsh define centos-dev-test01-v2v.xml 定義域 centos-dev-test01-v2v(從 centos-dev-test01-v2v.xml)
檢視主機列表
[root@clsn7 dev-test01]# virsh list --all Id 名稱 狀態 ---------------------------------------------------- - centos-dev-test01-v2v 關閉
啟動主機
[root@clsn7 dev-test01]# virsh start centos-dev-test01-v2v 域 centos-dev-test01-v2v 已開始
1.1.5 測試可用性
登陸遷移後的虛擬機器測試
[root@clsn7 ~]# ssh root@192.168.19.123 The authenticity of host '192.168.19.123 (192.168.19.123)' can't be established. RSA key fingerprint is SHA256:iRmghFzgRIJy5+v8p4lqi8DyUG8F0hXR/qNdDZ2J6RY. RSA key fingerprint is MD5:37:b8:56:3b:b7:85:fa:cb:d9:55:a7:44:d5:de:f8:d9. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.19.123' (RSA) to the list of known hosts. root@192.168.19.123's password: Last login: Mon Mar 5 10:30:02 2018 from 192.168.19.9 [root@dev-test01 ~]# hostname -I 192.168.19.123
設定虛擬機器開機自啟動。
[root@clsn7 ~]# virsh autostart centos-dev-test01-v2v 域 centos-dev-test01-v2v標記為自動開始
至此一臺機器的遷移完成,後續按照相同的方式將其他的虛擬機器進行遷移即可。