Debian P2V : Différence entre versions
(→Synchronise) |
|||
Ligne 1: | Ligne 1: | ||
− | Debian Physical to Virtual | + | [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 10: | Ligne 11: | ||
At this stage we use temporary IP addresses to avoid conflicts. | At this stage we use temporary IP addresses to avoid conflicts. | ||
− | = Synchronise = | + | = Synchronise and test = |
+ | == Synchronization == | ||
To minimize downtime for the actual migration, one can synchronize the data beforehand: | To minimize downtime for the actual migration, one can synchronize the data beforehand: | ||
{{Box Code|shell|2=<nowiki></nowiki> | {{Box Code|shell|2=<nowiki></nowiki> | ||
Ligne 30: | Ligne 32: | ||
− | {{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 | + | {{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. | 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 '' | + | # Shutdown all services but {{Commande|sshd}} on the source server.<br />I actually boot in ''maintenance mode'' and start {{Commande|sshd}} manually. |
− | # Synchronize ( | + | # Synchronize the data (see above). |
− | # | + | # Change the IP addresses on the physical server, as we want to keep the current IP addresses for our migrated server. |
− | # Mount | + | # 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 | + | # 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 |
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
- Shutdown all services but sshd on the source server.
I actually boot in maintenance mode and start sshd manually. - Synchronize the data (see above).
- Change the IP addresses on the physical server, as we want to keep the current IP addresses for our migrated server.
- 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
- Unmount the image
- Start the virtual machine
Migration done!
Post-install
There are a couple of things that can be done afterwards:
- Configure for pygrub (See Debian and pygrub)
- Uninstall unneeded packages (mdadm, ...)
- ...