
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_swapvm1010 is the vps we need to backup so we now have the LV details we need.
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
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/vpsWe 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_backupNext we need to shutdown the source vps either using SolusVM or the commandline:
# mkdir -p /home/vm1010_backup
# mount /dev/vps/vm1010_backup /home/vm1010_backup
# xm shutdown vm1010Now its time to create the backup:
# dd if=/dev/vps/vm1010_img of=/home/vm1010_backup/vm1010_backup.imgWhen 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.imgTransfer 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/vpsThe following is only for xen pv:
# lvcreate -n vm1010_img --size 10G /dev/vps
# lvcreate -n vm1010_swap --size 256M /dev/vpsMount the LV on the destination node for the backup:
# mkswap /dev/vps/vm1010_swap
# mkfs.ext3 /dev/vps/vm1010_backupTransfer the backup to the destination server:
# mkdir -p /home/vm1010_backup
# mount /dev/vps/vm1010_backup /home/vm1010_backup
# 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_imgUpdating 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 4All 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.
# CleanupWhen 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_backupOn the destination node:
# lvremove /dev/vps/vm1010_backup
# lvremove /dev/vps/vm1010_img
# lvremove /dev/vps/vm1010_swap
# umount /home/vm1010_backup
# lvremove /dev/vps/vm1010_backup
No comments:
Post a Comment