ESXI 迁移至KVM (V2V迁移)

1.1.1 ESXI将虚拟机导出

image.png

导出ova模板


image.png

将导出的ova模板导入到KVM环境中。

1.1.2 配置KVM环境

[root@clsn7 ~]# yum install libvirt* virt-* qemu-kvm* -y
配置桥接网卡
[root@clsn7 ~]# virsh iface-bridge eth1 br1 
使用附加设备 br1 生成桥接 eth1 失败
已启动桥接接口 br1

详情参考:http://www.cnblogs.com/clsn/p/8366251.html

安装所需要的组件
1.1.3 导入虚拟机

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

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

创建虚拟机存放目录

# 如果没有virt-v2v命令,需要提前安装
[root@clsn7 ~]# yum install -y virt-v2v -y
[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

# centos-dev-test01-v2v.ova 为导出虚拟机名称
# /vmhost/dev/dev-test01  导入kvm的新目录

导入完成后在 /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标记为自动开始

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

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,657评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,889评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,057评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,509评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,562评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,443评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,251评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,129评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,561评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,779评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,902评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,621评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,220评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,838评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,971评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,025评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,843评论 2 354