virt-v2v工具自动迁移vmware迁移至kvm
如果虚机是ESXi种的虚机,那么我们可以使用virt-v2v的工具直接进行自动迁移。
virt-v2v工具可以将其他hypervisor平台上的虚拟机迁移到KVM上。
它可以读取Xen,Hyper-v,VMware平台上的虚拟机,将它们迁移到由libvirt管理的KVM,openstack或者RHEV环境中。
本节只针对ESCi上如何将虚机迁移到KVM中,往openstack和RHEV上迁移只需要转换镜像和导入即可不做赘述。
KVM存储池配置过程
mkdir -p /data/vmfs
virsh pool-define-as vmdisk --type dir --target /data/vmfs
virsh pool-build vmdisk
virsh pool-autostart vmdisk
virsh pool-start vmdisk
创建ESXi认证文件
(本步骤不是必须步骤,如果不做配置的话则在使用virt-v2v的时候需要稍微改变命令)
vim /root/.netrc
machine YourESXiServerIPAddress login root password YourESXiServerIPAddress
chmod 0600 ~/.netrc
[root@amckvm2 ~]# cat /root/.netrc
machine 192.168.24.13 login root password password 192.168.24.13
[root@amckvm2 ~]#
开始迁移
开始迁移前先测试看是否能够连接上ESXi主机
virsh -c esx://192.168.24.13/?no_verify=1 list --all
如果能够看到运行在这个ESXi上的主机说明连接没有问题。
[root@amckvm2 ~]# virsh -c esx://192.168.24.13/?no_verify=1 list --all
Enter username for 192.168.24.13 [root]:
Enter root's password for 192.168.24.13:
Id Name State
----------------------------------------------------
1 Vcenter_192.168.24.100 running
8 amcctrix1_192.168.24.103 running
9 amcctrix2_192.168.24.104 running
10 amczhtest_192.168.24.105 running
11 amcjrjh_192.168.24.106 running
13 windowsclustertest_192.168.24.108 running
- rhel6.5_db_model_192.168.24.231 shut off
- windows2008_model shut off
开始迁移
virt-v2v -ic esx://192.168.24.13/?no_verify=1 -os vmdisk -of qcow2 -b br0 rhel6.5_db_model_192.168.24.231
注:
1.如果遇到了类似于“ Peer certificate cannot be authenticated with given CA certificates”这一类的错误通过在url后面设置no_verify=1 参数来忽略证书检查。
2.整个url的组成由user@esxi组成。如果在3.2没有创建认证文件的话这里需要将命令改成如下
virt-v2v -ic esx://root@192.168.24.13/no_verify=1 -os vmdisk -of qcow2 -b br0 rhel6.5_db_model_192.168.24.231
3.如果用户名使用的是域账户(domain\name)或者虚机名中包含有反斜线,则反斜线需要转码特殊标示,使用“%5c”代替“\”
4.-os表示指定到KVM中的哪个存储池,-of表示迁移转出的虚机磁盘格式,我这里指定的事qcow2,-b表示指定KVM中的虚拟网桥。
输出结果如下
[root@amckvm2 ~]# virt-v2v -ic esx://192.168.24.13/?no_verify=1 -os vmdisk -of qcow2 -b br0 rhel6.5_db_model_192.168.24.231
rhel6.5_db_model_rhel6.5_db_model: 100% [==========================================================]D 1h32m16s
virt-v2v: rhel6.5_db_model_192.168.24.231 configured with virtio drivers
virt-v2v: inner-db configured without virtio drivers.
查看转换出来的xml配置文件
[root@amckvm2 qemu]# pwd
/etc/libvirt/qemu
[root@amckvm2 qemu]# cat rhel6.5_db_model_192.168.24.231.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit rhel6.5_db_model_192.168.24.231
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>rhel6.5_db_model_192.168.24.231</name>
<uuid>c97c0167-fde4-e309-e477-4e5592e8507e</uuid>
<memory unit='KiB'>8388608</memory>
<currentMemory unit='KiB'>8388608</currentMemory>
<vcpu placement='static'>8</vcpu>
<os>
<type arch='x86_64' machine='rhel6.5.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none'/>
<source file='/home/data/vmfs/rhel6.5_db_model_rhel6.5_db_model'/>
<target dev='vda' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<interface type='bridge'>
<mac address='00:50:56:ab:3f:15'/>
<source bridge='br0'/>
<model type='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port='0'/>
</serial>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' autoport='yes'/>
<video>
<model type='cirrus' vram='9216' heads='1'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>
[root@amckvm2 qemu]#
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。