[Gllug] Cloning running servers

Vidar Hokstad vidar at aardvarkmedia.co.uk
Wed May 14 11:33:22 UTC 2008


On 14 May 2008, at 11:52, Simon Wilcox wrote:
> What I'm looking for is a tool that can image a running partition and
> copy it to the new device. The hardware profile will be different but
> we're running stock kernels so I'm hopeful that they will cope.
>
> Once we have the server running under VMware we can use rsync to copy
> across the few changing files during a short downtime window.
>
> It's getting the image across in the first place that I'm a bit  
> stuck on.

You should be able to create an image with an empty disk and boot from
an ISO image containing a LiveCD. Here's a reasonable howto (ignore
the "install OS bit" - use a LiveCD that contains enough tools for you
to partition the disk and rsync over your "old" machine).

Once that's done, this is a rough idea of how I did something similar
to migrate a server hosting several of our clients, including fairly  
high
traffic sites like www.squaremeal.co.uk (they've since been migrated  
onto
a cluster) into an OpenVZ container, with practically no downtime. Some
of it is OpenVZ specific, but the overall approach should work for most
virtualization methods:

- I first rsync'ed the whole server into the directory used as the base
- I created the container config file.
- Assigned a new IP address (OpenVz will enforce this, so the virtual
   container couldn't suddenly cause conflicts)
- Started the container
- I first tested that everything worked in the new setup, and shut down
   a few services etc. that are not required in an OpenVZ container
   (NTP for example gets handled on the host)
- Then I shut down and did one last rsync.
- Started it again.
- I assigned the old ip addresses to the server one by one.
- I then added the routing on the host required to reach the container.
- Then I started unilaterally sending ARP message from the container
    using "arpsend", while in a different terminal I shut down the  
relevant
    alias interface on the host I was moving from with ifconfig
- Repeat for all IP addresses to move.

 From a user POV, requests appeared to hang for up to a minute at most
per IP, though in practice requests got sent to the new one much quicker
(the purpose of the ARP send's being to ensure our firewall found the  
new
server right away instead of waiting for the arp cache entries to time  
out)

The only thing we lost was a couple of minutes of Apache log entries
and PHP sessions (which may of course be a dealbreaker depending on what
will happen if the sessions disappear - if something like that is an  
issue,
switching to a shared session mechanism first may be worthwhile) from
the last rsync until the IP takeover.

Vidar


-- 
Vidar Hokstad
Technical Director
Aardvark Media Limited
Mobile: 0795 867 7857
Direct Dial: 020 7183 2740

2 Fulham Business Exchange
The Boulevard
Imperial Wharf
London
SW6 2TL




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.lug.org.uk/pipermail/gllug/attachments/20080514/16b54b00/attachment.html>
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list