Upgrade Xen Server 6.02 to 6.2 on Hetzner Server

Prepare XenServer 6.02

Make sure to CD are attached:

xe vbd-list type=CD empty=false

If you see something dettach it:

xe vbd-eject uuid=

Make notes of everything, partitions tables, raid config, lvm/vg/lv config, network config everything you need.

Backup

Before we start we make a backup of the configuration with:

xe pool-dump-database file-name=xendb

Backup the file.

Use the XenClient to download all virtual machine in case you damage something.

XenServer Installieren

Man muss sich auf seinem Hetzner Server ein Minimal-OS anlegen, sich einloggen und dann die Netzwerkkonfiguration notieren (Debian/Ubuntu: /etc/networking/interfaces, CentOS /etc/sysconfig/network-scripts/ifcfg-eth0). Wichtig ist u.a. auch die Gateway-IP. Das MinimalOS auf jeden Fall so installieren, das auf keinen Fall etwas auf die zweite Festplatte geschrieben wird. Sonst muss das komplette Backup zurück kopiert werden, was dauert.

Dafür im Robot einloggen und die Installation starten, ich verwende immer das neueste Ubuntu. Achtung im Standard werden alle Daten auf allen Festplatte gelöscht, man muss sich sehr schnell einloggen mit:

screen -x

den Installer anzeigen und diesen mit CTRL+C abbrechen. Danach mit

installimage

die Installation manuell starten und die zweite Festplatte rausnehmen.

1.1 Xenserver Download + auf Webserver entpacken

Xenserver ISO von hier auf einen eigenen, separaten Webserver downloaden: http://xenserver.org/overview-xenserver-open-source-virtualization/download.html

wget http://downloadns.citrix.com.edgesuite.net/akdlm/8159/XenServer-6.2.0-install-cd.iso
mdconfig -a -t vnode -f XenServer-6.2.0-install-cd.iso -u 0
mount -t cd9660 /dev/md0 /mnt/mnt
cd <yourdirectory>
cp -a /mnt/mnt/* .
umount /mnt/mnt
mdconfig -d -u 0

Answerfile generieren und zum webserver kopieren

Hier als Beispiel eine XML-Datei, die man z.B. xenserver.xml nennen kann. Achtung: Unbedingt die richtige IP-Adresse für den Server und den Gateway eintragen!

<installation mode="fresh" srtype="lvm">
<primary-disk gueststorage="yes">sda</primary-disk>
<keymap>de</keymap>
<hostname>xenserver-ex4s</hostname>
<root-password>my_password</root-password>
<source type ="url">http://xx.xx.xx.xx/xenserver/</source>
<!-- No Post install scripts configured -->
<admin-interface name="eth0" proto="static">
<ip>Hetzner Server IP</ip>
<subnet-mask>255.255.255.224</subnet-mask>
<gateway>Hetzner Gateway IP</gateway>
</admin-interface>
<nameserver>213.133.99.99</nameserver>
<nameserver>213.133.100.100</nameserver>
<timezone>Europe/Berlin</timezone>
<time-config-method>ntp</time-config-method>
<ntp-servers>ntp</ntp-servers>
<ntpservers>83.246.120.75</ntpservers>
<ntpservers>213.9.73.106</ntpservers>
<ntpservers>188.40.34.195</ntpservers>
</installation>

Diese Datei sollte im gleichen Verzeichnis gespeichert werden, wie der Rest des Hauptverzeichnisses der Xenserver-CD.

Anpassungen für den PXE-Boot

Auf dem neuen Server: folgende Dateien vom eigenen Webserver auf den für die XenServer-Installation vorgesehene Server kopieren:

cd /boot
HOST=xx.xx.xx.xx
wget http://$HOST/xenserver/install.img
wget http://$HOST/xenserver/boot/vmlinuz
wget http://$HOST/xenserver/boot/xen.gz

Nun auf dem neuen Hetzner-Server die Bootloader-Konfiguration anpassen. Ich hatte ein Ubuntu 12.04 minimal gewählt, daher hier Grub2. In der /boot/grub/grub.cfg den ersten menuentry anpassen (siehe letzte 3 Zeilen):

if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.11.0-15-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod raid
insmod mdraid1x
insmod part_gpt
insmod ext2
set root='(hd0/gpt2)'
search --no-floppy --fs-uuid --set=root 8d59c7f2-b560-4286-9346-60cee5c9368e
multiboot /xen.gz dom0_mem=752M acpi=off nosmp noapic noirqbalance
module /vmlinuz answerfile=http://xx.xx.xx.xx/xenserver/xenserver.xml install
module /install.img
}

Achtung: Die URL vom answerfile muss mit der IP des Servers angegeben werden, nicht mit dem Hostnamen. Daher aufpassen, wenn man NameVirtualHosts o.ä. einsetzt!

Reboot

Mit reboot den Server neu starten. Nun sollte die XenServer-Installation starten, was man leicht auf dem externen Webserver per “tail -f /var/log/apache2/access.log” prüfen kann.

Install updates

Sich am XEN Server per ssh einlogen.

wget http://downloadns.citrix.com.edgesuite.net/akdlm/8707/XS62ESP1.zip
unzip XS62ESP1.zip
rm XS62ESP1.zip
PASSWORD=<PASSWORD>
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1
reboot
wget http://downloadns.citrix.com.edgesuite.net/akdlm/8737/XS62ESP1002.zip
unzip XS62ESP1002.zip
rm XS62ESP1002.zip
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1002.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1002

wget http://downloadns.citrix.com.edgesuite.net/akdlm/8736/XS62E014.zip
unzip XS62E014.zip
rm XS62E014.zip
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62E014.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62E014
reboot

wget http://downloadns.citrix.com.edgesuite.net/9031/XS62ESP1003.zip
unzip XS62ESP1003.zip
rm XS62ESP1003.zip
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1003.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1003
reboot

wget http://downloadns.citrix.com.edgesuite.net/9058/XS62ESP1005.zip
unzip XS62ESP1005.zip
rm XS62ESP1005.zip
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1005.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1005
reboot

Download driver from http://www.nvidia.com/object/virtual-gpus.html#downloadGRID
rpm -ev NVIDIA-vgx-xenserver
rpm -iv NVIDIA-vgx-xenserver-6.2-331.59.i386.rpm

wget http://downloadns.citrix.com.edgesuite.net/9279/XS62E015.zip
unzip XS62E015.zip
rm XS62E015.zip
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62E015.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62E015
reboot

wget http://downloadns.citrix.com.edgesuite.net/9491/XS62ESP1008.zip
unzip XS62ESP1008.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1008.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1008
reboot

wget http://downloadns.citrix.com.edgesuite.net/9617/XS62ESP1009.zip
unzip XS62ESP1009.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1009.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1009
reboot

wget http://downloadns.citrix.com.edgesuite.net/9703/XS62ESP1013.zip
unzip XS62ESP1013.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1013.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1013
reboot

wget http://downloadns.citrix.com.edgesuite.net/9708/XS62ESP1014.zip
unzip XS62ESP1014.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1014.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1014
reboot

wget http://downloadns.citrix.com.edgesuite.net/10128/XS62ESP1015.zip
unzip XS62ESP1015.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1015.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1015
reboot

wget http://downloadns.citrix.com.edgesuite.net/10134/XS62ESP1012.zip
unzip XS62ESP1012.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1012.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1012
xe-toolstack-restart

wget http://downloadns.citrix.com.edgesuite.net/10174/XS62ESP1016.zip
unzip XS62ESP1016.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1016.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1016
reboot

wget http://downloadns.citrix.com.edgesuite.net/10193/XS62ESP1017.zip
unzip XS62ESP1017.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1017.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1017

wget http://downloadns.citrix.com.edgesuite.net/10206/XS62ESP1019.zip
unzip XS62ESP1019.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1019.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1019

wget http://downloadns.citrix.com.edgesuite.net/10325/XS62ESP1021.zip
unzip XS62ESP1021.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1021.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1021

wget http://downloadns.citrix.com.edgesuite.net/10309/XS62ESP1020.zip
unzip XS62ESP1020.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1020.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1020

wget http://downloadns.citrix.com.edgesuite.net/10564/XS62ESP1025.zip
unzip XS62ESP1025.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1025.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1025

wget http://downloadns.citrix.com.edgesuite.net/10567/XS62ESP1024.zip
unzip XS62ESP1024.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1024.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1024

wget http://downloadns.citrix.com.edgesuite.net/10596/XS62ESP1026.zip
unzip XS62ESP1026.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1026.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1026

wget http://downloadns.citrix.com.edgesuite.net/10661/XS62ESP1027.zip
unzip XS62ESP1027.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1027.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1027

wget http://downloadns.citrix.com.edgesuite.net/10654/XS62ESP1028.zip
unzip XS62ESP1028.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1028.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1028
xe-toolstack-restart

wget http://support.citrix.com/filedownload/CTX201635/XS62ESP1030.zip
unzip XS62ESP1030.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1030.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1030

wget http://support.citrix.com/filedownload/CTX201763/XS62ESP1031.zip
unzip XS62ESP1031.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1031.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1031

wget --no-check-certificate https://support.citrix.com/filedownload/CTX201739/XS62ESP1032.zip
unzip XS62ESP1032.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1032.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1032

wget --no-check-certificate https://support.citrix.com/filedownload/CTX202437/XS62ESP1033.zip
unzip XS62ESP1033.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1033.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1033

wget http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX205227/XS62ESP1039.zip
unzip XS62ESP1039.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1039.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1039

wget http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX205354/XS62ESP1040.zip
unzip XS62ESP1040.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1040.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1040

wget http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX207935/XS62ESP1041.zip
unzip XS62ESP1041.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1041.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1041

wget http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX208512/XS62ESP1042.zip
unzip XS62ESP1042.zip
rm !$
rm XS62ESP1042-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1042.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1042

wget http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX214990/XS62ESP1045.zip
unzip XS62ESP1045.zip
rm !$
rm XS62ESP1045-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1045.xsupdate
rm XS62ESP1045.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1045

wget "http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX216555/XS62ESP1047.zip"
unzip XS62ESP1047.zip
rm !$
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1047.xsupdate
rm XS62ESP1047.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1047
xe-toolstack-restart

wget "http://support.citrix.com/supportkc/filedownload?uri=/filedownload/CTX216461/XS62ESP1048.zip"
unzip XS62ESP1048.zip
rm !$
rm XS62ESP1048-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1048.xsupdate
rm XS62ESP1048.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1048


Download patch and upload it manually to the server
unzip XS62ESP1051.zip
rm !$
rm XS62ESP1051-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1051.xsupdate
rm XS62ESP1051.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1051

Download patch and upload it manually to the server
unzip XS62ESP1062.zip
rm !$
rm XS62ESP1062-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1062.xsupdate
rm XS62ESP1062.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1062

Download patch and upload it manually to the server
unzip XS62ESP1066.zip
rm !$
rm XS62ESP1066-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1066.xsupdate
rm XS62ESP1066.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1066

Download patch and upload it manually to the server
unzip XS62ESP1068.zip
rm !$
rm XS62ESP1068-src-pkgs.tar.bz2
xe patch-upload -s localhost -u root -pw $PASSWORD file-name=XS62ESP1068.xsupdate
rm XS62ESP1068.xsupdate
xe -s localhost -u root -pw $PASSWORD patch-pool-apply uuid=<uuid you saw command before>
xe patch-list -s localhost -u root -pw $PASSWORD name-label=XS62ESP1068

Software-RAID1

Nach der Installation sollte der Xenserver per SSH mit dem im Answerfile eingegebenen Passwort erreichbar sein. XenServer 6 nutzt GPT statt MBR zur Einrichtung der Partitionen. Die 3 TB Festplatten eines EX4 etc. werden damit voll ausgenutzt.

Now it is a good time to copy you ssh key to the server.

zweite Festplatte sdb einrichten

/dev/sda sollte nun 3 Partitionen enthalten. Um die Partitionen gleichmäßig zu übertragen lässt man sich die Partitionen auf /dev/sda anzeigen:

sgdisk -p /dev/sda

Partitionen auf /dev/sdb löschen:

sgdisk --zap-all /dev/sdb

Now reboot the system because the kernel uses the old table of the harddisk.

reboot

Neue GPT Tabelle anlegen:

sgdisk --mbrtogpt --clear /dev/sdb

Anfang und Ende der jeweiligen Partitionen in folgende Befehle übernehmen (hier von meiner config übernommen):

sgdisk --new=1:2048:8388641 /dev/sdb
sgdisk --typecode=1:fd00 /dev/sdb
sgdisk --new=2:8390656:16777249 /dev/sdb
sgdisk --typecode=2:fd00 /dev/sdb
sgdisk --new=3:16779264:1465149134 /dev/sdb
sgdisk --typecode=3:fd00 /dev/sdb
sgdisk /dev/sda --attributes=1:set:2
sgdisk /dev/sdb --attributes=1:set:2
sgdisk --typecode=1:fd00 /dev/sda
sgdisk --typecode=2:fd00 /dev/sda
sgdisk --typecode=3:fd00 /dev/sda

Anschließend

RAID anlegen

Das von Hetzner eingerichtete RAID1 ist teilweise noch vorhanden, XenServer hat sich auf /dev/sda 3 Partitionen eingerichtet und /dev/sdb entsprechend dem Answerfile dieses Beispiels unangetastet gelassen. Die Reste des RAIDs werden zunächst aufgelöst:

mdadm --stop /dev/md0
mdadm --stop /dev/md1

Neues RAID anlegen:

mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb3

Optional: Bitmaps für jedes RAID-Device anlegen. Bitmaps haben geringen Einfluss auf die Performance aber reduzieren deutlich die Zeit, in der ein fehlgeschlagenes Array neu synchronisiert werden muss.

mdadm --grow /dev/md0 -b internal
mdadm --grow /dev/md1 -b internal
mdadm --grow /dev/md2 -b internal

Die neue RAID-Konfiguration in eine aktualisierte mdadm.conf speichern:

mdadm --examine --scan > /etc/mdadm.conf

Copy Store Manager Data to RAID

pvcreate /dev/md2 -ff
vgextend VG_<TAB> /dev/md2
pvmove /dev/sda3 /dev/md2

Remove /dev/sda3 from the SR volume group

vgreduce VG_<TAB> /dev/sda3
pvremove /dev/sda3

After the procedure explained on the hetzner site is not working we only make sure that our vms are on the raid:

mdadm -a /dev/md2 /dev/sda3

Continue now on the ISO mount.

mkfs.ext3 /dev/md0
mount /dev/md0 /mnt
cd /
cp -axv . /mnt

Nun muss die Datei /mnt/etc/fstab angepasst werden

vi /mnt/etc/fstab

Ersetze den Parameter root=LABEL=root-xxxxxx mit root=/dev/md0 (ohne LABEL=).

Neue Initrd erstellen:

mkdir /mnt/root/initrd-raid
mkinitrd -v --fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-`uname -r`-raid.img `uname -r`
cd /mnt/root/initrd-raid
zcat initrd-`uname -r`-raid.img | cpio -i

Die Datei ‘init’ bearbeiten und nach ‘raidautorun /dev/md0’ folgendes einfügen:

raidautorun /dev/md1
raidautorun /dev/md2

Die neue Ramdisk nun nach /mnt/boot kopieren

find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-`uname -r`-raid.img
rm /mnt/boot/initrd-2.6-xen.img

ln -s initrd-`uname -r`-raid.img /mnt/boot/initrd-2.6-xen.img
nano /mnt/boot/extlinux.conf

Nun “root=LABEL=root-xyz” mit “root=/dev/md0” in allen Menüeinträgen ersetzen.

Nun den MBR für GPT auf /dev/sdb einrichten:

cat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdb
cd /mnt
extlinux  --raid -i boot/
umount /dev/md0
sync

Das RAID-Array ist nun fast komplett, es fehlt lediglich /dev/sda1. Dazu nun ins Rescue System rebooten (im Robot Rescue System aktivieren, Passwort kopieren, Server per Hardware-Reset neu booten). Im Rescue System ausführen:

mdadm -a /dev/md0 /dev/sda1

Das RAID-Array muss sich nun erstmals synchronisieren, was einen Augenblick lang(!) dauert. Den Fortschritt kann man wie folgt beobachten: watch -n 1 cat /proc/mdstat

Lokale ISO Libary einbinden

Xenserver 6.0 bietet keine Moeglichkeit ISO Images im lokalen Storage anzubieten. Um dies dennoch zu ermoeglichen, wird im LVM des Datenbereiches ein neues LV angelegt und per lokalem NFS Server durchgereicht. Es ist nicht performant, aber es erfüllt seinen Zweck. Quelle: http://forums.citrix.com/thread.jspa?messageID=1393861&tstart=0

Eigene VG finden

vgscan
#Reading all physical volumes. This may take a while...
#Found volume group "VG_XenStorage-709d46ed-8193-d470-4ab8-21953af4f863" using metadata type lvm2

Neues LVM anlegen create new lvm

(bsp mit 20 GB)

lvcreate -L 20G -n ISO VG_XenStorage-<meineid>
#Logical volume "ISO" created

Filesystem anlegen

mkfs.ext3 /dev/VG_XenStorage-<meineid>/ISO

/etc/exports anpassen

mkdir /ISO
echo "/ISO 127.0.0.1(rw,no_root_squash,sync)" >> /etc/exports

NFS und Portmappen starten und rebootfest aktivieren

chkconfig --level 345 nfs on
chkconfig --level 345 portmap on
service nfs start
service portmap start

Mount beim boot

Am Ende des Files folgendes hinzufuegen:

lvchange -a y /dev/VG_XenStorage-<meineid>/ISO

Edit /etc/fstab and add:

/dev/VG_XenStorage-72b9dcb4-0881-54ff-4699-6447bbf8099d/ISO     /ISO    ext3    defaults        0       0

Mount the ISO lib:

mount /ISO

ISO Libray in XenCenter eintragen

Im XenCenter kann man nun eine neue Storage-Library hinzufügen, Typ “NFS ISO”. Als Mountpoint “localhost:/ISO” angeben

Netzwerkkonfiguration

To fix problem with the network card modify /etc/modprobe.conf

options r8169 use_dac=1

Host als Router konfigurieren

Der XenServer wird durch Änderungen in der Datei /etc/sysctl.conf als Router konfiguriert (die ersten paar Zeilen bis einschließlich net.ipv4.ip_forward = 0 durch die folgenden ersetzen):

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1

# Controls proxy arp
net.ipv4.conf.default.proxy_arp = 1

# Turn off redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.xenbr0.send_redirects = 0

Die Einstellungen sind nun nach jedem Neustart aktiv. Sie lassen sich aber auch ohne Neustart direkt mit dem sysctl -p Befehl anwenden:

sysctl -p

Disable Firewall on XEN host

Disable the security level:

system-config-securitylevel-tui

IPv4

For the xen host, insert the gateway your get from Hetzner.

On the VMs use as gateway the ip address from the xen-host.

You have to activate the MACs on a Hetzner interface.

If you have a subnet: Create the file /etc/sysconfig/network-scripts/ifcfg-xenbr0:1 with the following settings:

DEVICE=xenbr0:1
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.224
IPADDR=192.168.99.1

Start the interface with:

ifup xenbr0:1

IPv6

At first request a IPv6-Subnet (/64) from Hetzner.

The XenServer 6.2 has a bug and the command modprobe ipv6 is not sucessfully, so we use a work-around. Edit the file /etc/sysconfig/network-scripts/network-functions-ipv6 in function ipv6_test() modify line 180:

old
modprobe ipv6

change it to
modprobe esp6

Edit /etc/sysconfig/network

NETWORKING_IPV6=yes
IPV6_DEFAULTDEV=xenbr0
IPV6_DEFAULTGW=fe80::1

Execute:

ip addr add 2a01:4f8:101:2046::2/64 dev xenbr0
route -A inet6 add default gw fe80::1 dev xenbr0

Create a script in /etc/init.d/network6:

#!/bin/bash
#
# network6      This starts and stops ipv6 on xenbr0
#
# chkconfig: 2345 15 85
# description: ipv6 configuration
#
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# Von Hetzner zugewiesenes Gateway
IPV6GATEWAY=fe80::1
# Eigene Adresse und eigenes Subnetz
IPV6HOSTADDR=2a01:4f8:101:2046::2/64

usage () {
   echo "Usage: service $prog {start|stop}"
   RETVAL=1
}
start () {
  # Configure our ip address
  ip addr add $IPV6HOSTADDR dev xenbr0
  # Configure routing to hetzner gateway
  route -A inet6 add default gw fe80::1 dev xenbr0

}
case "$1" in
   start) start; RETVAL=$? ;;
   *) usage ; RETVAL=2 ;;
esac
exit $RETVAL
########

Make it executable:

chmod +x network6

Add it to start scripts:

chkconfig network6 on

In den jeweiligen VMs (so sie denn mit Linux laufen) nimmt man dann folgende Einstellungen vor:

ip addr add 2a01:4f8:161:xxx::y/64 dev eth0
ip route add default via 2a01:4f8:161:xxx::2

Treiber für die Netzwerkkarte austauschen (optional)

Der standardmäßig im XenServer geladene Treiber (r8169) für die Realtek-Netzwerkkarte produziert unter Umständen Paketverluste. Daher muss auf einen alternative Treiber umgesattelt werden: r8168. Um den Netzwerkkartentreiber zu kompilieren, benötigt man das zur eigenen XenServer-Version passende Driver Development Kit (DDK), welches auf der Citrix Seite heruntergeladen werden kann: https://www.citrix.com/downloads/xenserver/product-software/xenserver-62

cd /ISO
wget http://download.citrix.com.edgesuite.net/6764/XenServer-6.0.2-XS602E005-ddk.iso

Vorerst sollte zusätzlich mittels XenCenter das VM Storage als Default markiert werden (Rechtsklick -> Default Storage) da sonst der xe vm-import Befehl nicht funktioniert. ISO Mounten:

mkdir /mnt/iso
mount -o loop /local/iso/XenServer-6.2.0-SP1-ddk.iso /mnt/iso

DDK VM Importieren:

xe vm-import filename=/mnt/iso/ddk/ova.xml

Im XenCenter muss dann noch ein Netzwerkdevice zur Virtuellen Maschine hinzugefügt werden, danach kann man die Maschine starten und ein root Passwort setzen mit dem man sich dann einloggen kann. Nun tragen wir die richtigen Netzwerkeinstellungen für die VM ein: /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
IPADDR=IP-ADRESSE-DER-VM
NETMASK=255.255.255.192
ONBOOT=yes
TYPE=ethernet

/etc/sysconfig/network-scripts/route-eth0

IP-ADRESSE-DER_VM dev eth0 scope link
default via IP-DES-XENSERVERS-BZW-BEI-IP-NETZ-DIE-DES-xenbr0:1

/etc/resolv.conf

nameserver 213.133.99.99
nameserver 213.133.100.100

Nun den Treiber ziehen, entpacken und kompilieren:

cd /root
wget http://r8168dl.appspot.com/files/r8168-8.038.00.tar.bz2
tar xjf r8168-8.038.00.tar.bz2
cd r8168-8.031.00
make all

Den neuen Treiber (r8168.ko) auf das Hostsystem übertragen nach: /lib/modules/2.6.32.43-0.4.1.xs1.8.0.853.170791xen/kernel/drivers/net/

Dem Treiber dann die richtigen Rechte geben:

chmod 0744 /lib/modules/2.6.32.43-0.4.1.xs1.8.0.853.170791xen/kernel/drivers/net/r8168.ko

Nun den neuen Treiber in die /etc/modprobe.conf eintragen: echo “alias eth0 r8168” > /etc/modprobe.conf

Danach den neuen Treiber aktivieren und den Server neustarten (Achtung, nach Ausführung des folgenden Befehls startet der Server automatisch neu!):

rmmod r8169 && depmod -a && modprobe r8168 && reboot

Wenn alles richtig gelaufen ist, wird der neue Treiber für die Netzwerkschnittstelle genutzt:

lspci -nnk | grep -i net -A2

In der letzten Zeile sollte stehen: “Kernel driver in use: r8168”

Virtuelle Maschinen von einem anderen (älteren) XenServer übertragen

Der XenServer ist zum Glück recht flexibel, was die Übertragung von virtuellen Maschinen eines anderen XenServer-Hosts angeht. Im Grunde gibt es viele Möglichkeiten, eine davon ist z.B. das remote-mounten eines Verzeichnisses (per NFS) auf dem neuen XenServer-Host vom alten XenServer-Host aus. In dieses Verzeichnis wird dann eine VM nach der anderen exportiert (per “xe vm-export uuid=xxx-xxx filename=vm1.xva”) und jeweils auf dem neuen Host wieder importiert (“xe vm-import filename=vm1.xva”).

Enable email notifications for smartd and mdadm

Install missing mail:

wget http://vault.centos.org/5.5/os/x86_64/CentOS/mailx-8.1.1-44.2.2.x86_64.rpm
rpm -Uhv mailx-8.1.1-44.2.2.i386.rpm

Edit /etc/ssmtp/ssmtp.conf

root=postmaster
mailhub=>mailhub>:465
rewriteDomain=<domain>
hostname=<domain>
UseTLS=YES
UseTLSCert=NO
AuthUser=<user>
AuthPass=<password>

Copy the file to /etc/mail-alarm.conf:

cp /etc/ssmtp/ssmtp.conf /etc/mail-alarm.conf

Edit /etc/smartd.conf

DEVICESCAN -a -m root@<domain> -M test

Edit /etc/mdadm.conf

MAILADDR root@<domain>

To test it, start the smartd:

/etc/init.d/smartd restart

To test mdadm:

mdadm --monitor --scan --test --oneshot

You should have now an email from smartd and mdadm in your mailbox.

Install screen

wget http://vault.centos.org/5.5/os/i386/CentOS/screen-4.0.3-1.el5_4.1.i386.rpm
rpm -Uhv screen-4.0.3-1.el5_4.1.i386.rpm

Xen

Backup and Restore with a console

To copy a VM to another computer over ssh:

xe vm-list
xe vm-export uuid=<uuid> filename= | ssh -c blowfish -C <user>@<sys-x> 'dd of=<filename>.xva'

To Restore it from the remote host:

ssh -c blowfish -C <user>@<sys-x> 'dd if=<filename>.xva' | xe vm-import filename=/dev/stdin

Automatically Start Virtual Machines

By default the newly created virtual machine is not started automatically. At first we have to start the pool:

xe pool-list
xe pool-param-set uuid=<uuid-pool> other-config:auto_poweron=true

To enable this, execute the following command:

xe vm-list
xe vm-param-set uuid=[[uuid-vm]] other-config:auto_poweron=true 

Xen Server 6.02 Installation on Hetzner Server

XenServer Installieren

Man sollte sich auf seinem Hetzner Server ein Minimal-OS anlegen, sich einloggen und dann die Netzwerkkonfiguration notieren (Debian/Ubuntu: /etc/networking/interfaces, CentOS /etc/sysconfig/network-scripts/ifcfg-eth0). Wichtig ist u.a. auch die Gateway-IP. 1.1 Xenserver Download + auf Webserver entpacken

Xenserver ISO von hier auf einen eigenen, separaten Webserver downloaden: http://www.citrix.com/lang/English/lp/lp_1688615.asp

wget http://downloadns.citrix.com.edgesuite.net/akdlm/6760/XenServer-6.0.201-install-cd.iso
mount -o loop XenServer-6.0.201-install-cd.iso /mnt
mkdir /var/www/xenserver
cp -a /mnt/* /var/www/xenserver

Answerfile generieren und zum webserver kopieren

Hier als Beispiel eine XML-Datei, die man z.B. xenserver.xml nennen kann. Achtung: Unbedingt die richtige IP-Adresse für den Server und den Gateway eintragen!

<installation mode="fresh" srtype="lvm">
<primary-disk gueststorage="yes">sda</primary-disk>
<keymap>de</keymap>
<hostname>xenserver-ex4s</hostname>
<root-password>my_password</root-password>
<source type ="url">http://xx.xx.xx.xx/xenserver/</source>
<!-- No Post install scripts configured -->
<admin-interface name="eth0" proto="static">
<ip>Hetzner Server IP</ip>
<subnet-mask>255.255.255.224</subnet-mask>
<gateway>Hetzner Gateway IP</gateway>
</admin-interface>
<nameserver>213.133.99.99</nameserver>
<nameserver>213.133.100.100</nameserver>
<timezone>Europe/Berlin</timezone>
<time-config-method>ntp</time-config-method>
<ntp-servers>ntp</ntp-servers>
<ntpservers>83.246.120.75</ntpservers>
<ntpservers>213.9.73.106</ntpservers>
<ntpservers>188.40.34.195</ntpservers>
</installation>

Diese Datei sollte im gleichen Verzeichnis gespeichert werden, wie der Rest des Hauptverzeichnisses der Xenserver-CD.

Anpassungen für den PXE-Boot

Auf dem neuen Server: folgende Dateien vom eigenen Webserver auf den für die XenServer-Installation vorgesehene Server kopieren:

cd /boot
HOST=xx.xx.xx.xx
wget http://$HOST/xenserver/install.img
wget http://$HOST/xenserver/boot/vmlinuz
wget http://$HOST/xenserver/boot/xen.gz

Nun auf dem neuen Hetzner-Server die Bootloader-Konfiguration anpassen. Ich hatte ein Ubuntu 12.04 minimal gewählt, daher hier Grub2. In der /boot/grub/grub.cfg den ersten menuentry anpassen (siehe letzte 3 Zeilen):

if [ "${linux_gfx_mode}" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.2.0-24-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
gfxmode $linux_gfx_mode
insmod gzio
insmod raid
insmod mdraid1x
insmod part_gpt
insmod part_gpt
insmod ext2
set root='(mduuid/xxxxxxxxxxxxx)'
search --no-floppy --fs-uuid --set=root 2caba589-8a66-457a-81a2-2f43c7203736
multiboot /xen.gz dom0_mem=752M acpi=off nosmp noapic noirqbalance
module /vmlinuz answerfile=http://xx.xx.xx.xx/xenserver/xenserver.xml install
module /install.img
}

Achtung: Die URL vom answerfile muss mit der IP des Servers angegeben werden, nicht mit dem Hostnamen. Daher aufpassen, wenn man NameVirtualHosts o.ä. einsetzt!

Reboot

Mit reboot den Server neu starten. Nun sollte die XenServer-Installation starten, was man leicht auf dem externen Webserver per “tail -f /var/log/apache2/access.log” prüfen kann.

Software-RAID1

Nach der Installation sollte der Xenserver per SSH mit dem im Answerfile eingegebenen Passwort erreichbar sein. XenServer 6 nutzt GPT statt MBR zur Einrichtung der Partitionen. Die 3 TB Festplatten eines EX4 etc. werden damit voll ausgenutzt.

Now it is a good time to copy you ssh key to the server.

zweite Festplatte sdb einrichten

/dev/sda sollte nun 3 Partitionen enthalten. Um die Partitionen gleichmäßig zu übertragen lässt man sich die Partitionen auf /dev/sda anzeigen:

sgdisk -p /dev/sda

Partitionen auf /dev/sdb löschen:

sgdisk --zap-all /dev/sdb

Now reboot the system because the kernel uses the old table of the harddisk.

reboot

Neue GPT Tabelle anlegen:

sgdisk --mbrtogpt --clear /dev/sdb

Anfang und Ende der jeweiligen Partitionen in folgende Befehle übernehmen (hier von meiner config übernommen):

sgdisk --new=1:2048:8388641 /dev/sdb
sgdisk --typecode=1:fd00 /dev/sdb
sgdisk --new=2:8390656:16777249 /dev/sdb
sgdisk --typecode=2:fd00 /dev/sdb
sgdisk --new=3:16779264:1465149134 /dev/sdb
sgdisk --typecode=3:fd00 /dev/sdb
sgdisk /dev/sda --attributes=1:set:2
sgdisk /dev/sdb --attributes=1:set:2
sgdisk --typecode=1:fd00 /dev/sda
sgdisk --typecode=2:fd00 /dev/sda
sgdisk --typecode=3:fd00 /dev/sda

Anschließend

RAID anlegen

Das von Hetzner eingerichtete RAID1 ist teilweise noch vorhanden, XenServer hat sich auf /dev/sda 3 Partitionen eingerichtet und /dev/sdb entsprechend dem Answerfile dieses Beispiels unangetastet gelassen. Die Reste des RAIDs werden zunächst aufgelöst:

mdadm --stop /dev/md0

Neues RAID anlegen:

mknod /dev/md0 b 9 0
mknod /dev/md1 b 9 1
mknod /dev/md2 b 9 2
mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb3

Optional: Bitmaps für jedes RAID-Device anlegen. Bitmaps haben geringen Einfluss auf die Performance aber reduzieren deutlich die Zeit, in der ein fehlgeschlagenes Array neu synchronisiert werden muss.

mdadm --grow /dev/md0 -b internal
mdadm --grow /dev/md1 -b internal
mdadm --grow /dev/md2 -b internal

Die neue RAID-Konfiguration in eine aktualisierte mdadm.conf speichern:

mdadm --examine --scan > /etc/mdadm.conf

Copy Store Manager Data to RAID

pvcreate /dev/md2 -ff
vgextend VG_<TAB> /dev/md2
pvmove /dev/sda3 /dev/md2

Remove /dev/sda3 from the SR volume group

vgreduce VG_<TAB> /dev/sda3
pvremove /dev/sda3

After the procedure explained on the hetzner site is not working we only make sure that our vms are on the raid:

mdadm -a /dev/md2 /dev/sda3

Continue now on the ISO mount.

mkfs.ext3 /dev/md0
mount /dev/md0 /mnt
cd /
cp -axv . /mnt

Nun muss die Datei /mnt/etc/fstab angepasst werden

vi /mnt/etc/fstab

Ersetze den Parameter root=LABEL=root-xxxxxx mit root=/dev/md0 (ohne LABEL=).

Neue Initrd erstellen:

mkdir /mnt/root/initrd-raid
mkinitrd -v --fstab=/mnt/etc/fstab /mnt/root/initrd-raid/initrd-`uname -r`-raid.img `uname -r`
cd /mnt/root/initrd-raid
zcat initrd-`uname -r`-raid.img | cpio -i

Die Datei ‘init’ bearbeiten und nach ‘raidautorun /dev/md0’ folgendes einfügen:

raidautorun /dev/md1
raidautorun /dev/md2

Die neue Ramdisk nun nach /mnt/boot kopieren

find . -print | cpio -o -Hnewc | gzip -c > /mnt/boot/initrd-`uname -r`-raid.img
rm /mnt/boot/initrd-2.6-xen.img

ln -s initrd-`uname -r`-raid.img /mnt/boot/initrd-2.6-xen.img
nano /mnt/boot/extlinux.conf

Nun “root=LABEL=root-xyz” mit “root=/dev/md0” in allen Menüeinträgen ersetzen.

Nun den MBR für GPT auf /dev/sdb einrichten:

cat /mnt/usr/share/syslinux/gptmbr.bin > /dev/sdb
cd /mnt
extlinux  --raid -i boot/
umount /dev/md0
sync

Das RAID-Array ist nun fast komplett, es fehlt lediglich /dev/sda1. Dazu nun ins Rescue System rebooten (im Robot Rescue System aktivieren, Passwort kopieren, Server per Hardware-Reset neu booten). Im Rescue System ausführen:

mdadm -a /dev/md0 /dev/sda1

Das RAID-Array muss sich nun erstmals synchronisieren, was einen Augenblick lang(!) dauert. Den Fortschritt kann man wie folgt beobachten: watch -n 1 cat /proc/mdstat

Lokale ISO Libary einbinden

Xenserver 6.0 bietet keine Moeglichkeit ISO Images im lokalen Storage anzubieten. Um dies dennoch zu ermoeglichen, wird im LVM des Datenbereiches ein neues LV angelegt und per lokalem NFS Server durchgereicht. Es ist nicht performant, aber es erfüllt seinen Zweck. Quelle: http://forums.citrix.com/thread.jspa?messageID=1393861&tstart=0

Eigene VG finden

vgscan
#Reading all physical volumes. This may take a while...
#Found volume group "VG_XenStorage-709d46ed-8193-d470-4ab8-21953af4f863" using metadata type lvm2

Neues LVM anlegen create new lvm

(bsp mit 20 GB)

lvcreate -L 20G -n ISO VG_XenStorage-<meineid>
#Logical volume "ISO" created

Filesystem anlegen

mkfs.ext3 /dev/VG_XenStorage-<meineid>/ISO

/etc/exports anpassen

mkdir /ISO
echo "/ISO 127.0.0.1(rw,no_root_squash,sync)" >> /etc/exports

NFS und Portmappen starten und rebootfest aktivieren

chkconfig --level 345 nfs on
chkconfig --level 345 portmap on
service nfs start
service portmap start

Mount beim boot

Am Ende des Files folgendes hinzufuegen:

lvchange -a y /dev/VG_XenStorage-<meineid>/ISO

Edit /etc/fstab and add:

/dev/VG_XenStorage-72b9dcb4-0881-54ff-4699-6447bbf8099d/ISO     /ISO    ext3    defaults        0       0

Mount the ISO lib:

mount /ISO

ISO Libray in XenCenter eintragen

Im XenCenter kann man nun eine neue Storage-Library hinzufügen, Typ “NFS ISO”. Als Mountpoint “localhost:/ISO” angeben

Netzwerkkonfiguration

To fix problem with the network card modify /etc/modprobe.conf

options r8169 use_dac=1

Host als Router konfigurieren

Der XenServer wird durch Änderungen in der Datei /etc/sysctl.conf als Router konfiguriert (die ersten paar Zeilen bis einschließlich net.ipv4.ip_forward = 0 durch die folgenden ersetzen):

# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding=1

# Controls proxy arp
net.ipv4.conf.default.proxy_arp = 1

# Turn off redirects
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.lo.send_redirects = 0
net.ipv4.conf.xenbr0.send_redirects = 0

Die Einstellungen sind nun nach jedem Neustart aktiv. Sie lassen sich aber auch ohne Neustart direkt mit dem sysctl -p Befehl anwenden:

sysctl -p

Disable Firewall on XEN host

Disable the security level:

system-config-securitylevel-tui

IPv4

For the xen host, insert the gateway your get from Hetzner.

On the VMs use as gateway the ip address from the xen-host.

You have to activate the MACs on a Hetzner interface.

If you have a subnet: Create the file /etc/sysconfig/network-scripts/ifcfg-xenbr0:1 with the following settings:

DEVICE=xenbr0:1
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.224
IPADDR=192.168.99.1

Start the interface with:

ifup xenbr0:1

IPv6

At first request a IPv6-Subnet (/64) from Hetzner.

The XenServer 6 has a bug and the command modprobe ipv6 is not sucessfully, so we use a work-around. Edit the file /etc/sysconfig/network-scripts/network-functions-ipv6 in function ipv6_test() modify line 180:

old
modprobe ipv6

change it to
modprobe esp6

Configure XenServer by edit /etc/sysconfig/network:

NETWORKING_IPV6=yes
IPV6_DEFAULTDEV=xenbr0
IPV6_DEFAULTGW=fe80::1

Configure IPv6 address by editing /etc/sysconfig/network-scripts/ifcfg-xenbr0:1

DEVICE=xenbr0:1
ONBOOT=yes
BOOTPROTO=none

IPV6INIT=yes
IPV6ADDR=2a01:4f8:101:2040::2/64
IPV6_ROUTER=yes
IPV6_AUTOCONF=no
IPV6FORWARDING=yes
IPV6_DEFAULTDEV=xenbr0:1
IPV6_DEFAULTGW=fe80::1

Create a script in /etc/init.d/network6:

#!/bin/bash
#
# network6      This starts and stops ipv6 on xenbr0
#
# chkconfig: 2345 15 85
# description: ipv6 configuration
#
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Source function library.
. /etc/init.d/functions
# Von Hetzner zugewiesenes Gateway
IPV6GATEWAY=2a01:4f8:101:2040::1
# Eigene Adresse und eigenes Subnetz
IPV6HOSTADDR=2a01:4f8:101:2046::2/112
IPV6HOSTSUBNET=2a01:4f8:101:2046::0/112

usage () {
   echo "Usage: service $prog {start|stop}"
   RETVAL=1
}
start () {
  # Configure our ip address
   ip -6 addr add $IPV6HOSTADDR dev xenbr0
  # Configure routing to hetzner gateway
   ip -6 route add $IPV6GATEWAY dev xenbr0
   ip -6 route add default via $IPV6GATEWAY
}
case "$1" in
   start) start; RETVAL=$? ;;
   *) usage ; RETVAL=2 ;;
esac
exit $RETVAL
########

Make it executable:

chmod +x network6

Add it to start scripts:

chkconfig network6 on

In den jeweiligen VMs (so sie denn mit Linux laufen) nimmt man dann folgende Einstellungen vor:

ip addr add 2a01:4f8:161:xxx::y/64 dev eth0
ip route add default via 2a01:4f8:161:xxx::2

Treiber für die Netzwerkkarte austauschen (optional)

Der standardmäßig im XenServer geladene Treiber (r8169) für die Realtek-Netzwerkkarte produziert unter Umständen Paketverluste. Daher muss auf einen alternative Treiber umgesattelt werden: r8168. Um den Netzwerkkartentreiber zu kompilieren, benötigt man das zur eigenen XenServer-Version passende Driver Development Kit (DDK), welches auf der Citrix Seite heruntergeladen werden kann: http://support.citrix.com/article/CTX133814 .

cd /ISO
wget http://download.citrix.com.edgesuite.net/6764/XenServer-6.0.2-XS602E005-ddk.iso

Vorerst sollte zusätzlich mittels XenCenter das VM Storage als Default markiert werden (Rechtsklick -> Default Storage) da sonst der xe vm-import Befehl nicht funktioniert. ISO Mounten:

mkdir /mnt/iso
mount -o loop /local/iso/XenServer-6.0.0-XS60E003-ddk.iso /mnt/iso

DDK VM Importieren:

xe vm-import filename=/mnt/iso/ddk/ova.xml

Im XenCenter muss dann noch ein Netzwerkdevice zur Virtuellen Maschine hinzugefügt werden, danach kann man die Maschine starten und ein root Passwort setzen mit dem man sich dann einloggen kann. Nun tragen wir die richtigen Netzwerkeinstellungen für die VM ein: /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
IPADDR=IP-ADRESSE-DER-VM
NETMASK=255.255.255.224
ONBOOT=yes
TYPE=ethernet

/etc/sysconfig/network-scripts/route-eth0

IP-ADRESSE-DER_VM dev eth0 scope link
default via IP-DES-XENSERVERS-BZW-BEI-IP-NETZ-DIE-DES-xenbr0:1

/etc/resolv.conf

nameserver 213.133.99.99
nameserver 213.133.100.100

Nun den Treiber ziehen, entpacken und kompilieren:

cd /root
wget http://r8168.googlecode.com/files/r8168-8.031.00.tar.bz2
tar xjf r8168-8.031.00.tar.bz2
cd r8168-8.031.00
make all

Den neuen Treiber (r8168.ko) auf das Hostsystem übertragen nach: /lib/modules/2.6.32.12-0.7.1.xs6.0.2.542.170665xen/kernel/drivers/net/

Dem Treiber dann die richtigen Rechte geben:

chmod 0744 /lib/modules/2.6.32.12-0.7.1.xs6.0.2.542.170665xen/kernel/drivers/net/r8168.ko

Nun den neuen Treiber in die /etc/modprobe.conf eintragen: echo “alias eth0 r8168” > /etc/modprobe.conf

Danach den neuen Treiber aktivieren und den Server neustarten (Achtung, nach Ausführung des folgenden Befehls startet der Server automatisch neu!):

rmmod r8169 && depmod -a && modprobe r8168 && reboot

Wenn alles richtig gelaufen ist, wird der neue Treiber für die Netzwerkschnittstelle genutzt:

lspci -nnk | grep -i net -A2

In der letzten Zeile sollte stehen: “Kernel driver in use: r8168”

Virtuelle Maschinen von einem anderen (älteren) XenServer übertragen

Der XenServer ist zum Glück recht flexibel, was die Übertragung von virtuellen Maschinen eines anderen XenServer-Hosts angeht. Im Grunde gibt es viele Möglichkeiten, eine davon ist z.B. das remote-mounten eines Verzeichnisses (per NFS) auf dem neuen XenServer-Host vom alten XenServer-Host aus. In dieses Verzeichnis wird dann eine VM nach der anderen exportiert (per “xe vm-export uuid=xxx-xxx filename=vm1.xva”) und jeweils auf dem neuen Host wieder importiert (“xe vm-import filename=vm1.xva”).

Install Xen Server 5.5 on Hetzner Server

You need an additional computer on which the installation files are stored. They are downloaded then via http.

Prepare Webserver

I use as webserver a FreeBSD:

wget http://downloadns.citrix.com.edgesuite.net/akdlm/4210/FREE_XenServer-5.5.0-install-cd.iso
mdconfig -a -t vnode -f FREE_XenServer-5.5.0-install-cd.iso -u 0
mount -t cd9660 /dev/md0 /mnt
mkdir /usr/local/www/apache22/data/xenserver
cp -a /mnt/* /usr/local/www/apache22/data/xenserver
umount mnt
mdconfig -d -u 0

Create the unattended installation file, you can use the following tool to do this http://wiki.xenmaster.de/doku.php/tools/xstools and save it as xenserver.xml on the webserver.

<?xml version="1.0" standalone="no"?>
<!--
************************************************************
*   XML answer file for unattend Xenserver installation     
* created by XenServer PXE Install Tool - (c) Thomas Krampe 
*                                                           
*  BE CAREFUL IF YOU CHANGE SOMETHING MANUALLY IN THS FILE  
*                                                           
************************************************************
-->
<installation mode="fresh" srtype="lvm">
   <bootloader>grub</bootloader>
   <primary-disk gueststorage="yes">sda</primary-disk>
   <keymap>de</keymap>
   <hostname>xen</hostname>
   <root-password>_password_</root-password>
   <source type ="url">http://_IP_WEBSERVER_/xenserver</source>
   <!-- No Post install scripts configured -->
   <admin-interface name="eth0" proto="static">
      <ip>_IP_</ip>
      <subnet-mask>255.255.255.192</subnet-mask>
      <gateway>_GATEWAY_</gateway>
   </admin-interface>
   <nameserver>213.133.99.99</nameserver>
   <nameserver>213.133.100.100</nameserver>
   <timezone>Europe/Berlin</timezone>
   <time-config-method>ntp</time-config-method>
   <ntp-servers>ntp</ntp-servers>
   <ntpservers>83.246.120.75</ntpservers>
   <ntpservers>213.9.73.106</ntpservers>
   <ntpservers>188.40.34.195</ntpservers>
</installation>

Installation of Xen

Install a standard linux on it like Debian. Login and copy the following files to /boot:

cd /boot
wget http://_IP_/xenserver/boot/vmlinuz
wget http://_IP_/xenserver/boot/xen.gz
wget http://_IP_/xenserver/install.img

Now we great the grub entry in /boot/grub/menu.lst

default 2

title Install Xenserver
root (hd0,1)
kernel /xen.gz dom0_mem=752M acpi=off nosmp noapic noirqbalance
module /vmlinuz answerfile=http://_IP_/xenserver/xenserver.xml install
module /install.img

Now reboot and check on the webserver if it loads the files.

Use Raid1 on the XEN Server

Copy the partition table from disk 1 to disk 2:

dd if=/dev/sda of=/dev/sdb bs=512 count=1

Create raid partitions on second hard disk:

echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sdb

I got an warning message here:

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.

so I rebooted the system.

Create raid devices:

[ -e /dev/md0 ] || mknod /dev/md0 b 9 0
[ -e /dev/md1 ] || mknod /dev/md1 b 9 1

Startup the degraded RAID devices

mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb1
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3

Create the volume:

pvcreate /dev/md1
volume_group=`vgscan | grep VG | awk -F \" '{print $2}'`
vgextend $volume_group /dev/md1
pvmove /dev/sda3 /dev/md1
# If this is a fresh install, then there won't be any data to move
vgreduce $volume_group /dev/sda3

Now we’re ready to copy the filesystem over to the RAID device /dev/md0

mkfs.ext3 /dev/md0
cd / && mount /dev/md0 /mnt && rsync -a --progress --exclude=/sys --exclude=/proc --exclude=/dev/shm --exclude=/dev/pts / /mnt
mkdir /mnt/sys
mkdir /mnt/proc
sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /mnt/etc/fstab

Now let’s setup initrd

mkdir /root/initrd && cd /root/initrd
zcat /boot/initrd-`uname -r`.img | cpio -i && \\
cp /lib/modules/`uname -r`/kernel/drivers/md/raid1.ko lib

Now we have to edit the init file:

q="echo Waiting for driver initialization."
sed -r -i "s,^${q}$,\n\necho Loading raid1.ko module\ninsmod /lib/raid1.ko\n${q}\n,g" init
q="resume /var/swap/swap.001"
sed -r -i "s,^${q}$,${q}\necho Running raidautorun\nraidautorun /dev/md0\nraidautorun /dev/md1,g" init
r=`grep mkroot /root/initrd/init`
sed -r -i "s|^${r}$|${r/sda1/md0}|g" init

Now we’ll copy the initial ramdisk to the /boot on the new RAID

find . -print | cpio -o -c | gzip -c > /boot/initrd-`uname -r`.img
sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /mnt/etc/fstab
sed -r -i 's,LABEL=root-\w+ ,/dev/md0 ,g' /etc/fstab

And setup the boot loader

sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /mnt/boot/grub/grub.conf
sed -r -i 's,root=LABEL=root-\w+ ,root=/dev/md0 ,g' /boot/grub/grub.conf
grub-install /dev/sdb

Unmount /dev/md0, sync, and reboot

cd ; umount /mnt || umount /dev/md0
sync
reboot

First we tag the partitions as type Linux raid, then we have to add /dev/sda to the RAID.

echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sda
mdadm -a /dev/md0 /dev/sda1
mdadm -a /dev/md1 /dev/sda3

Now it restores the raid, that can take some time, you can see it with:

cat /proc/mdstat

Add local ISO to Xen

Create a directory with:

mkdir -p /var/opt/xen/iso_import

Create now a ISO storage repository:

xe sr-create name-label=MyISORepository type=iso device-config:location=/var/opt/xen/iso_import/ device-config:legacy_mode=true content-type=iso

Now copy for files to

/var/opt/xen/iso_import/

Create Volume for ISOs on LVM

To find the volume ID:

vgscan

Create new LVM to hold the ISOs, in this case 12GB:

lvcreate -L 12G -n ISO VG_XenStorage-fb805573-ae34-9739-c362-521d364cc04b

Create file system:

mkfs.ext3 /dev/VG_XenStorage-fb805573-ae34-9739-c362-521d364cc04b/ISO

Adapt /etc/exports:

mkdir /ISO
echo "/ISO *(rw,no_root_squash,sync)" >> /etc/exports

Start NFS and portmapper:

chkconfig --level 345 nfs on
chkconfig --level 345 portmap on
service nfs start
service portmap start 

Enable mount at boot:

lvchange -a y /dev/VG_XenStorage-fb805573-ae34-9739-c362-521d364cc04b/ISO
mount /dev/VG_XenStorage-fb805573-ae34-9739-c362-521d364cc04b/ISO /ISO

Add ISO library to XenCenter: Click ‘New Storage Repository’ and select ‘NFS ISO’. As mount point use localhost:/ISO.

Install XEN Server 6.0 on Hetzner Server

http://wiki.hetzner.de/index.php/Xenserver_6.0:_Automatische_Installation,_SW_RAID1,_lokale_ISO_Library,_IPv6_und_r8168_Treibertausch