Debian P2V : Différence entre versions

Un article de Bulles.
Aller à : navigation, rechercher
 
 
(2 révisions intermédiaires par le même utilisateur non affichées)
Ligne 1: Ligne 1:
Debian Physical to Virtual -- Brain dump; this is very basic...
+
[http://www.debian.org Debian] Physical to Virtual migration.<br />
 +
This is a very basic brain dump of actions taken to migrate a [http://www.debian.org Debian] physical to a [[Xen]] virtual machine. It needs to be reviewed and refined...
  
 
= Prepare =
 
= Prepare =
Ligne 6: Ligne 7:
 
  xen-create-image --hostname=...}}
 
  xen-create-image --hostname=...}}
  
= Synchronise =
+
This is a bit an overkill as we do not really need to install an image in the Virtual Machine, but everything is setup nicely and we can test our configuration.
Synchronize data at any time:
+
 
{{Boite Code|shell|2=<nowiki></nowiki>
+
At this stage we use temporary IP addresses to avoid conflicts.
 +
 
 +
= Synchronise and test =
 +
== Synchronization ==
 +
To minimize downtime for the actual migration, one can synchronize the data beforehand:
 +
{{Box Code|shell|2=<nowiki></nowiki>
 
  mount /dev/<path to disk image> /mnt
 
  mount /dev/<path to disk image> /mnt
 
  rsync \
 
  rsync \
Ligne 25: Ligne 31:
 
  umount /mnt}}
 
  umount /mnt}}
  
Note: if the ''--delete'' option is used, we need to re-add the modules from the Xen Kernel afterwards...
+
 
 +
{{Box Note|This is to be refined and tested. To have an exact copy of the Physical Machine, we should use the ''--delete'' option if we synchronize multiple times; but that would also delete the files from our pre-seeded [[Xen]] environment.<br>
 +
As far as I can see, the only files we really need to keep are the kernel modules, but that needs to be confirmed.
 +
}}
 +
 
 +
== Test ==
 +
Once synchronized the above image can easily be tested
 +
 
 +
Mount the disk image and ''chroot'' it
 +
{{Box Code|shell|2=<nowiki></nowiki>
 +
mount /dev/<path to disk image> /mnt
 +
chroot /mnt}}
 +
 
 +
In the ''chrooted'' environment we need to install the [[Xen]] version of libc6, modify IPs to avoid conflicts and update {{Fichier|/etc/fstab}} to reflect the [[Xen]] disk layout.
 +
We also need to ensure that we only start the services we want/need (''/etc/rcN.d'')!
 +
{{Box Code|shell|2=<nowiki></nowiki>
 +
apt-get install libc6-xen
 +
vi /etc/network/interface
 +
vi /etc/udev/rules.d/z25_persistent-net.rules
 +
vi /etc/fstab
 +
# Any other cleanup
 +
# ...
 +
exit}}
 +
 
 +
Unmount the partition and test the Virtual Server
 +
{{Box Code|shell|2=<nowiki></nowiki>
 +
umount /mnt
 +
xm create -c /etc/xen/<virtual machine>.cfg}}
  
 
= Migrate =
 
= Migrate =
# Shutdown all services but ''ssh'' on the source server
+
# Shutdown all services but {{Commande|sshd}} on the source server.<br />I actually boot in ''maintenance mode'' and start {{Commande|sshd}} manually.
# Synchronize (as above)
+
# Synchronize the data (see above).
# Free / change IPs from the source server
+
# Change the IP addresses on the physical server, as we want to keep the current IP addresses for our migrated server.
# Mount / chroot to the disk image
+
# Mount the disk image and ''chroot'' it as described above. We need to:
 
#* Install ''libc6-xen''
 
#* Install ''libc6-xen''
#* Cleanup fstab
+
#* Cleanup {{Fichier|/etc/udev/rules.d/z25_persistent-net.rules}}
#* ...
+
#* Cleanup {{Fichier|/etc/fstab}}
 +
#* Any other cleanup action
 
# Unmount the image
 
# Unmount the image
# Start the VM
+
# Start the virtual machine
# Configure for pygrub
+
 
 +
Migration done!
 +
 
 +
= Post-install =
 +
There are a couple of things that can be done afterwards:
 +
# Configure for ''pygrub'' (See [[Xen#Debian et pygrub|Debian and pygrub]])
 +
# Uninstall unneeded packages (''mdadm'', ...)
 +
# ...

Version actuelle datée du 11 mars 2008 à 11:34

Debian Physical to Virtual migration.
This is a very basic brain dump of actions taken to migrate a Debian physical to a Xen virtual machine. It needs to be reviewed and refined...

Prepare

Create the Debian Virtual Machine which will receive the Physical Machine data

Code: shell

xen-create-image --hostname=...

This is a bit an overkill as we do not really need to install an image in the Virtual Machine, but everything is setup nicely and we can test our configuration.

At this stage we use temporary IP addresses to avoid conflicts.

Synchronise and test

Synchronization

To minimize downtime for the actual migration, one can synchronize the data beforehand:

Code: shell

mount /dev/<path to disk image> /mnt
rsync \
       --verbose \
       --archive \
       --numeric-ids \
       --hard-links \
       --exclude=/tmp \
       --exclude=/proc \
       --exclude=/dev \
       --exclude=/sys \
       --compress \
       --rsh=ssh \
       <physical machine>:/ \
       /mnt/
umount /mnt


Note: This is to be refined and tested. To have an exact copy of the Physical Machine, we should use the --delete option if we synchronize multiple times; but that would also delete the files from our pre-seeded Xen environment.

As far as I can see, the only files we really need to keep are the kernel modules, but that needs to be confirmed.


Test

Once synchronized the above image can easily be tested

Mount the disk image and chroot it

Code: shell

mount /dev/<path to disk image> /mnt
chroot /mnt

In the chrooted environment we need to install the Xen version of libc6, modify IPs to avoid conflicts and update /etc/fstab to reflect the Xen disk layout. We also need to ensure that we only start the services we want/need (/etc/rcN.d)!

Code: shell

apt-get install libc6-xen
vi /etc/network/interface
vi /etc/udev/rules.d/z25_persistent-net.rules
vi /etc/fstab
# Any other cleanup
# ...
exit

Unmount the partition and test the Virtual Server

Code: shell

umount /mnt
xm create -c /etc/xen/<virtual machine>.cfg

Migrate

  1. Shutdown all services but sshd on the source server.
    I actually boot in maintenance mode and start sshd manually.
  2. Synchronize the data (see above).
  3. Change the IP addresses on the physical server, as we want to keep the current IP addresses for our migrated server.
  4. Mount the disk image and chroot it as described above. We need to:
    • Install libc6-xen
    • Cleanup /etc/udev/rules.d/z25_persistent-net.rules
    • Cleanup /etc/fstab
    • Any other cleanup action
  5. Unmount the image
  6. Start the virtual machine

Migration done!

Post-install

There are a couple of things that can be done afterwards:

  1. Configure for pygrub (See Debian and pygrub)
  2. Uninstall unneeded packages (mdadm, ...)
  3. ...