navigation
Home
admin
|
Xen
October 18th, 2016
|
| Table des matières |  |
Dom0 - Installation sur une Ubuntu 12.04
Dom0 - Installation sur une Debian
Sauvegardes - Exemple de script
DOMU Centos / DOM0 Ubuntu 12.04
DOMU lenny / DOM0 lenny
Quelques commandes
NTP
Erreurs
Divers
Anciennes installations
| Notes |  |
A lire : http://wiki.xen.org/wiki/Xen_Overview
HVM is needed for non-linux virtual machines (Windows, Solaris..). You can run Linux as HVM virtual machine too,
but the I/O performance will be significantly reduced. However, it's possible to use PVonHVM drivers for the I/O devices and
get better performance (my guess is it should be more or less on par wirh PVM). If you are used to PVM (paravirtualized virtual
machines) and there's no problem with PVM drawbacks, I would say that there's no need to experiment with HVM Linux machines.
et XCP ?
cf http://wiki.xen.org/wiki/XCP_FAQ_General
libvirt
apt-get install libvirt-bin |
Management tools
http://wiki.xen.org/wiki/Xen_Management_Tools
http://wiki.prgmr.com/mediawiki/index.php/Chapter_6:_domU_Management:_Tools_and_Frontends
| Dom0 - Installation sur une Ubuntu 12.04 |  |
Note
4.2 Creating an Installation Tree
You cannot create a paravirtualized guest virtual machine from a local hard disk or CD-ROM using either the virt-install
command-line tool, or Oracle VM Manager. You can, however, create an installation tree, and mount it as an NFS share.
or make it available via HTTP or FTP. For example, to create mount an ISO file and make it available via NFS:
# mkdir -p /el/EL5-x86
# mount -o ro,loop /path/to/Enterprise-R5-x86-dvd.iso /el/EL5-x86
# exportfs *:/el/EL5-x86/
When you create the guest virtual machine, enter the installation location as:
nfs:example.com:/el/EL5-x86
Similarly, to set up an installation tree that can be accessed via HTTP on a computer named example.com, enter
# cd /var/www/html
# mkdir EL5-x86
# mount -o ro,loop /path/to/Enterprise-R5-x86-dvd.iso EL5-x86
When you create the guest virtual machine, enter the installation location as:
http://example.com/EL5-x86 |
Source :
http://docs.oracle.com/cd/E15458_01/doc.22/e15444/createvm.htm
Installation
Après avoir installé les packages classiques (xen-hypervisor xen-utils-4.1 xenwatch xen-tools xen-utils-common xenstore-utils),
puis rebooté, j'ai le message suivant :
$ xm list
ERROR: Can't find hypervisor information in sysfs! |
Logique : dans le menu grub, lors du reboot je n'ai pas vu de proposition du noyau linux-xen.
Une solution : retélécharger les noyaux :
apt-get install linux-image-server |
puis mettre à jour le grub :
Source :
http://askubuntu.com/questions/115931/xen-4-1-missing-from-the-grub-menu
| Dom0 - Installation sur une Debian |  |
apt-get install linux-image-2.6-xen-686 xen-utils* bridge-utils iproute debootstrap vlan (xen-tools) |
Le nouveau moyau est "xen compatible"
Le grub est modifié. Rebooter et s'assurer de bien choisir ce nouveau noyau.
modification de :
- /etc/xen/xend-config.sxp :
je commente :
(network-script network-dummy) |
et j'ajoute :
(network-script 'network-bridge netdev=eth0')
(network-script 'network-bridge bridge=br0') |
Je ne touche à rien d'autre !!!
- /etc/modules
je rajoute à la fin de la ligne loop : max_loop=64
pour éviter des pbs du genre
mount: could not find any free loop device |
(par défaut seuls 8 montages sont autorisés; voir les montages : losetup -a)
- modification de /etc/network/interface
avec DHCP :
more /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
#iface eth0 inet dhcp
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_maxwait 0 |
sans DHCP :
info:/etc/xen# more /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
#auto eth0
#iface eth0 inet static
#address <mon ip>
#netmask 255.255.255.0
#gateway <ma passerelle>
auto eth0
iface eth0 inet manual
auto br0
iface br0 inet static
bridge_ports eth0
address <mon ip>
netmask 255.255.255.0
gateway <ma passerelle> |
- reboot puis
brctl addif br0 vif0.0
brctl show
bridge name bridge id STP enabled interfaces
xenbr0 8000.000d56950829 no eth0
vif0.0
vif4.0 |
- /etc/init.d/xend start
- erreur au reboot :
(==) intel(0): Depth 24, (--) framebuffer bpp 32
(==) intel(0): RGB weight 888
(==) intel(0): Default visual is TrueColor
(II) intel(0): Integrated Graphics Chipset: Intel(R) 865G
(--) intel(0): Chipset: "865G"
(--) intel(0): Linear framebuffer at 0xE8000000
(--) intel(0): IO registers at addr 0xFEB80000 |
Fatal server error:
xf86MapVidMem: Could not mmap framebuffer (0xfeb80000,0x80000) (Invalid argument) |
solution : http://diffrentcolours.livejournal.com/814563.html
modification du grub du dom0.
je n'ai rajouté que 256 Mo :
kernel /boot/xen-3.2-1-i386.gz dom0_mem=256M |
| Sauvegardes - Exemple de script |  |
#! /bin/bash
#
# sauvegarde de machvirt, machine virtuelle
echo `date`
echo shutdown -w de machvirt
xm shutdown -w machvirt
md1=`md5sum -b /xen/machvirt/diskimage.img|awk '{print $1}'`
echo premiere mesure md5 : $md1
sleep 10
md2=`md5sum -b /xen/machvirt/diskimage.img|awk '{print $1}'`
echo deuxieme mesure md5 : $md2
while [ $md1 != $md2]
do
md1 = $md2
sleep 10
md2=`md5sum -b /xen/machvirt/diskimage.img|awk '{print $1}'`
echo premiere mesure md5 : $md1
echo deuxieme mesure md5 : $md2
done
echo md5sum ok - on lance la sauvegarde
dd if=/xen/machvirt/diskimage.img of=/var/tmp/sauv_machvirt_temp.img
md2=`md5sum -b /var/tmp/sauv_machvirt_temp.img|awk '{print $1}'`
echo mesure finale md5 : $md2
if [ $md1 != $md2]
then
echo PB DANS LA SAUVEGARDE
echo $md1 != $md2
else
echo xm create machvirt.cfg
xm create machvirt.cfg
echo `date` machine virtuelle ok
madate=`date '+%y%m%d'`
fichier_sauvegarde="/sauvegardes/machvirt/machvirt-$madate.img"
echo fichier de sauvegarde : $fichier_sauvegarde
echo copie du fichier de sauvegarde sur zoe
mv /var/tmp/sauv_machvirt_temp.img $fichier_sauvegarde
echo sauvegarde ok
fi
echo fin sauv_machvirt
|
| DOMU Centos / DOM0 Ubuntu 12.04 |  |
dd if=/dev/zero of=centos6.img oflag=direct bs=1M seek=3800 count=1 |
Il est préférable d'utiliser l'option seek :
When creating a normal file system all empty blocks are assigned with empty data (usually zero's).
With a sparse file the empty blocks are not assigned but the sparse file keeps track of the size it can be eventually become.
Sparse on a FAT file system is not possible probably because FAT is not capable of saving the meta-data about which
blocks are empty, it only allocates the used blocks.
# du -sh /sauvegardes/xen/debian/debian.img
209M /sauvegardes/xen/debian/debian.img
root@cri-brri:~# ls -alh /sauvegardes/xen/debian/debian.img
-rw-r--r-- 1 root root 4,9G nov. 1 10:35 /sauvegardes/xen/debian/debian.img |
Source : https://www.os3.nl/2011-2012/students/maikel_de_boer/inr/uml
mkfs.ext4 /sauvegardes/xen/centos/centos6.img |
Lors du mkfs, on peut avoir le message suivant : image.img n'est pas un périphérique spécial en mode bloc.
C'est normal, mkfs repère qu'il ne s'agit pas de périphérique physique. Il faut simplement répondre oui à cette question.
virt-install -n centos -r 512 --vcpus=1 -f /sauvegardes/xen/centos/centos6.img -m 52:54:00:12:34:56 -b br0 -p
--location http://mirror.centos.org/centos/6.3/os/i386 |
| DOMU lenny / DOM0 lenny |  |
mkdir /xen/domains/nestor
dd if=/dev/zero of=/xen/domains/nestor/diskimage.img bs=1024k count=5000
bs : block size
count : taille du disque : count*bs
dd if=/dev/zero of=/xen/domains/nestor/swapimage.img bs=1024k count=512
mkfs.ext3 /xen/domains/nestor/diskimage.img
mkswap /xen/domains/nestor/swapimage.img
mount -o loop /xen/domains/nestor/diskimage.img /mnt
(uname -a)
export http_proxy=http://....
debootstrap --arch [i386, amd64] lenny /mnt http://debian.med.domaine-tours.fr/debian/
(mv /mnt/lib/tls /mnt/lib/tls.disabled)
(cp /etc/apt/sources.list /mnt/etc/apt/)
cp -a /lib/modules/2.6.26-2-xen-686/ /mnt/lib/modules/
cp /etc/resolv.conf /mnt/etc/
(cp /etc/network/interfaces /mnt/etc/network)
vi /mnt/etc/network/interfaces |
cat /mnt/etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#allow-hotplug eth0 static // ATTENTION, SI on ne commente pas cette ligne, ca ne fonctionne pas...
auto eth0
iface eth0 inet static
address 19...
netmask 255.255.255.0
network 19.. .29.0
broadcast 19...
gateway 19...
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 19...
dns-search domaine.fr |
+
modifier /etc/hostname et /etc/hosts
- modification de /etc/xen/<host>.cfg
kernel = '/boot/vmlinuz-2.6.26-2-xen-686'
ramdisk = '/boot/initrd.img-2.6.26-2-xen-686'
# la ligne suivante supprime le blocage du
# domU lors du booot (scheduler crond)
extra = 'console=hvc0 xencons=tty'
memory = '128'
vcpus = '15'
root = '/dev/sda2 ro'
disk = [
'file:/xen/domains/nestor/swapimage.img,sda1,w',
'file:/xen/domains/nestor/diskimage.img,sda2,w',
]
name = 'nestor'
vif = 'ip=<mon ip>,bridge=br0'
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'restart' |
Modifier le fichier /etc/fstab :
cat /etc/fstab
/dev/sda1 none swap sw 0 0 |
Compléments après boot :
passwd
export http_proxy=http://proxy:3128
apt-get install openssh-server udev libpam-ldap libnss-ldap nss-updatedb libpam-cracklib nfs-kernel-server tcsh locales ksh
dpkg-reconfigure tzdata
dpkg-reconfigure locales
|
+ reboot (pour le udev)
| Quelques commandes |  |
Démarrer le domU
Divers
-
//creation / lancement + console
-
-
-
-
Ceci va arrêter le système invité, en effectuant un arrêt normal de la machine, comme si vous aviez lancé la commande halt depuis le système.
Avec -w la commande attend l'arret complet du système.
-
L'option destroy arrêtera brutalement le domaine concerné sans passer par la procédure normale de fermeture des processus.
Cette commande peut donc aboutir à corrompre les données et le système de fichiers du système concerné. A ne faire qu'en cas de réelle nécessité.
-
// attacher une console
sortir de la console avec MAC OS : ctrl+6
sortir de la console avec pc : ctrl+]
-
- hybernation :
xm save nestor nestor20090707.chk |
relance :
xm restore nestor20090707.chk |
-
-
Déplacement d'une machine virtuelle
copie des fichiers diskimage et swapimage
verif du fichier :
montage :
mount -o loop diskimage.img /mnt |
ajustement de la machine virtuelle / noyau (on passe d'un noyau 686 -> amd64)
cp -a /lib/modules/2.6.26-2-xen-amd64/ /mnt/lib/modules/
Et ça marche !!!
| NTP |  |
on n'utilise pas le ntp sur les domU. Ils se débrouillent
pour récupérer les infos correctes sur le dom0
| Erreurs |  |
stdin: is not a tty
ssh nestor
stdin: is not a tty |
solution :
rajouter extra = 'console=hvc0 xencons=tty'
dans le fichier de config du domu +
sur le domu : apt-get install udev + reboot
unable to connect to 'localhost:8000': Connexion refusée
virt-install -n centos -r 256 --vcpus=1 -f /sauvegardes/xen/centos/centos6.img -m 52:54:00:12:34:56 -b br0 -p
ERROR unable to connect to 'localhost:8000': Connexion refusée |
Solution : modifier le fichier /etc/xen/xend-config.sxp : (xend-unix-server yes)
puis
ValueError: L'ouverture de l'URL http://mirror.centos.org/centos/6.3/os/i386 a échoué
Si vous êtes derrière un proxy et que vous voulez utiliser virt-install, n'oubliez pas de configurer le proxy :
export http_proxy=http://proxy:3128 |
ERROR Could not start storage pool: cannot open path '/var/lib/xen': No such file or directory
Solution :
| Divers |  |
Mon domu est il de type HVM ou paravirtualisé ?
"If your Dom0 is a linux machine , can you please check the output of command "ps -eaf | grep qemu" ? It should state the type of guest running on it (in case it is xen hypervisor that is being used).
The output corresponding to pv guest machine will end with "-M xenpv" and output corresponding to hvm/pvhvm guest machines should end with "-M xenfv". This is what i find in my case."
Exemple :
1ere ligne : un windows : xenfv
2eme ligne : un linux : xenpv
ps -ef |grep qe
root 13873 21922 6 16:43 ? 00:06:37 /usr/lib/xen-default/bin/qemu-dm -d 25 -domain-name win -videoram 4 -k fr -vnc 127.0.0.1:0 -vncunused -parallel none -vcpus 1 -vcpu_avail 0x1 -boot c -soundhw es1370 -localtime -serial pty -acpi -usb -usbdevice tablet -net nic,vlan=1,macaddr=52:54:00:12:34:56,model=rtl8139 -net tap,vlan=1,ifname=tap25.0,bridge=br0 -M xenfv
root 17926 21922 0 17:57 ? 00:00:01 /usr/lib/xen-4.1/bin/qemu-dm -d 26 -serial pty -domain-name centos -videoram 4 -k fr -vnc 127.0.0.1:0 -vncunused -M xenpv |
Source : http://stackoverflow.com/questions/10042119/how-to-make-sure-a-xen-domu-is-hvm-or-pv?rq=1
| Anciennes installations |  |
Sur une etch
impossible d'utiliser les packages fournis par debian :
1/ update-grub ne les détecte pas
2/ si on modifie à la main le menu.lst de grub :
error: error 13: invalid or unsupported executable format |
=> je décide de compiler xen
- je récupère xen 3.3.1
- make world
puis make dist pour relancer après les pbs |
différentes erreurs :
/bin/sh: line 8: hg: command not found
=> apt-get install mercurial
Makefile.build:73: *** 'Your awk program does not define gensub.
=> apt-get install gawk
can't find xgettext
=> apt-get install gettext
can't find X11 headers
=> apt-get install libx11-dev
error: Python.h: Aucun fichier ou répertoire de ce type
=> apt-get install python2.5-dev
Checking check_zlib_devel:
*** check_zlib_devel FAILED: can't find zlib headers
=> apt-get install zlib1g-dev
Checking check_openssl_devel:
*** check_openssl_devel FAILED: missing openssl headers
=> apt-get install libssl-dev
/usr/bin/ld: ne peut trouver -lncurses
=> apt-get install libncurses
error: Python.h: Aucun fichier ou répertoire de ce type
=> apt-get install python-dev
tar: bzip2: ne peut exec: Aucun fichier ou répertoire de ce type
=> apt-get install bzip2 |
au reboot pb :
VFS: Cannot open root device "sda |
solution (thanks to http://www.generation-nt.com/reponses/kernel-panic-avec-xen-entraide-1768941.html#reponse) :
1/ ajouter un noreboot en fin de ligne kernel => au moins on voit
de message
ds repertoire source de xen, ds linux-2.6.18-xen.hg faire :
mkinitrd -o /boot/initrd-xen-2.6.18.8-xen-686 2.6.18.8-xen |
Sur une lenny
Via la récupération des sources de Xen-3.4.2
apt-get install mercurial gawk gettext libx11-dev zlib1g-dev python2.5-dev libssl-dev python-dev bzip2 bin86 bcc libncurses5 libncurses5-dev
make world
make install
cd linux-2.6.18-xen.hg
mkinitramfs -o /boot/initrd-xen-2.6.18.8-xen-686 2.6.18.8-xen |
modification du fichier /boot/grub/menu.lst :
title Xen Debian GNU/Linux, kernel 2.6.18
root (hd1,0)
kernel /boot/xen.gz noreboot
module /boot/vmlinuz-2.6.18.8-xen root=/dev/sdb1 ro
module /boot/initrd-xen-2.6.18.8-xen-686 |
(et normalement on évite les erreurs du style Error 13: Invalid or Unsupported Executable Format)
Ca boote mais je n'ai plus la carte réseau...
Sur les HP DC7900 c'est une Intel® 82567LM Gigabit intégrée%% From http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=544989
"The Intel 82567lm ethernet card is not recognized. The driver is e1000e"
il faut télécharger ce driver chez intel :
http://downloadcenter.intel.com/confirm.aspx?httpDown=http://downloadmirror.intel.com/15817/eng/e1000e-1.1.2.tar.gz&agr=&ProductID=&DwnldId=15817&strOSs=&OSFullName=&lang=eng
et ça marche !
Ne pas oublier : echo e1000e > /etc/modules
Note : en cas de chgt de noyau, il faut recompiler...%
apt-get install bridge-utils iproute debootstrap vlan |
modifier /etc/network/interfaces
# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
auto br0
iface br0 inet static
bridge_ports eth2
address ...
netmask ...
gateway ... |
Modification de la config de xen :
vi /etc/xen/xend-config.sxp |
Modifs effectuées :
* décommenté :
(logfile /var/log/xen/xend.log)
(loglevel DEBUG)
* modifs :
(network-script 'network-bridge netdev=eth2')
(network-script 'network-bridge bridge=br0')
Lancement du service xen :
update-rc.d xend start 50 3 4 5 . /etc/init.d/xend start |
Création d'une machine virtuelle :
Via les packages
apt-get install xen-linux-system-2.6.26-2-xen-amd64
apt-get install iproute debootstrap vlan |
Modification de /etc/network/interfaces :
# The primary network interface
allow-hotplug eth1
auto eth1
iface eth1 inet manual
auto br0
iface br0 inet static
bridge_ports eth1
address 19xxxxx
netmask 255.255.255.0
gateway 19xxxx
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 19xxxxxx
dns-search domaine.fr |
Modification de xend-config.sxp :
* décommenté :
(logfile /var/log/xen/xend.log)
(loglevel DEBUG)
* modifs :
(network-script 'network-bridge netdev=eth1')
(network-script 'network-bridge bridge=br0')
J'ai ensuite fait une création de domU comme indiqué + haut.
|
|
Dernières modifs
|
|---|
VNC (November 22nd, 2020) Editeurs (October 20th, 2016) Awk (October 18th, 2016) Claws Mail (October 18th, 2016) Cups (October 18th, 2016) Gimp (October 18th, 2016) Git (October 18th, 2016) |
Contact
|
|---|
Pour m'envoyer un mail, Pour me laisser un commentaire :richard.brunooo chez gmail.com |  |
|
|