The late scholar notes --KVM virtual migration (5)

KVM virtual migration ( 5 )

I. Introduction Migration                                                                                                  

migrate:

      Migration refers to the system of the operating system and applications on the source host to the destination host moves, and works correctly on the destination host. In no time the virtual machine migration between physical machines rely on the system backup and recovery techniques. In the real-time backup status on the source host operating system and applications, and the storage medium is connected to the target host, the final recovery system on the target host. With the development of virtual machine technology, the migration system more flexible and diverse.

 

Eventually we migrate purpose is to:

    Simplify system maintenance and management

    High system load balancing

    Augmentation System error tolerance

    Optimize system power management

 

Second, the thermal migration  --- Live Migration                                                                            

KVM live migration of virtual machines --- Live Migration:

      Server virtualization technology is the current hot spots, and virtual machine "hot migration (Live Migration)" technology is a hot spot among virtualization technology.

 

Live migration (also known as live migration, live migration), a virtual machine that is saved ( the Save) / restore (restore): The overall state of the virtual machine preserved intact, and can quickly be restored to the original hardware platforms or even different hardware on the platform. After recovery, the virtual machine is still running smoothly, users will not notice any difference.

 

Migration of species:

P2P: migration between physical machines

V2P: physical machine virtual machine moved

P2V: physical machine move virtual machines

V2V: VM virtual machine moved

 

Third, the application of heat migration                                                                                 

Heat Transfer Technology, the virtual machine was originally used in the fault-tolerant or load balancing: When the host hardware failure leads to abnormal service, a virtual machine can shift to another host or in a cluster based on the amount of workload size, choose whether or not to replace the host to ensure their good service to provide sexual.

 

2. System hardware maintenance: the current number of operating systems are able to support the stability of 7 × 24 operation, but the hardware it needs regular maintenance. If a dynamic migration of virtual machine technology, the virtual machine from the need to maintain the physical machine to another master device, Once maintenance is completed, it is moved back to the original physical machine. All system services and applications still run properly after recovery & migration, users will not notice due to the interruption caused by hardware maintenance. Finally achieved our hardware maintenance services from interference 7 * 24 hours of work aspirations.

 

3. Database Backup: For some large, critical database applications, backup is an important but complex task. Save VM / restore database can be run in a virtual machine, the virtual machine is saved To back up all data in this database, the state has done a backup. If the database crashes, you can recover the entire database by restoring a virtual machine.

 

4. Environment reproduce: performance testing or debugging, the need to reproduce the complex was huge and fully consistent with real-time network environment, not just restart, configuration software, and often take some time to run. We can install each service to separate each virtual machine, then use the individual virtual machine deployments we need work environment, can greatly shorten the time to reproduce the environment.

 

5. Computer Sharing: In some public users need to share computers, but due to different system configurations and software need to spend a lot of time configuring and recovery. Then use the virtual machine to save / restore can solve this problem. Alternatively, you can run multiple logical virtual machines assigned to each of us to help those who need an independent, secure, stable environment on the physical machine. When the host because the problems affecting the virtual machine, the virtual machine so that we can shift to another host in order to maintain normal work.

 

四、热迁移的优势                                                                         

1. 首先是可伸缩性比较强, IT 管理者可以在合理时间段让运行某些关键业务的服务器适当减少工作量,以便进行更新操作系统,给应用程序打补丁等。而到了服务高峰期,又可以弹性地进行大负载量的运算。虚拟机迁移过程完全透明,几乎不影响使用。

 

2. 其次,现在的数据中心都追求环保节能, 工作量负载大的应用程序必然会令服务器能耗增加,有了虚拟机热迁移技术,当一台物理服务器负载过大时,系统管理员可以将其上面的虚拟机迁移到其他服务器,可有效减低数据中心服务器的总体能耗,再通过冷却系统将数据中心的温度保持在正常水平。

 

五、热迁移的局限                                                                           

进行虚拟机的热迁移也有不少的限制。例如, 

      VMotion 在进行迁移之前,管理软件会检测目标服务器的 X86 架构是否与原服务器兼容。包括存储设备以及处理器,虚拟机必须放到共享的存储里, CPU 的类型也要一样,不仅不能一个是英特尔,一个是 AMD ,甚至相同厂商不同产品线的CPU 也不行,比如英特尔至强和奔腾

 

六、衡量虚拟机迁移的效率                                                                              

 1. 整体迁移时间:从源主机中迁移操作开始到目的主机上客户机服务处于不可用状态的时间,此时源主机上客户机已经暂停服务,目的主机上的客户机还未恢复服务。

 

2. 服务器停机时间:在迁移过程中,源主机和目的主机上的客户机都处于不可用状态的时间,此时源主机上客户机已暂停,目的主机上客户还未恢复服务。

 

3. 对服务的性能影响:不仅包括迁移后的客户机中应用程序的性能与迁移前相对比是否有所降低,还包括迁移后对目的主机上的其他服务的性能影响。

 

Kvm 动态迁移,也有如下几个建议和注意事项:

1. 源宿主机和目的宿主机直接尽量用网络共享的存储系统来保存客户机磁盘镜像。例如 NFS , ISCSI , Glusterfs 等。

2. 为了提高动态迁移的成功率,尽量在同类型 cpu的主机上面进行动态迁移,尽管 kvm 动态迁移也支持从 Intel 平台迁移到 amd 平台。  但,从安全性,稳定度考虑不建议这样去操作!!!

3. 64 位的客户机只能运行在 64 宿主机之间的迁移,而 32 位客户机可以在 32 宿主机和 64 位宿主机之间迁移。

4. 在进行动态迁移时,被迁移客户机的名称是唯一的,在目的宿主机上不能有与源宿主机被迁移客户机同名的客户机存在。

5. 目的宿主机和源宿主机的软件尽可能的相同。也就是同为 Vmware , KVM , Xen 等。

 

七、v2v迁移实践                                                                             

安装前准备工作:

迁移需要识别 source&target 主机的主机名所以需要我们搭建 DNS Ser 或者将 IP& 域名 & 主机名的对应条目写入到 hosts 文件中去(可省略)。

 

实验环境:

Source Ser ---- VM

Target Ser

NFS Server 共享存储服务器

 

实验步骤:

 

(1)NFS 部署:

1. 安装 / 配置 / 开启 NFS 服务共享 NFS Server 上的目录: /nfsdate

——#yum install nfs-utils rpcbind -y

——#vim /etc/exports

/nfsdate   *(rw,sync)       #读写同步

——#mkdir /nfsdate

——#chmod  -R  777  /nfsdate

——#chown -R nfsnobody:    /nfsdate

——#systemctl restart rpcbind   nfs

——#showmount -e 192.168.249.21

 

(2)客户端挂载

挂载 NFS Ser 的 /nfsdate 目录到本地的 /nfsdate 目录上

——#mkdir /nfsdate

——#chmod -R 777 /nfsdate

——#mount -t nfs 192.168.249.21:/nfsdate  /nfsdate

 

(3)分别在两台机器上查看当前运行在本地的虚拟机

——# virsh list –all

我的实验条件是:在2虚拟机上有vm01和vm02,1虚拟机有vm01,将2上的vm02迁移到1上;

 

关闭vm02,复制vm02的配置文件到nfsdate:

——#cp /etc/libvirt/qemu/vm02.xml  /nfsdate  

 

删除vm02域:

——#virsh undefine vm02

 

移动vm02的磁盘到nfsdate下:

——#mv /var/lib/libvirt/images/vm02.qcow2

 

修改vm02配置文件的磁盘路径,改为当前路径: /nfadate/vm02.qcow2

——#vim /nfsdsate/vm02.xml

。。。。。。。

 <disk type='file' device='disk'>

      <driver name='qemu' type='qcow2'/>

      <source file='/var/lib/libvirt/images/vm02.qcow2'/>  #改黄色位置

      <target dev='vda' bus='virtio'/>

      <boot order='1'/>

      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>

    </disk>

。。。。。。。

 

重新定义vm02的域:

——#cd /nfsdate

——#virsh define vm02.xml

 

开启vm02。

 

(4)图形界面操作:

先互相连接2台虚拟机,再:

 

 

 

 

 

 

可能有报错:

 

 

 

 

点击下面选项:

 

 

 

 

 

完成后显示如下:

 

 

 

再迁移回来:

 

 

 

 

 

可能会出现的报错:

 

 

未关闭selinux,关闭即可,可能需要重启以完成关闭;重启后再实验:

 

 

完成后:

 

 

查看另一台虚拟机:

 

 

 

 

 =============================================分割线==============================================

 

Guess you like

Origin www.cnblogs.com/feige2L/p/11093365.html