通过qemu monitor 来测试 qemu live migration (1)

虚拟机的热迁移无论对于公有云还是私有云都是重要的功能,尤其是为了保持高可用,不down机更新等,热迁移更是必不可少,但是如何测试云热迁移的性能,发现热迁移的瓶颈,找寻了很多方法,最后发现qemu monitor本身就提供了很好监控热迁移以及虚拟机各项指标的功能,并且可以通过在qemu monitor里配置优化迁移的特性达到提高迁移效率或者实现一些特定条件的热迁移,下面几篇内容会包含对于qemu monitor的搭建和使用,以及对于live migration和部分优化手段的测试。

我们先看看做热迁移的要求(https://www.linux-kvm.org/page/Migration )

The VM image is accessible on both source and destination hosts (located on a shared storage, e.g. using nfs).
It is recommended an images-directory would be found on the same path on both hosts (for migrations of a copy-on-write image -- an image created on top of a base-image using "qemu-image create -b ...")
The src and dst hosts must be on the same subnet (keeping guest's network when tap is used).
Do not use -snapshot qemu command line option.
For tcp: migration protocol
the guest on the destination must be started the same way it was started on the source.

根据上面的要求,我们会

  • 搭建共享存储,并且把相关文件放置在共享文件夹内。
  • 保证源服务器和目的服务器网络配置一致。(这一条暂时省略,因为没有配置网络,只要保证两台服务器网络连接正常,并且tcp通信通畅就可以了)
  • 在源服务器和目的服务器上启动对应的虚拟机。

1. 环境搭建

1). 编译qemu

(1) Install dependences
# yum -y install gcc gcc-c++ automake libtool zlib-devel glib2-devel bzip2-devel libuuid-devel spice-protocol spice-server-devel usbredir-devel libaio-devel
(2) Download QEMU 2.10.2
# wget https://download.qemu.org/qemu-2.10.2.tar.xz
# tar -xf qemu-2.10.2.tar.xz
# cd qemu-2.10.2
(3) Configure & make & install
# ./configure
# make -j

这里不需要安装,在qemu-2.10.2/中找到服务器芯片所对应的架构的可执行程序

e.g qemu-2.10.2/x86_64-softmmu/qemu-system-x86_64

2). 安装vncviewer

由于直接通过qemu命令行启动的虚拟机,在不做配置的情况下,可以直接通过vnc访问,提前把vncviewer安装好

# yum install vnc

3). 共享存储搭建

热迁移需要准备共享存储,否则需要把虚拟机镜像等相关文件,在源服务器和目的服务器的相同路径下放置。这里配置了一个简单的nfs共享存储。

centos:
nfs-server
# yum -y install nfs-utils
# systemctl enable nfs-server.service
# vi /etc/exports
/usr/share/AAVMF   192.168.0.0/24(rw,no_root_squash) //only for uefi boot
/root/images   192.168.0.0/24(rw,no_root_squash)
# systemctl start nfs-server.service

nfs-client
# yum -y install nfs-utils
# mount 192.168.0.10:/usr/share/AAVMF /usr/share/AAVMF //only for uefi boot
# mount 192.168.0.10:/root/images  /root/images

注意,最好先把防火墙情况,并且把selinux关掉。

这时,两台服务器间共享了/usr/share/AAVMF和/root/images

这些准备完了就可开始准备启动虚拟机和测试热迁移了。

猜你喜欢

转载自blog.csdn.net/yadehuiyin/article/details/80897515