📜 ⬆️ ⬇️

Migrating VMs from Xen 3.2 to XenServer 6.2 in Hetzner

A bit of background


In 2010, for a private project, I got myself a small dedicated server at hezner.de. As time went on, hardware improved, Linux distributions were removed from those. support, new tasks and opportunities appeared, and the resources for the full upgrade of software on the server were sorely lacking.

Since the old server was virtualized, it was thought to take a new server and migrate all the old equipment to it, especially since hetzner had an EX40 server at an interesting price. Compared to the old X3, the rental price grew slightly (about 8 euros if paid without VAT), but in terms of performance, this was a huge breakthrough. The lack of a large amount of free time and a bit of installation cost (setup fee) per server hampered migration.

A couple of weeks ago, I accidentally discovered that Hetzner is holding a campaign in July and is giving these pieces of iron without a setup fee. Laziness and the toad were defeated, and there was some free time to carry out the saber process.
')
The action is held only in July, so who needs it - fly around, do not skimp, buy a painting!

Installing XenServer


Much has been written about the installation and configuration of XenServer, so this point can be omitted. Detailed instructions for installation and configuration are also given in the hetzner Wiki .

I posted the XenServer distribution kit and the answer file on the old server; there were no problems with the installation speed.

Immediately after installing XenServer, I recommend adding an unprivileged user and close root access to ssh, as well as close access to the server for all networks except their own (if this is possible, of course). In the future, you can install OpenVPN on one of the virtual machines and use all the advantages of managing via VPN. After setting up these simplest server protection mechanisms, you can safely proceed to the preparation of the patient.

I recommend combining disks (by the way, I’ve got new ones) in RAID and split it with this consideration so that there is still some room left for connecting to dom0 as a repository of ISO images, backups, uploading software updates, and so on.

Over the past year, since the release of 6.2, many updates have been released, so immediately after installing XenServer, it is highly recommended to update the software and install all the patches. It is better to start with SP1, after installing which, a list of patches can be viewed through XenCenter and downloaded from the web at the indicated links (Tools / Check for Updates menu).
Automatic update if you have not purchased TP, is impossible via XenCenter. You must use CLI.
To update the software, you need to copy all the patches in the dom0, unpack and execute the following commands for each patch:
xe patch-upload file-name=/mnt/disk/1.xsupdate xe patch-pool-apply uuid=UUID___ 

After installing updates, you need to restart the services with the command:
 xe-toolstack-restart 

The list of installed patches can be checked with the command:
 xe patch-list 

The XenServer 6.2 version uses Open vSwitch by default, so 99% of articles and comments on configuring the network environment do not fully fit (the part about configuring the xebr0: 1 network interface, although you can probably live with the dummy interface). This problem is quite easy to manage: you can add additional local networks and interfaces to XenCenter (you need to select a server and open the Networking tab).
After setting up an additional network, do not forget to configure iptables (Firewall and NAT) to communicate with the outside world (if you use private networks).

Migration of virtual machines


At the time of the idea of ​​migrating virtual machines, my sclerosis remembered that I had virtualized my servers using LVM (almost guessed :). Fortunately, logging on to the machine, I found that I had Xen 3.2 installed (para-virtualization was used), and this greatly simplified the task.

To import virtual machines, I used the xva.py script, which can be downloaded here .
On the Xen 3.2 server for each virtual machine, you need to run the command:
 python xva.py -c /etc/xen/VM.cfg -n --sparse -s IP_XenServer --username=root --password="Password" 

The virtual machine will automatically be transferred to the new server in a few minutes. The export through the file took place many times longer (it didn’t measure the time, but the VM with a 32Gb disk was exported for more than an hour).
If immediately after starting the script falls out with the message
 Unauthorised response from server. Exiting 

Check if you are using a password. I had a problem with a dot (".").

If, after successfully completing the export / import, you received the message below, then you will need to tweak something else on the dom0 and in the virtual machine.
 VM Successfully streamed With the options you supplied, you will need to SFTP/SCP the kernel/initrd to the server manually Create the /boot/guest/208f7a74-126e-11e4-8a8c-002185153241 directory Copy /boot/vmlinuz-2.6.26-2-xen-amd64 to /boot/guest/208f7a74-126e-11e4-8a8c-002185153241/vmlinuz and copy /boot/initrd.img-2.6.26-2-xen-amd64 to /boot/guest/208f7a74-126e-11e4-8a8c-002185153241/initrd Copy these to _all_ the nodes in the pool 

Namely, copy the vmlinuz- * and initrd- * files from dom0 Xen 3.2 to dom0 XenServer.
Since I needed to transfer 3 virtual machines with one kernel, I did not create separate directories for them (maybe in vain), but created one / boot / guest / lenny directory into which I placed the specified files.

In order for these virtual machines to boot, you need to properly configure the settings of the PV-kernel, PV-ramdisk. In my case, I also had to clear the PV-bootloader parameter, which interfered with my work.
To configure the parameters of virtual machines, you must run the following commands:
 xe vm-param-set uuid=UUID_VM PV-bootloader xe vm-param-set uuid=UUID_VM PV-kernel="/boot/guest/lenny/vmlinuz" xe vm-param-set uuid=UUID_VM PV-ramdisk="/boot/guest/lenny/initrd" 

UUID_VM - virtual machine identifier (can be viewed with the xe vm-list command)

Now you can try to boot. In case of failure, do not turn off the virtual machine, but look at the path to the root device, under which disks / partitions in your virtual machine are visible (in the XenCenter, the Storage tab, “Device Path” parameter). You must edit the PV-args parameter or via CLI or XenCenter. I set the following parameters:
 root=/dev/xvda ro clocksource=jiffies 

We are trying to load again.
After successfully loading the OS, do not forget to fix the / etc / fstab file (specify the correct location of the swap) and install the XenServer Tools. For Debian Lenny, the xe-guest-utilities_6.2.0-1137_amd64.deb package is suitable.

It seems to be all. It remains only until the end of the month to backup the old server and give back to Hetzner.
Vadim pavlov

Source: https://habr.com/ru/post/231301/


All Articles