KVM static Migration, NFS-based dynamic migration

Source: Internet
Author: User

Reference <KVM virtualization Technology, actual combat and Principle analysis >

Migration: Migrations that involve the overall system and migration of a workload can be categorized into the following categories according to the characteristics of the migration:

Static migration (cold migration): Refers to the migration process for a period of time, the client's service is not available, it can also be divided into two, one is to completely shut down the client, the hard disk image copied to another host and then started up, this does not save the client's workload state; There is also a way not to completely shut down the client, but to pause the client, and then use a snapshot, such as the current state of the snapshot, copy the snapshot to the new host on the boot.

Dynamic migration (hot migration): To ensure that the client's application services are running properly while the migration is complete, the user does not feel the change of service, because the time to suspend the service is very short. Therefore, dynamic migration is more difficult for a client with a busy service.

Static migration of the KVM Save workload State:

(1) Press ctrl+alt+2 on the source host to switch to monitor and save the current state of the client with the following command

SAVEVM My_tag #my_tag是自定义的名称

(2) Copy the client's image to the new host, boot the image with the same command parameters as the source host, and use the following command to restore the status to monitor mode

LOADVM My_tag

Note: The SAVEVM feature is supported only for specific image file formats, such as QCOW2,QED.


650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8B/8D/wKioL1hRAt-CGtYcAAEk2zoiZi8038.png "title=" r4gf% Xdq@i_7lei%z2v~axj.png "alt=" Wkiol1hrat-cgtycaaek2zoizi8038.png "/>

KVM-based dynamic migration for shared storage on NFS:

1. In the case of shared storage, the specific dynamic migration process for KVM is:

(1) Destination host initiates a client mirror on the shared storage and listens for a socket to receive the client's information

(2) The client is still running on the source host, while the client's memory page is transferred to the destination host

(3) KVM monitors and records any changes to all memory pages that have been transferred during the migration

(4) When all the memory is also transferred, the KVM starts to transfer the modified contents of the memory page

(5) KVM estimates the transfer speed during the migration process, and when the remaining amount of data can be completed in a configurable time period (KVM default 30ms), KVM shuts down the client on the source host and transmits the remaining content

(6) The destination host receives the last data volume and restores the client's status according to the data

It is known from the above that the KVM dynamic migration process is not complete when the memory is modified faster than the speed of the KVM transfer memory

2. Specific implementation:

Architecture:

SOURCE Host: 192.168.2.127

Destination Host: 192.168.2.188

Server for NFS: 192.168.2.138

(Default off SELinux and Iptables)


On the 192.168.2.138:

(1) Configure Server for NFS (refer to https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-nfs.html, this is only built, not explained)

Yum install Nfs-utils rpcbind-y #我的是centos6.5 default installed Rpcbind and so on, compared to the old system like RPC is PORTMAP implementation, according to their own situation to

echo "/mydata 192.168.2.0/24 (rw)" >/etc/exports

#三段式命令,/mydata represents the export of this directory as a shared storage directory, 192.168.2.0/24 representative allows the host mount of this segment, (RW) represents read and write permissions, each user host can read and write to it

Chown-r Nfsnobody:nfsnobody/mydata #因为用户挂载这个目录是以nfsnobody的身份来的, so to be able to read this directory reading and writing, you must also let Nfsnobody have write access to it

Service NFS Start

(2) Create a disk image

DD If=/dev/zero of=/mydata/redhat6.5.img bs=1024 count=10240000

(3) Installation system

Qemu-system-x86_64-m 1024-smp 1-boot order=dc-hda/mydata/redhat6.5.img-cdrom install.iso #install. ISO I use Kickst One-click installation system image for art production

Chown-r Nfsnobody:nfsnobody/mydata #因为安装镜像用的root身份, need to read or write to it or change back to Nfsnobody

On the source host:

(1) Mount NFS

Mount 192.168.2.138:/mydata/mydata

(2) Boot image

Qemu-system-x86_64-m 1024-smp 1/mydata/redhat6.5.img-net nic-net tap #网络方面的配置请参考我前面的文档, with ready-made scripts

On the destination host:

(1) Mount NFS

Mount 192.168.2.138:/mydata/mydata#这里的挂载的目录路径必须和源宿主机一样, and the reason might be a path-dependent migration process. Personal speculation, awaiting enquiry

(2) Boot image

Qemu-system-x86_64-m 1024-smp 1/mydata/redhat6.5.img-net nic-net tap-incoming tcp:0:6666

#启动参数必须和源宿主机一致, just a little extra-incoming, the boot will be black screen, it is not to the normal client as the start, but wait for the dynamic migration of data incoming

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M00/8B/8D/wKioL1hRBMKhs6_JAAB6M7o9Bwg440.png "title=" {}} 8cmnn3[) o~{%1[u28km0.png "alt=" Wkiol1hrbmkhs6_jaab6m7o9bwg440.png "/>

On the source host:

Ctrl+alt+2 into QEMU monitor mode, use the following command to migrate:

Migrate tcp:192.168.2.188:6666

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M01/8B/90/wKiom1hRBNTg0ClgAACtI6piZoM043.png "title=" 4 ' 8O Vw@~i4 (rqv}wven22gp.png "alt=" Wkiom1hrbntg0clgaacti6pizom043.png "/>

Next, you can see the black screen of the guest host's client, and the destination host's client successfully started, the dynamic migration of a client is complete.

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/8B/8D/wKioL1hRBOXw_ZXZAAB7sVE6KX0230.png "title=" B16LLA7L (oxn1gmg4i3_ (fj.png "alt=" Wkiol1hrboxw_zxzaab7sve6kx0230.png "/>

KVM static Migration, NFS-based dynamic migration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.