86 lines
2 KiB
Text
86 lines
2 KiB
Text
= Guest migration between hosts.
|
|
|
|
Move guests from one host to another.
|
|
|
|
== Contact Information
|
|
|
|
Owner::
|
|
Fedora Infrastructure Team
|
|
Contact::
|
|
#fedora-admin, sysadmin-main
|
|
Location::
|
|
RDU3, Tummy, ibiblio, Telia, OSUOSL
|
|
Servers::
|
|
All xen servers, kvm/libvirt servers.
|
|
Purpose::
|
|
Migrate guests
|
|
|
|
== How to do it
|
|
|
|
[arabic]
|
|
. Schedule outage time if any. This will need to be long enough to copy
|
|
the data from one host to another, so will depend on guest disk size.
|
|
. Turn off monitoring in nagios
|
|
. On new host create disk space for server:
|
|
+
|
|
....
|
|
lvcreate -n app03 -L 32G vg_guests
|
|
....
|
|
. prepare old guest for migration:
|
|
[loweralpha]
|
|
.. if system is xen, install a regular kernel
|
|
.. look for entries for xenblk and hvc0 in /etc files
|
|
. Shutdown the guest.
|
|
. {blank}
|
|
+
|
|
....
|
|
virsh dumpxml guestname > guest.xml
|
|
....
|
|
. Copy guest.xml to the new machine. You will need to make various edits
|
|
depending on if the system was originally xen or such. I normally need
|
|
to compare an existing xml on the target system and the one we dumped
|
|
out to make up the differences.
|
|
. Define the guest on the new machine:
|
|
|
|
....
|
|
virsh define guest.xml
|
|
....
|
|
|
|
Depending on the changes in the xml this may not work and you will need
|
|
to make many manual changes plus copy the guest.xml to
|
|
`/etc/libvirtd/qemu` and do a `/sbin/service libvirtd restart`
|
|
|
|
. Insert iptables rule for nc transfer:
|
|
+
|
|
....
|
|
iptables -I INPUT -s <source host> -m tcp -p tcp --dport 11111 -j ACCEPT
|
|
....
|
|
. On the destination host:
|
|
+
|
|
____
|
|
nc -l 11111 | dd of=/dev/mapper/<guest-partition>
|
|
____
|
|
. On the source host:
|
|
+
|
|
....
|
|
dd if=/dev/mapper/guest-partition | nc <desthost> 11111
|
|
....
|
|
+
|
|
Wait for the copy to finish. You can do the following to track how far
|
|
something has gone by finding the dd pid and then sending a 'kill -USR1'
|
|
to it.
|
|
. start the guest on the new host:
|
|
+
|
|
....
|
|
``virsh start guest``
|
|
....
|
|
|
|
. To ensure that the new vm starts automatically after boot run:
|
|
|
|
....
|
|
virsh autostart guest
|
|
....
|
|
|
|
. On the source host, rename storage and undefine guest so it's not
|
|
started.
|
|
. In ansible change the host_vars to reflect the new host
|