Virtualisation avec Libvirt / Qemu sur un serveur Gandi IaaS

Virtualisation avec Libvirt / Qemu sur un serveur Gandi IaaS.

Procédure

1/ Création d’un serveur Gandi.

Localisation : Paris, France
Coeur : 4
RAM :  	4096 Mo
Système : Ubuntu 16.04 64 bits LTS (HVM)
Disque système :  20 Go

2/ Connexion au serveur.

[~] ➔ ssh admin@95.142.162.206
...
admin@95.142.162.206's password:
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-21-lowlatency x86_64)
...
admin@server01virt:~$

3/ Mise-à-jour de la distribution.

admin@server01q:~$ su
root@server01virt:/home/admin# apt-get update && apt-get upgrade

4/ Installation des paquets de base.

root@server01virt:/home/admin# apt-get install mc screen htop vim links

5/ Remplacement des dépôts Gandi par les dépôts officiels Ubuntu.

Ouvrir :

/etc/apt/sources.list.d/multistrap-ubuntu-xenial-backports.list

Remplacer tout par :

deb [arch=amd64] http://en.archive.ubuntu.com/ubuntu/ xenial-backports main

Ouvrir :

/etc/apt/sources.list.d/multistrap-ubuntu-xenial-proposed.list

Remplacer tout par :

deb [arch=amd64] http://en.archive.ubuntu.com/ubuntu/ xenial-proposed main

Ouvrir :

/etc/apt/sources.list.d/multistrap-ubuntu-xenial-security.list

Remplacer tout par :

deb [arch=amd64] http://security.ubuntu.com/ubuntu xenial-security main

Ouvrir :

/etc/apt/sources.list.d/multistrap-ubuntu-xenial-updates.list

Remplacer tout par :

deb [arch=amd64] http://en.archive.ubuntu.com/ubuntu/ xenial-updates main universe

Ouvrir :

/etc/apt/sources.list.d/multistrap-ubuntu-xenial.list

Remplacer tout par :

deb [arch=amd64] http://en.archive.ubuntu.com/ubuntu/ xenial main universe

Lien :
http://askubuntu.com/questions/835731/cant-install-php-mbstring-on-ubuntu-16-04-1-lts/836033

6/ Mise-à-jour de la distribution.

root@server01virt:/home/admin# apt-get update && apt-get upgrade

7/ Installation des paquets pour la virtualisation.

root@server01virt:/home/admin# apt-get --no-install-recommends install qemu-kvm libvirt-bin virtinst qemu

8/ Création d’un disque virtuel.

root@server01virt:/home/admin# qemu-img create vhda.raw 5G
Formatting 'vhda.raw', fmt=raw size=5368709120

9/ Création d’une machine virtuelle Ubuntu.

root@server01virt:/home/admin# virt-install --name VM01 --memory 2048 --disk vhda.raw --network default --graphics vnc,password=Mot2Passe --location http://us.archive.ubuntu.com/ubuntu/dists/xenial/main/installer-amd64/
WARNING  KVM acceleration not available, using 'qemu'
WARNING  Unable to connect to graphical console: virt-viewer not installed. Please install the 'virt-viewer' package.
WARNING  No console to launch for the guest, defaulting to --wait -1
Starting install...
Retrieving file linux...                                                                                                                                                                                                | 6.7 MB  00:00:00
Retrieving file initrd.gz...                                                                                                                                                                                            |  36 MB  00:00:01
Creating domain...                                                                                                                                                                                                      |    0 B  00:00:00
Domain installation still in progress. Waiting for installation to complete.

10/ A partir de la machine hôte, connexion localhost en ssh pour VNC.

[~] ➔ ssh admin@95.142.162.206 -L 5900:localhost:5900
admin@95.142.162.206's password:
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-21-lowlatency x86_64)
...
admin@server01virt:~$

11/ A partir de la machine hôte, visualisation de la machine virtuelle avec VNC pour l’installation.

[~] ➔ vncviewer localhost:0
VNC Viewer Free Edition 4.1.1 for X - built Jul 31 2015 19:05:51
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Thu Apr 13 21:58:37 2017
 CConn:       connected to host localhost port 5900
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
Password:
Thu Apr 13 21:58:43 2017
 TXImage:     Using default colormap and visual, TrueColor, depth 24.
 CConn:       Using pixel format depth 6 (8bpp) rgb222
 CConn:       Using ZRLE encoding


12/ Après l’installation de la machine virtuelle, démarrage de la machine virtuelle.

root@server01virt:/home/admin# virsh start VM01
Domain VM01 started

13/ Liste des machines virtuelles.

root@server01virt:/home/admin# virsh net-list
setlocale: No such file or directory
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 default              active     yes           yes

14/ Visualisation de la machine virtuelle.

[~] ➔ vncviewer localhost:0
VNC Viewer Free Edition 4.1.1 for X - built Jul 31 2015 19:05:51
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Fri Apr 14 10:08:33 2017
 CConn:       connected to host localhost port 5900
 CConnection: Server supports RFB protocol version 3.8
 CConnection: Using RFB protocol version 3.8
Password:
Fri Apr 14 10:08:36 2017
 TXImage:     Using default colormap and visual, TrueColor, depth 24.
 CConn:       Using pixel format depth 6 (8bpp) rgb222
 CConn:       Using ZRLE encoding

15/ Information sur réseau.

root@server01virt:/home/admin# virsh net-info default
setlocale: No such file or directory
Name:           default
UUID:           ce51274e-d060-43b1-bf9c-040cd30ebb59
Active:         yes
Persistent:     yes
Autostart:      yes
Bridge:         virbr0

16/ Information sur le réseau au format XML.

root@server01virt:/home/admin# virsh net-dumpxml default
setlocale: No such file or directory

  default
  ce51274e-d060-43b1-bf9c-040cd30ebb59
  
    
      
    
  
  
  
  
    
      
    
  

17/ Liste des machines virtuelles.

root@server01virt:/home/admin# virsh list
setlocale: No such file or directory
 Id    Name                           State
----------------------------------------------------
 1     VM01                           running

18/ Affichage de la configuration VNC.

root@server01virt:/home/admin# virsh dumpxml VM01 | grep vnc
setlocale: No such file or directory
    

19/ Liste de la configuration réseau de la VM.

root@server01virt:/home/admin# virsh net-dhcp-leases default
 Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2017-04-14 10:45:00  52:54:00:90:64:dc  ipv4      192.168.122.10/24         ubuntu          -

20/ Connexion en ssh sur la VM.

root@server01virt:/home/admin# ssh util01@192.168.122.10
util01@192.168.122.10's password:
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-72-generic x86_64)
 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.
util01@ubuntu:~$

21/ Arrêter la machine virtuelle.

root@server01virt:/home/admin# virsh shutdown VM01
Domain VM01 is being shutdown

22/ Liste de toutes machines virtuelles.

root@server01virt:/home/admin# virsh list --all
setlocale: No such file or directory
 Id    Name                           State
----------------------------------------------------
 -     VM01                           shut off

23/ Supprimer une machine virtuelle.

root@server01virt:/home/admin# virsh undefine VM01
setlocale: No such file or directory
Domain VM01 has been undefined

24/ Liens.

https://www.cyberciti.biz/faq/how-to-install-kvm-on-ubuntu-linux-14-04/
https://www.maccagnoni.eu/2016/09/kvm-virtualisation-serveur/
https://docs.fedoraproject.org/en-US/Fedora/18/html/Virtualization_Administration_Guide/ch15s06.html

Comments are closed, but trackbacks and pingbacks are open.