基于libvert的虚拟机热迁移

原blog地址:http://www.libaoyin.com/2013/05/19/libvirt-live-migration-without-shared-storage/

作者:李保银


虚拟化hypervisor:KVM

libvirt版本:0.8.8

虚拟机使用本地存储


操作步骤:

  1. 准备libvirt开启tcp监控
    修改/etc/libvirt/libvirtd.conf
    去掉注释
    listen_tls = 0
    listen_tcp = 1
    去掉注释并修改值
    auth_tcp = “none”
同时 vi /etc/default/libvirt-bin 修改为libvirt_opts = "-d -l" 增加-l监听tcp

  1. scp镜像文件和console.log以及其他文件到目标主机
    scp文件这个视你的情况而定,如果漏了的话迁移的时候会报错,到时候再根据提示scp就行。这一步最好保持源主机和目标主机的路径是一致的。
  2. 迁移
    1. virsh migrate vm_name --live qemu+ssh://intent_ip/system
    这过程中会让你输入目标主机的root密码(可以提前配置免密码登录,对于普通用户的免密码登录,可以参见我的这篇blog),按照提示做就好,然后登陆目标主机。察看迁移的进度:
    tail -f /var/log/libvirt/qemu/zhruxgpy.log
  3. 清理源节点
    把源节点的虚拟机销毁,磁盘文件删除,与虚拟机相关的防火墙规则删除等等。

要基于无共享存储的live migration 你需要在命令中添加选项

--copy-storage-all 或者 --copy-storage-inc

如:virsh migrate vm_name --live qemu+ssh://intent_ip/system --copy-storage-inc 

说明:

--copy-storage-all :基于非共享存储的全部硬盘的迁移

--copy-storage-inc :基于非共享存储的额外的存储(在source和destination之间有相同的共享的硬盘)

英语原文:

  1. --copy-storage-all indicates migration with non-shared storage with full disk copy

  2. --copy-storage-inc indicates migration with non-shared storage with incremental copy (same base image shared between source and destination)
  • 关于--copy-storage-inc的说明
  • Live migration with incremental storage copy . This is for the case where you're using a “linked image”. In other words, If you're using a copy on write block image based on a base image a.k.a backing file. In this case the backing file must be present on both source and destination servers. For more on backing files or base images see the following post on base images.

  • 其实,在OpenStack中的虚拟机live-migrate,基本就是组合了上述过程,具体的命令后续有时间我会补上。

    你可能感兴趣的:(基于libvert的虚拟机热迁移)