I. Lab Environment
- Original VM name: vm01-centos6.8
- Original VM host machine: kvm-host-2
- Post-migration VM name: vm01-cloud-centos6.8
- Host where the VM is located after migration: kvm-host-2
2. Preparations for migration process 2.1
1 [[email protected] ~] # Virsh shutdown vm01-centos6.8 # Shut down the VM to be migrated 2 [[email protected] ~] # Virsh list -- all # view VM status
1 [[email protected] ~] # Virsh dow.klist vm01-centos6.8 # view VM Disk
2.2 migration host environment configuration the migrated host kvm-host-2 VM environment must be available, specific environment deployment refer to 002. KVM environment deployment. 2.3 export the configuration file
1 [[email protected] ~]# virsh dumpxml vm01-centos6.8 > /tmp/vm01-cloud-centos6.8.xml
2.4 copy the configuration to the target machine
1 [[email protected] ~]# scp /tmp/vm01-cloud-centos6.8.xml [email protected]:/etc/libvirt/qemu
2.5 copy the disk to the target machine
1 [[email protected] ~]# scp /data/images/vm01-centos6.8.img [email protected]:/data/images/vm01-cloud-centos6.8.img
2.6 target host Adjustment
1 [[email protected] ~] # Virsh list -- all # view the VM list
1 [[email protected] ~] # Vi/etc/libvirt/qemu/vm01-cloud-centos6.8.xml 2 ...... 3 <Name> vm01-cloud-centos6.8 </Name> 4 <UUID> 5130c447-8f43-4f84-bc90-4f51db2023f8 </UUID> # modify UUID 5 ...... 6 <disk type = 'file' device = 'disk'> 7 <driver name = 'qemu' type = 'qcow2 '/> 8 <source file ='/data/images/ vm01-cloud-centos6.8.img '/> # modify the corresponding disk path and name 9 <target Dev = 'vda' bus = 'virtio'/> 10 <address type = 'pci 'domain = '0x0000' bus = '0x00' slot = '0x04 'function = '0x0'/> 11 </disk> 12 ...... 13 <MAC address = '52: 54: 00: 16: D3: 96 '/> # modify the corresponding MAC address
Suggestion: Modify the preceding parameters to be different from the original values to prevent conflicts.2.7 register a VM
1 [[email protected] ~]# virsh define /etc/libvirt/qemu/vm01-cloud-centos6.8.xml
2.8 view Verification
1 [[email protected] ~]# virsh list --all
3. Start and adjust
1 [[email protected] ~]# virsh list --all
Change the MAC/IP address in the nic and the MAC address in/etc/udev/rules. d/70-persistent-net.rules to the xml configuration file and restart it.
010. Cold migration of KVM VM