Xen
Contents |
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 [1] 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.