Archives pour l'étiquette LVM

Xen : Créer une machine virtuel sur debian etch

Support Physique a la machine virtuel

Il y à trois support physique à un DomU : Un fichier image, une partition LVM, une Partition Physique

  1. Un fichier image est ce est le plus rapide à configuré. La contre partie sont de pauvre performance I/O. La taille du fichier image représentant le disque du serveur virtuel est modifiable mais au prix de quelque manipulation laborieuse. Par contre un fichier image est facilement manipulable, copiable, déplacèable
  2. LVM est ce qui est le plus largement utilisé en production. Les partitions peuvent être re-tailler à volonté, facilement, sans (trop) d’intéruption de service. C’est l’idéal pour constituer un hébergement xen. Les performances I/O sont bien meilleur de fait comparé à un fichier image. Par contre en cas de soucis cela ce déplace bien moins facilelement qu’un fichier image.
  3. La partition physique est ce qu’il y à de mieux pour les performances IO. Mais c’est difficilement administrable et pas vraiment flexible.

Disque virtuel dans un fichier image.

C’est mon choix de production, la partition sur la quelle je stock ces fichiers images étant sur un SAN j’ai limité le soucis des I/O tout en ayant la possibilité de transférer mes machine virtuel sur une autre serveur d’hebergement facilement et rapidement.

<span style="color: #c20cb9; font-weight: bold;">mkdir</span> -p <span style="color: #000000; font-weight: bold;">/</span>xens<span style="color: #000000; font-weight: bold;">/</span>burkesys<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if=</span><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of=</span><span style="color: #000000; font-weight: bold;">/</span>xens<span style="color: #000000; font-weight: bold;">/</span>burkesys<span style="color: #000000; font-weight: bold;">/</span>diskimage.img <span style="color: #007800;">bs=</span>1024k <span style="color: #007800;">count=</span><span style="color: #000000;">5000</span> <span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if=</span><span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of=</span><span style="color: #000000; font-weight: bold;">/</span>xens<span style="color: #000000; font-weight: bold;">/</span>burkesys<span style="color: #000000; font-weight: bold;">/</span>swapimage.img <span style="color: #007800;">bs=</span>1024k <span style="color: #007800;">count=</span><span style="color: #000000;">512</span> &nbsp; mkfs.ext3 <span style="color: #000000; font-weight: bold;">/</span>xens<span style="color: #000000; font-weight: bold;">/</span>burkesys<span style="color: #000000; font-weight: bold;">/</span>diskimage.img mkswap <span style="color: #000000; font-weight: bold;">/</span>xens<span style="color: #000000; font-weight: bold;">/</span>burkesys<span style="color: #000000; font-weight: bold;">/</span>swapimage.img &nbsp; <span style="color: #c20cb9; font-weight: bold;">mount</span> -o loop <span style="color: #000000; font-weight: bold;">/</span>xens<span style="color: #000000; font-weight: bold;">/</span>burkesys<span style="color: #000000; font-weight: bold;">/</span>diskimage.img <span style="color: #000000; font-weight: bold;">/</span>mnt

Disque Virtuel dans une volume LVM

lvcreate -n twister --<span style="color: #c20cb9; font-weight: bold;">size</span> 2g main-vol2 lvcreate -n twisterswp --<span style="color: #c20cb9; font-weight: bold;">size</span> 512m main-vol2 &nbsp; mkfs.ext3 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>main-vol2<span style="color: #000000; font-weight: bold;">/</span>twister mkswap <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>main-vol2<span style="color: #000000; font-weight: bold;">/</span>twisterswp &nbsp; <span style="color: #c20cb9; font-weight: bold;">mount</span> -o loop <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>main-vol2<span style="color: #000000; font-weight: bold;">/</span>twister <span style="color: #000000; font-weight: bold;">/</span>mnt

Un nouvel OS avec Debootstrap

Créé avec Debootstrap un nouveau système sur le disque virtuel

debootstrap --<span style="color: #c20cb9; font-weight: bold;">arch</span> i386 sarge <span style="color: #000000; font-weight: bold;">/</span>mnt http:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #c20cb9; font-weight: bold;">ftp</span>.de.debian.org<span style="color: #000000; font-weight: bold;">/</span>debian<span style="color: #000000; font-weight: bold;">/</span> &nbsp; <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>tls <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>tls.disabled &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span> vi <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apt<span style="color: #000000; font-weight: bold;">/</span>sources.list &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> -a <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.6</span><span style="color: #000000;">.16</span><span style="color: #000000;">-1</span>-xen-k7<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span> &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>resolve.conf <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span> &nbsp; <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>interfaces <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span> vi <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>network<span style="color: #000000; font-weight: bold;">/</span>interfaces &nbsp; <span style="color: #808080; font-style: italic;">#To use Specific IP address - edit the /mnt/etc/network/interfaces manually.</span> <span style="color: #808080; font-style: italic;">#To use DHCP, edit and include the following:</span> <span style="color: #808080; font-style: italic;"># The loopback network interface</span> auto lo iface lo inet loopback <span style="color: #808080; font-style: italic;"># The primary network interface</span> auto eth0 iface eth0 inet dhcp &nbsp; vi <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">hostname</span> &nbsp; vi <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>fstab proc <span style="color: #000000; font-weight: bold;">/</span>proc proc defaults <span style="color: #000000;">0</span> <span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda1 <span style="color: #000000; font-weight: bold;">/</span> ext3 defaults,<span style="color: #007800;">errors=</span>remount-ro <span style="color: #000000;">0</span> <span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sda2 none swap sw <span style="color: #000000;">0</span> <span style="color: #000000;">0</span>

Configurer le serveur virtuel domU

<span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt &nbsp; vi <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>burkesys kernel = <span style="color: #ff0000;">&quot;/boot/vmlinuz-2.6.16-1-xen-k7&quot;</span> ramdisk = <span style="color: #ff0000;">&quot;/boot/initrd.img-2.6.16-1-xen-k7&quot;</span> memory = <span style="color: #000000;">192</span> name = <span style="color: #ff0000;">&quot;burkesys&quot;</span> vif = <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #ff0000;">'bridge=xenbr0'</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #808080; font-style: italic;">#File Based:# disk = ['file:/xens/burkesys/diskimage.img,sda1,w','file:/xens/burkesys/swapimage.img,sda2,w']</span> <span style="color: #808080; font-style: italic;">#LVM Based:# disk = ['phy:/dev/main-vol2/twister,sda1,w', 'phy:/dev/main-vol2/twister,sda2,w']</span> <span style="color: #808080; font-style: italic;">#DHCP - remove the ip, gateway and netmask lines, and include:# dhcp = &quot;dhcp&quot;</span> ip = <span style="color: #ff0000;">&quot;ip add&quot;</span> gateway = <span style="color: #ff0000;">&quot;ip add&quot;</span> netmask = <span style="color: #ff0000;">&quot;255.255.0.0&quot;</span> root = <span style="color: #ff0000;">&quot;/dev/sda1 ro&quot;</span> extra = <span style="color: #ff0000;">'4'</span> &nbsp; <span style="color: #c20cb9; font-weight: bold;">ln</span> -s <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>burkesys <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>auto<span style="color: #000000; font-weight: bold;">/</span>burkesys <span style="color: #000000; font-weight: bold;">//</span><span style="color: #c20cb9; font-weight: bold;">link</span> <span style="color: #000000; font-weight: bold;">in</span> the config <span style="color: #c20cb9; font-weight: bold;">file</span> so that the Virtal Machine starts on Bootup of Dom0

Lancer et mettre à jour le serveur virtuel DomU

xm create burkesys -c

Vous allez voir votre serveur virtuel booter. Logger vous en suite et faire une mise à jour.

<span style="color: #c20cb9; font-weight: bold;">passwd</span> &nbsp; apt-get update apt-get upgrade