Xen Migrations
From SolusVM
Contents |
Introduction
This guide has been written to aid you in SAFELY transfering Xen PV & HVM virtual servers between nodes.
Creating a Copy of the Virtual Server
We need to find the correct LV that needs backing up. You do this by issuing lvdisplay in ssh on the source node:
[root@herculis ~]# lvdisplay --- Logical volume --- LV Name /dev/vps/vm1010_img VG Name vps LV UUID pFtowh-vnxa-DXeE-KqqZ-N1h1-IQ2z-4VFSad LV Write Access read/write LV Status available # open 0 LV Size 10.00 GB Current LE 160 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:52 --- Logical volume --- LV Name /dev/vps/vm1010_swap VG Name vps LV UUID iBGJKk-do9U-5tGM-fqZT-fD1U-Ejqa-Dih3VT LV Write Access read/write LV Status available # open 0 LV Size 256.00 MB Current LE 4 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:53
vm1010 is the vps we need to backup so we now have the LV details we need.
Next we need to find some space on the the server to make the backup to. If you have enough space on the normal / partition you can put the backup there but in most cases you won't so you need to create an LV to put the backup into:
lvcreate -n vm1010_backup --size 15G /dev/vps
We created an new LV called vm1010_backup with a size 5GB bigger than the source LV.
Now format the new LV and mount it:
mkfs.ext3 /dev/vps/vm1010_backup mkdir -p /home/vm1010_backup mount /dev/vps/vm1010_backup /home/vm1010_backup
Next we need to shutdown the source vps either using SolusVM or the commandline:
xm shutdown vm1010
Now its time to create the backup:
dd if=/dev/vps/vm1010_img of=/home/vm1010_backup/vm1010_backup.img
When complete the backup will be stored in /home/vm1010_backup:
ls -lh /home/vm1010_backup -rw-r--r-- 1 root root 10G May 29 00:10 vm1010_backup.img
Transfer to the destination node
On the destination node you need to create a set of LV's for the backup and the new vps:
lvcreate -n vm1010_backup --size 15G /dev/vps lvcreate -n vm1010_img --size 10G /dev/vps
The following is only for xen pv:
lvcreate -n vm1010_swap --size 256M /dev/vps mkswap /dev/vps/vm1010_swap
Mount the LV on the destination node for the backup:
mkfs.ext3 /dev/vps/vm1010_backup mkdir -p /home/vm1010_backup mount /dev/vps/vm1010_backup /home/vm1010_backup
Transfer the backup to the destination server:
scp -C /home/vm1010_backup/vm1010_backup.img root@remote.server.com:/home/vm1010_backup/
Restoring the Virtual Server
Once the transfer is complete we can restore the backup to the new LV:
dd if=/home/vm1010_backup/vm1010_backup.img of=/dev/vps/vm1010_img
Updating SolusVM and Starting the Virtual Server
When the restore is complete you need to update SolusVM so it knows where the vps has been moved to.
In SSH on your master do the following:
/scripts/vm-migrate <VSERVERID> <NEWNODEID>
<VSERVERID> is the ID listed in your VM list in SolusVM <NEWNODEID> is the ID of the node listed in your node list in SolusVM
Example moving vserverid 150 to node 4:
/scripts/vm-migrate 150 4
All you need to do now is boot up the vps on the new node by clicking the reboot button within SolusVM. You must use the reboot button so it writes a new configuration file on the new slave.
Cleanup
When you have confirmed the vps has been moved and is up and running on the new slave you need to remove any LV's and mount points you made.
On the source node:
umount /home/vm1010_backup lvremove /dev/vps/vm1010_backup lvremove /dev/vps/vm1010_img lvremove /dev/vps/vm1010_swap
On the destination node:
umount /home/vm1010_backup lvremove /dev/vps/vm1010_backup
Tips
To see the progress of dd open a new ssh terminal and run the following:
ps ux | awk '/dd/ && !/awk/ {print $2}' | xargs kill -s USR1 $1
In the dd terminal you will see the output.
