Following scenario:
You have 2 servers. No shared storage.
You would like to move VMs from Server A to Server B.
If you want a clean filesystem there will be downtime.
Downtime will take as long as it needs to copy the image from one server to the other.
Step 1:
Shutdown the instance running on the source server.
e.g.
1 |
virsh shutdown domain.name |
Step 2:
Copy the image, usually located in /var/lib/libvirt/images/ , from source to destination.
e.g.
1 |
rsync -avh /var/lib/libvirt/images/* root@destination.server:/var/lib/libvirt/images/ |
Step 3:
Dumo the configuration xml of your vm and copy it to the destination server
e.g.
1 |
virsh dumpxml domain.name > domain.name.xml |
1 |
scp domain.name.xml root@destination.server: |
This will copy domain.name.xml to the home directory of the destination server, in this case /root/ (implied by the : after the server name)
Step 4:
Import the copied xml domain configuration on the destination server.
The MAC address probably changed, depending on your data center’s setup you’d need to edit the xml file accordingly.
The domain import command is
1 |
virsh define domain.name.xml |
Step 5:
Finish it up.
Change network configuration from inside the guest.
You will need to login via spice console.
It’s best to use the great tool “Virtual Machine Manager” for this job.
Remember to keep your VM’s root password ready.