Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
elearning:workbooks:centos:6:ha:l603 [2021/09/10 09:21] – admin | elearning:workbooks:centos:6:ha:l603 [2022/04/22 06:25] (Version actuelle) – admin | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
~~PDF: | ~~PDF: | ||
+ | |||
+ | Version : **2022.01** | ||
Dernière mise-à-jour : ~~LASTMOD~~ | Dernière mise-à-jour : ~~LASTMOD~~ | ||
- | ======HAC603 | + | ======VIC603 |
=====Contenu du Module===== | =====Contenu du Module===== | ||
- | * **HAC603 | + | * **VIC603 |
* Contenu du Module | * Contenu du Module | ||
* LAB #1 - Gestion des Clones | * LAB #1 - Gestion des Clones | ||
Ligne 20: | Ligne 22: | ||
* 3.2 - Création d'une Copie de la Configuration de la VM | * 3.2 - Création d'une Copie de la Configuration de la VM | ||
* 3.3 - Sauvegarder les Copies | * 3.3 - Sauvegarder les Copies | ||
- | * LAB #4 - Augmentation de la Taille du Disque | ||
- | * 4.1 - Augmenter la Taille du Disque avec la Commande qemu-img | ||
- | * Augmenter la Taille du Disque de la VM | ||
- | * Augmenter la Taille de la Partition Système de la VM | ||
- | * Augmenter la Taille du Système de Fichiers | ||
- | * 4.2 - Augmenter la Taille du Disque avec la Commande virsh | ||
- | * Augmenter la Taille du Disque de la VM | ||
- | * LAB #5 - Réparation d'un Filesystem Corrompu | ||
- | * 5.1 - Préparation | ||
- | * 5.2 - La Commande guestfish | ||
- | * LAB #6 - Gestion de la VM | ||
- | * 6.1 La Commande shutdown | ||
- | * 6.2 La Commande reboot | ||
- | * 6.3 La Commande suspend | ||
- | * 6.4 La Commande resume | ||
- | * 6.5 La Commande dominfo | ||
- | * 6.6 La Commande autostart | ||
- | * 6.7 La Commande domuuid | ||
- | * 6.8 La Commande undefine | ||
- | * 6.9 La Commande destroy | ||
- | * LAB #7 - Gestion des Ressources | ||
- | * 7.1 - Augmenter les VCPUs et la Mémoire | ||
- | * 7.2 - Ajouter et Supprimer un Disque Dur | ||
- | * LAB #8 - Journalisation | ||
- | * 8.1 - Le Répertoire / | ||
- | * 8.2 - Le Fichier / | ||
| | ||
=====LAB #1 - Gestion des Clones===== | =====LAB #1 - Gestion des Clones===== | ||
Ligne 114: | Ligne 90: | ||
</ | </ | ||
- | The **State** peut être une des valeurs suivantes : | + | Le **State** peut être une des valeurs suivantes : |
* **running** - la machine virtuelle est active, | * **running** - la machine virtuelle est active, | ||
Ligne 294: | Ligne 270: | ||
[root@testvm1 ~]# | [root@testvm1 ~]# | ||
... | ... | ||
- | [root@testvm1 ~]# [CTRL]+[VER MAJ]+[ALT GR]+[)] | + | [root@testvm1 ~]# [ALT GR]+[CTRL]+[)] |
[root@centos8 ~]# | [root@centos8 ~]# | ||
</ | </ | ||
Ligne 567: | Ligne 543: | ||
drwxr-xr-x. 2 root root 74 Sep 4 03:19 testvm1 | drwxr-xr-x. 2 root root 74 Sep 4 03:19 testvm1 | ||
-rw-r--r--. 1 root root 867042697 Sep 4 03:24 testvm1-backup-04092021.tar.gz | -rw-r--r--. 1 root root 867042697 Sep 4 03:24 testvm1-backup-04092021.tar.gz | ||
- | </ | ||
- | |||
- | =====LAB #4 - Augmentation de la Taille du Disque===== | ||
- | |||
- | ====4.1 - Augmenter la Taille du Disque avec la Commande qemu-img==== | ||
- | |||
- | ===Augmenter la Taille du Disque de la VM=== | ||
- | |||
- | Les images des VMs sont stockées dans le pool **kvm-storagepool** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh pool-list | ||
- | | ||
- | --------------------------------------- | ||
- | | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | Consultez le contenu du pool **kvm-storagepool** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh vol-list kvm-storagepool | ||
- | | ||
- | -------------------------------------------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | Consultez ensuite les informations concernant l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh vol-info / | ||
- | Name: | ||
- | Type: file | ||
- | Capacity: | ||
- | Allocation: | ||
- | </ | ||
- | |||
- | Pour pouvoir redimensionner la taille de l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# qemu-img resize / | ||
- | Image resized. | ||
- | </ | ||
- | |||
- | Vérifiez ensuite la prise en charge de la modification : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh vol-info / | ||
- | Name: | ||
- | Type: file | ||
- | Capacity: | ||
- | Allocation: | ||
- | </ | ||
- | |||
- | ===Augmenter la Taille de la Partition Système de la VM=== | ||
- | |||
- | Démarrez la VM **testvm1** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh start testvm1 | ||
- | </ | ||
- | |||
- | Connectez-vous à la VM grâce à la commande **virsh console** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh console testvm1 | ||
- | Connected to domain testvm1 | ||
- | Escape character is ^] | ||
- | [Return] | ||
- | CentOS Linux 8 | ||
- | Kernel 4.18.0-305.12.1.el8_4.x86_64 on an x86_64 | ||
- | |||
- | testvm1 login: root | ||
- | Mot de passe : fenestros | ||
- | Dernière connexion : | ||
- | </ | ||
- | |||
- | Constatez la taille de la partition **/ | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# lsblk | ||
- | NAME | ||
- | sr0 | ||
- | vda 253:0 0 7G 0 disk | ||
- | ├─vda1 253:1 0 1G 0 part /boot | ||
- | ├─vda2 253:2 0 512M 0 part [SWAP] | ||
- | └─vda3 253:3 0 3,5G 0 part / | ||
- | </ | ||
- | |||
- | <WRAP center round important 60%> | ||
- | **Important** : Notez que, pour le système d' | ||
- | </ | ||
- | |||
- | Constatez ensuite l' | ||
- | |||
- | [< | ||
- | [root@testvm1 ~]# df -h | ||
- | Sys. de fichiers Taille Utilisé Dispo Uti% Monté sur | ||
- | devtmpfs | ||
- | tmpfs 909M | ||
- | tmpfs 909M 8,5M 901M 1% /run | ||
- | tmpfs 909M | ||
- | / | ||
- | / | ||
- | tmpfs 182M | ||
- | </ | ||
- | |||
- | La partition **/ | ||
- | |||
- | < | ||
- | root@testvm1 ~]# dnf -y install cloud-utils-growpart gdisk | ||
- | </ | ||
- | |||
- | Le paquet **cloud-utils-growpart** fournit la commande **growpart** qui permet d' | ||
- | |||
- | * le nom du fichier spécial - /dev/vda, | ||
- | * le numéro de la partition à augmenter en taille - **3**. | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# growpart /dev/vda 3 | ||
- | / | ||
- | </ | ||
- | |||
- | <WRAP center round important 60%> | ||
- | **Important** : Notez que cette commande retourne une erreur. En effet, elle ne comprend l' | ||
- | </ | ||
- | |||
- | Pour palier à ce problème, il convient simplement d' | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# echo $LANG | ||
- | fr_FR.UTF-8 | ||
- | [root@testvm1 ~]# unset LANG | ||
- | [root@testvm1 ~]# echo $LANG | ||
- | </ | ||
- | |||
- | En exécutant de nouveau la commande **growpart**, | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# growpart /dev/vda 3 | ||
- | CHANGED: partition=3 start=3147776 old: size=7337984 end=10485760 new: size=11532255 end=14680031 | ||
- | </ | ||
- | |||
- | L' | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# lsblk | ||
- | NAME | ||
- | sr0 | ||
- | vda 253:0 0 7G 0 disk | ||
- | |-vda1 253:1 0 1G 0 part /boot | ||
- | |-vda2 253:2 0 512M 0 part [SWAP] | ||
- | `-vda3 253:3 0 5.5G 0 part / | ||
- | </ | ||
- | |||
- | <WRAP center round important 60%> | ||
- | **Important** : Notez que, pour le système d' | ||
- | </ | ||
- | |||
- | Par contre, l' | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# df -TH | ||
- | Filesystem | ||
- | devtmpfs | ||
- | tmpfs tmpfs | ||
- | tmpfs tmpfs | ||
- | tmpfs tmpfs | ||
- | / | ||
- | / | ||
- | tmpfs tmpfs | ||
- | </ | ||
- | |||
- | ===Augmenter la Taille du Système de Fichiers=== | ||
- | |||
- | Pour augmenter la taille du système de fichiers se trouvant sur **/ | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# xfs_growfs /dev/vda3 | ||
- | meta-data=/ | ||
- | | ||
- | | ||
- | | ||
- | data | ||
- | | ||
- | naming | ||
- | log =internal log | ||
- | | ||
- | realtime =none | ||
- | data blocks changed from 917248 to 1441531 | ||
- | </ | ||
- | |||
- | Cette fois-ci la sortie de la commande **df** démontre bien l' | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# df -TH | ||
- | Filesystem | ||
- | devtmpfs | ||
- | tmpfs tmpfs | ||
- | tmpfs tmpfs | ||
- | tmpfs tmpfs | ||
- | / | ||
- | / | ||
- | tmpfs tmpfs | ||
- | [root@testvm1 ~]# [CTRL]+[VER MAJ]+[ALT GR]+[)] | ||
- | [root@centos8 ~]# | ||
- | </ | ||
- | |||
- | Arrêtez la VM **testvm1** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh shutdown testvm1 | ||
- | </ | ||
- | |||
- | ====4.2 - Augmenter la Taille du Disque avec la Commande virsh==== | ||
- | |||
- | ===Augmenter la Taille du Disque de la VM=== | ||
- | |||
- | La VM **testvm2** est en cours d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | Utilisez la commande **virsh domblklist** pour afficher l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh domblklist testvm2 | ||
- | | ||
- | ------------------------------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | Cette fois, utilisez la commande **virsh blockresize** pour redimensionner la taille de l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh blockresize --domain testvm2 --path / | ||
- | Block device '/ | ||
- | </ | ||
- | |||
- | <WRAP center round important 60%> | ||
- | **Important** : Notez que la commande **qemu-img resize** nécessite la spécification de l' | ||
- | </ | ||
- | |||
- | Vérifiez ensuite la prise en charge de la modification : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh vol-info / | ||
- | Name: | ||
- | Type: file | ||
- | Capacity: | ||
- | Allocation: | ||
- | </ | ||
- | |||
- | Connectez-vous à la VM grâce à la commande **virsh console** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh console testvm2 | ||
- | Connected to domain testvm2 | ||
- | Escape character is ^] | ||
- | </ | ||
- | |||
- | Ré-exécutez les mêmes commandes que la dernière fois : | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# dnf -y install cloud-utils-growpart gdisk | ||
- | ... | ||
- | |||
- | [root@testvm1 ~]# unset LANG | ||
- | |||
- | [root@testvm1 ~]# growpart /dev/vda 3 | ||
- | CHANGED: partition=3 start=3147776 old: size=7337984 end=10485760 new: size=11532255 end=14680031 | ||
- | |||
- | [root@testvm1 ~]# lsblk | ||
- | NAME | ||
- | sr0 | ||
- | vda 253:0 0 7G 0 disk | ||
- | |-vda1 253:1 0 1G 0 part /boot | ||
- | |-vda2 253:2 0 512M 0 part [SWAP] | ||
- | `-vda3 253:3 0 5.5G 0 part / | ||
- | |||
- | [root@testvm1 ~]# xfs_growfs /dev/vda3 | ||
- | meta-data=/ | ||
- | | ||
- | | ||
- | | ||
- | data | ||
- | | ||
- | naming | ||
- | log =internal log | ||
- | | ||
- | realtime =none | ||
- | data blocks changed from 917248 to 1441531 | ||
- | |||
- | [root@testvm1 ~]# df -TH | ||
- | Filesystem | ||
- | devtmpfs | ||
- | tmpfs tmpfs | ||
- | tmpfs tmpfs | ||
- | tmpfs tmpfs | ||
- | / | ||
- | / | ||
- | tmpfs tmpfs | ||
- | [root@testvm1 ~]# [CTRL]+[VER MAJ]+[ALT GR]+[)] | ||
- | [root@centos8 ~]# | ||
- | </ | ||
- | |||
- | =====LAB #5 - Réparation d'un Filesystem Corrompu===== | ||
- | |||
- | En cas de défaillance de la procédure d' | ||
- | |||
- | ====5.1 - Préparation==== | ||
- | |||
- | La réparation est effectuée grâce à l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# dnf install -y libguestfs-tools | ||
- | Last metadata expiration check: 2:14:42 ago on Sat 04 Sep 2021 02:21:59 EDT. | ||
- | Package libguestfs-tools-1: | ||
- | Dependencies resolved. | ||
- | Nothing to do. | ||
- | Complete! | ||
- | </ | ||
- | |||
- | ====5.2 - La Commande guestfish==== | ||
- | |||
- | Commencez par ajouter l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# guestfish -a / | ||
- | |||
- | Welcome to guestfish, the guest filesystem shell for | ||
- | editing virtual machine filesystems and disk images. | ||
- | |||
- | Type: ‘help’ for help on commands | ||
- | ‘man’ to read the manual | ||
- | ‘quit’ to quit the shell | ||
- | |||
- | >< | ||
- | </ | ||
- | |||
- | Initialisez **guestfish** avec la commande **run** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# guestfish -a / | ||
- | |||
- | Welcome to guestfish, the guest filesystem shell for | ||
- | editing virtual machine filesystems and disk images. | ||
- | |||
- | Type: ‘help’ for help on commands | ||
- | ‘man’ to read the manual | ||
- | ‘quit’ to quit the shell | ||
- | |||
- | >< | ||
- | </ | ||
- | |||
- | Listez ensuite les systèmes de ficheirs de la VM : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# guestfish -a / | ||
- | |||
- | Welcome to guestfish, the guest filesystem shell for | ||
- | editing virtual machine filesystems and disk images. | ||
- | |||
- | Type: ‘help’ for help on commands | ||
- | ‘man’ to read the manual | ||
- | ‘quit’ to quit the shell | ||
- | |||
- | >< | ||
- | >< | ||
- | /dev/sda1: ext4 | ||
- | /dev/sda2: swap | ||
- | /dev/sda3: xfs | ||
- | </ | ||
- | |||
- | Procédez ensuite à la réparation des systèmes de fichiers avec la commande **fsck** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# guestfish -a / | ||
- | |||
- | Welcome to guestfish, the guest filesystem shell for | ||
- | editing virtual machine filesystems and disk images. | ||
- | |||
- | Type: ‘help’ for help on commands | ||
- | ‘man’ to read the manual | ||
- | ‘quit’ to quit the shell | ||
- | |||
- | >< | ||
- | >< | ||
- | lisf-filesystems: | ||
- | >< | ||
- | /dev/sda1: ext4 | ||
- | /dev/sda2: swap | ||
- | /dev/sda3: xfs | ||
- | >< | ||
- | 0 | ||
- | >< | ||
- | 0 | ||
- | </ | ||
- | |||
- | <WRAP center round important 60%> | ||
- | **Important** : Notez que le code retour de **0** indique qu' | ||
- | </ | ||
- | |||
- | Quittez **guestfish** à l'aide de la touche **q** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# guestfish -a / | ||
- | |||
- | Welcome to guestfish, the guest filesystem shell for | ||
- | editing virtual machine filesystems and disk images. | ||
- | |||
- | Type: ‘help’ for help on commands | ||
- | ‘man’ to read the manual | ||
- | ‘quit’ to quit the shell | ||
- | |||
- | >< | ||
- | >< | ||
- | lisf-filesystems: | ||
- | >< | ||
- | /dev/sda1: ext4 | ||
- | /dev/sda2: swap | ||
- | /dev/sda3: xfs | ||
- | >< | ||
- | 0 | ||
- | >< | ||
- | 0 | ||
- | >< | ||
- | </ | ||
- | |||
- | Après la réparation du système de fichiers, démarrez le VM **testvm1** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh start testvm1 | ||
- | Domain testvm1 started | ||
- | |||
- | [root@centos8 ~]# | ||
- | </ | ||
- | |||
- | =====LAB #6 - Gestion de la VM===== | ||
- | |||
- | ====6.1 La Commande shutdown==== | ||
- | |||
- | Comme il a déjà été expliqué, pour arrêter une VM, il convient d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh shutdown testvm1 | ||
- | Domain testvm1 is being shutdown | ||
- | |||
- | [root@centos8 ~]# virsh list | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | -------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | ====6.2 La Commande reboot==== | ||
- | |||
- | La commande **virsh reboot** permet de re-démarrer une VM : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh reboot 5 | ||
- | Domain 5 is being rebooted | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | -------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | ====6.3 La Commande suspend==== | ||
- | |||
- | La commande **virsh suspend** permet de mettre en pause une VM. Bien évidement, une VM ne peut être mise en pause que quand celle-ci est en cours de fonctionnement : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh suspend testvm1 | ||
- | error: Failed to suspend domain testvm1 | ||
- | error: Requested operation is not valid: domain is not running | ||
- | |||
- | [root@centos8 ~]# virsh start testvm1 | ||
- | Domain testvm1 started | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | | ||
- | |||
- | [root@centos8 ~]# virsh suspend testvm1 | ||
- | Domain testvm1 suspended | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | ====6.4 La Commande resume==== | ||
- | |||
- | La commande **virsh resume** permet d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh resume testvm1 | ||
- | Domain testvm1 resumed | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | ====6.5 La Commande dominfo==== | ||
- | |||
- | La commande **virsh dominfo** permet de consulter les informations relatives à un domaine donné : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh dominfo 11 | ||
- | Id: 11 | ||
- | Name: | ||
- | UUID: | ||
- | OS Type: hvm | ||
- | State: | ||
- | CPU(s): | ||
- | CPU time: 28.7s | ||
- | Max memory: | ||
- | Used memory: | ||
- | Persistent: | ||
- | Autostart: | ||
- | Managed save: no | ||
- | Security model: selinux | ||
- | Security DOI: 0 | ||
- | Security label: system_u: | ||
- | </ | ||
- | |||
- | ====6.6 La Commande autostart==== | ||
- | |||
- | La commande **virsh autostart** permet de configurer la VM de façon à ce que celle-ci démarre automatiquement : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh autostart d436a2df-78b0-474c-833b-3f7af8681052 | ||
- | Domain d436a2df-78b0-474c-833b-3f7af8681052 marked as autostarted | ||
- | |||
- | [root@centos8 ~]# virsh dominfo 11 | ||
- | Id: 11 | ||
- | Name: | ||
- | UUID: | ||
- | OS Type: hvm | ||
- | State: | ||
- | CPU(s): | ||
- | CPU time: 29.0s | ||
- | Max memory: | ||
- | Used memory: | ||
- | Persistent: | ||
- | Autostart: | ||
- | Managed save: no | ||
- | Security model: selinux | ||
- | Security DOI: 0 | ||
- | Security label: system_u: | ||
- | </ | ||
- | |||
- | Pour annuler l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh autostart --disable 11 | ||
- | Domain 11 unmarked as autostarted | ||
- | |||
- | [root@centos8 ~]# virsh dominfo 11 | ||
- | Id: 11 | ||
- | Name: | ||
- | UUID: | ||
- | OS Type: hvm | ||
- | State: | ||
- | CPU(s): | ||
- | CPU time: 29.2s | ||
- | Max memory: | ||
- | Used memory: | ||
- | Persistent: | ||
- | Autostart: | ||
- | Managed save: no | ||
- | Security model: selinux | ||
- | Security DOI: 0 | ||
- | Security label: system_u: | ||
- | </ | ||
- | |||
- | ====6.7 La Commande domuuid==== | ||
- | |||
- | La commande **virsh domuuid** permet d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh domuuid testvm1 | ||
- | d436a2df-78b0-474c-833b-3f7af8681052 | ||
- | </ | ||
- | |||
- | ====6.8 La Commande undefine==== | ||
- | |||
- | La commande **virsh undefine** permet de supprimer la configuration d'une VM : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh undefine 5 | ||
- | Domain 5 has been undefined | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | | ||
- | </ | ||
- | |||
- | < | ||
- | **Important** : Notez que si la VM est en cours d' | ||
- | </ | ||
- | |||
- | ====6.9 La Commande destroy==== | ||
- | |||
- | La commande **virsh destroy** permet de supprimer une VM. Cette commande est l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | | ||
- | |||
- | [root@centos8 ~]# virsh destroy 5 | ||
- | Domain 5 destroyed | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | |||
- | [root@centos8 ~]# ls -lh / | ||
- | total 3.9G | ||
- | -rw-------. 1 qemu qemu 5.1G Sep 4 06:21 testvm1-os.qcow2 | ||
- | -rw-------. 1 root root 2.2G Sep 4 06:18 testvm2.qcow2 | ||
- | |||
- | [root@centos8 ~]# du -sh / | ||
- | 1.8G / | ||
- | 2.2G / | ||
- | </ | ||
- | |||
- | =====LAB #7 - Gestion des Ressources===== | ||
- | |||
- | ====7.1 - Augmenter les VCPUs et la Mémoire==== | ||
- | |||
- | La façon de modifier les ressources d'une VM en ligne de commande est d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | |||
- | [root@centos8 ~]# virsh dominfo 11 | ||
- | Id: 11 | ||
- | Name: | ||
- | UUID: | ||
- | OS Type: hvm | ||
- | State: | ||
- | CPU(s): | ||
- | CPU time: 36.5s | ||
- | Max memory: | ||
- | Used memory: | ||
- | Persistent: | ||
- | Autostart: | ||
- | Managed save: no | ||
- | Security model: selinux | ||
- | Security DOI: 0 | ||
- | Security label: system_u: | ||
- | </ | ||
- | |||
- | Comme détaillé précédemment, | ||
- | |||
- | < | ||
- | [root@centos8 ~]# cat / | ||
- | ... | ||
- | <memory unit=' | ||
- | < | ||
- | <vcpu placement=' | ||
- | ... | ||
- | </ | ||
- | |||
- | Pour modifier la configuration, | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh shutdown 11 | ||
- | Domain 11 is being shutdown | ||
- | </ | ||
- | |||
- | Editez ensuite les valeurs suivantes dans le fichier de configuration en utilisant la commande **virsh edit** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh edit testvm1 | ||
- | ... | ||
- | < | ||
- | <vcpu placement=' | ||
- | ... | ||
- | </ | ||
- | |||
- | Lors de votre sauvegarde du fichier, le système vous indiquera que le fichier a été modifié : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh edit testvm1 | ||
- | Domain testvm1 XML configuration edited. | ||
- | </ | ||
- | |||
- | L' | ||
- | |||
- | Consultez la valeur de la mémoire dans le fichier **/ | ||
- | |||
- | < | ||
- | ... | ||
- | <memory unit=' | ||
- | < | ||
- | ... | ||
- | </ | ||
- | |||
- | Démarrez maintenant la VM **testvm1** : | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh start testvm1 | ||
- | Domain testvm1 started | ||
- | |||
- | [root@centos8 ~]# virsh list --all | ||
- | | ||
- | ------------------------- | ||
- | | ||
- | |||
- | [root@centos8 ~]# virsh dominfo 1 | ||
- | Id: 1 | ||
- | Name: | ||
- | UUID: | ||
- | OS Type: hvm | ||
- | State: | ||
- | CPU(s): | ||
- | CPU time: 41.6s | ||
- | Max memory: | ||
- | Used memory: | ||
- | Persistent: | ||
- | Autostart: | ||
- | Managed save: no | ||
- | Security model: selinux | ||
- | Security DOI: 0 | ||
- | Security label: system_u: | ||
- | </ | ||
- | |||
- | Pour accorder à la VM le droit d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh setmem testvm1 4194304 | ||
- | |||
- | </ | ||
- | |||
- | Vérifiez ensuite la prise en compte de l' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# virsh dominfo 1 | ||
- | Id: 1 | ||
- | Name: | ||
- | UUID: | ||
- | OS Type: hvm | ||
- | State: | ||
- | CPU(s): | ||
- | CPU time: 47.5s | ||
- | Max memory: | ||
- | Used memory: | ||
- | Persistent: | ||
- | Autostart: | ||
- | Managed save: no | ||
- | Security model: selinux | ||
- | Security DOI: 0 | ||
- | Security label: system_u: | ||
- | </ | ||
- | |||
- | ====7.2 - Ajouter et Supprimer un Disque Dur==== | ||
- | |||
- | Pour ajouter un disque à une VM, il convient d' | ||
- | |||
- | < | ||
- | [root@centos8 ~]# cd / | ||
- | </ | ||
- | |||
- | Créez un disque d'une taille de 10 Go au format **raw** : | ||
- | |||
- | < | ||
- | [root@centos8 images]# qemu-img create -f raw testvm1-disk2.img 10G | ||
- | Formatting ' | ||
- | </ | ||
- | |||
- | Attachez ensuite ce disque à la VM **testvm1** : | ||
- | |||
- | < | ||
- | [root@centos8 images]# virsh attach-disk testvm1 --source / | ||
- | Disk attached successfully | ||
- | </ | ||
- | |||
- | Connectez-vous à la VM avec la commande **virsh console** : | ||
- | |||
- | < | ||
- | [root@centos8 images]# virsh console testvm1 | ||
- | Connected to domain testvm1 | ||
- | Escape character is ^] | ||
- | </ | ||
- | |||
- | Contrôlez la présence du disque ajouté : | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# lsblk | ||
- | NAME | ||
- | sr0 | ||
- | vda 253:0 0 7G 0 disk | ||
- | ├─vda1 253:1 0 1G 0 part /boot | ||
- | ├─vda2 253:2 0 512M 0 part [SWAP] | ||
- | └─vda3 253:3 0 5,5G 0 part / | ||
- | vdb 253: | ||
- | </ | ||
- | |||
- | Créez une partition sur le disque : | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# fdisk /dev/vdb | ||
- | |||
- | Bienvenue dans fdisk (util-linux 2.32.1). | ||
- | Les modifications resteront en mémoire jusqu' | ||
- | Soyez prudent avant d' | ||
- | |||
- | Le périphérique ne contient pas de table de partitions reconnue. | ||
- | Création d'une nouvelle étiquette pour disque de type DOS avec identifiant de disque 0xcde64a28. | ||
- | |||
- | Commande (m pour l' | ||
- | Type de partition | ||
- | | ||
- | | ||
- | Sélectionnez (p par défaut) : | ||
- | |||
- | Utilisation de la réponse p par défaut. | ||
- | Numéro de partition (1-4, 1 par défaut) : | ||
- | Premier secteur (2048-20971519, | ||
- | Dernier secteur, +secteurs ou +taille{K, | ||
- | |||
- | Une nouvelle partition 1 de type « Linux » et de taille 10 GiB a été créée. | ||
- | |||
- | Commande (m pour l' | ||
- | La table de partitions a été altérée. | ||
- | Appel d' | ||
- | [ 1518.252446] | ||
- | Synchronisation des disques. | ||
- | </ | ||
- | |||
- | Créez un système de fichiers de type **xfs** sur la partition : | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# mkfs.ext4 /dev/vdb1 | ||
- | mke2fs 1.45.6 (20-Mar-2020) | ||
- | Rejet des blocs de périphérique : | ||
- | En train de créer un système de fichiers avec 2621184 4k blocs et 655360 i-noeuds. | ||
- | UUID de système de fichiers=805d3a53-4f8f-43f1-8b2a-bf1c493f33ee | ||
- | Superblocs de secours stockés sur les blocs : | ||
- | 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632 | ||
- | |||
- | Allocation des tables de groupe : complété | ||
- | Écriture des tables d' | ||
- | Création du journal (16384 blocs) : complété | ||
- | Écriture des superblocs et de l' | ||
- | fichiers : complété | ||
- | </ | ||
- | |||
- | Montez le disque et vérifiez que vous pouvez y écrire : | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# mount /dev/vdb1 /mnt | ||
- | [ 1581.199551] EXT4-fs (vdb1): mounted filesystem with ordered data mode. Opts: (null) | ||
- | [root@testvm1 ~]# cd /mnt | ||
- | [root@testvm1 mnt]# touch test | ||
- | [root@testvm1 mnt]# ls | ||
- | lost+found | ||
- | </ | ||
- | |||
- | Détachez-vous de la VM : | ||
- | |||
- | < | ||
- | [root@testvm1 ~]# [CTRL]+[VER MAJ]+[ALT GR]+[)] | ||
- | [root@centos8 images]# | ||
- | </ | ||
- | |||
- | Détachez ensuite le disque **vdb** de la VM : | ||
- | |||
- | < | ||
- | [root@centos8 images]# virsh detach-disk testvm1 vdb | ||
- | Disk detached successfully | ||
- | </ | ||
- | |||
- | Reconnectez-vous à la VM et exécutez la commande **lsblk**. Notez que celle-ci génère des erreurs dues au fait que le disque n'a pas été démonté avant d' | ||
- | |||
- | < | ||
- | [root@testvm1 mnt]# lsblk | ||
- | [ 1879.523849] EXT4-fs error (device vdb1): ext4_find_entry: | ||
- | [ 1879.536586] EXT4-fs error (device vdb1): ext4_find_entry: | ||
- | [ 1879.550137] EXT4-fs error (device vdb1): ext4_find_entry: | ||
- | NAME | ||
- | sr0 | ||
- | vda 253:0 0 7G 0 disk | ||
- | ├─vda1 253:1 0 1G 0 part /boot | ||
- | ├─vda2 253:2 0 512M 0 part [SWAP] | ||
- | └─vda3 253:3 0 5,5G 0 part / | ||
- | </ | ||
- | |||
- | Démontez donc le disque : | ||
- | |||
- | < | ||
- | [root@testvm1 mnt]# cd .. | ||
- | [root@testvm1 /]# umount /mnt | ||
- | [ 1921.363728] Buffer I/O error on dev vdb1, logical block 1081344, lost sync page write | ||
- | [ 1921.372593] JBD2: Error -5 detected when updating journal superblock for vdb1-8. | ||
- | [ 1921.381098] Aborting journal on device vdb1-8. | ||
- | [ 1921.386369] Buffer I/O error on dev vdb1, logical block 1081344, lost sync page write | ||
- | [ 1921.395319] JBD2: Error -5 detected when updating journal superblock for vdb1-8. | ||
- | </ | ||
- | |||
- | Exécutez de nouveau la commande **lsblk**. Vous verrez qu'il n'y a plus d' | ||
- | |||
- | < | ||
- | [root@testvm1 /]# lsblk | ||
- | NAME | ||
- | sr0 | ||
- | vda 253:0 0 7G 0 disk | ||
- | ├─vda1 253:1 0 1G 0 part /boot | ||
- | ├─vda2 253:2 0 512M 0 part [SWAP] | ||
- | └─vda3 253:3 0 5,5G 0 part / | ||
- | [root@testvm1 /]# [CTRL]+[VER MAJ]+[ALT GR]+[)] | ||
- | [root@centos8 images]# | ||
- | </ | ||
- | |||
- | =====LAB #8 - Journalisation===== | ||
- | |||
- | ====8.1 - Le Répertoire / | ||
- | |||
- | Le répertoire **/ | ||
- | |||
- | < | ||
- | [root@centos8 images]# cd / | ||
- | [root@centos8 qemu]# ls -l | ||
- | total 56 | ||
- | -rw-------. 1 root root 4037 Sep 4 04:51 guestfs-7w7bnjy7ro65665z.log | ||
- | -rw-------. 1 root root 4005 Sep 4 04:40 guestfs-xt170t6ii8uce35y.log | ||
- | -rw-------. 1 root root 37531 Sep 4 07:04 testvm1.log | ||
- | -rw-------. 1 root root 7179 Sep 4 06:18 testvm2.log | ||
- | |||
- | [root@centos8 qemu]# more testvm1.log | ||
- | 2021-09-03 12: | ||
- | module_el8.4.0+885+5e18b468 (CentOS Buildsys < | ||
- | :57, ), qemu version: 4.2.0qemu-kvm-4.2.0-48.module_el8.4.0+783+f8734d30, | ||
- | : 4.18.0-305.7.1.el8.i2tch.x86_64, | ||
- | LC_ALL=C \ | ||
- | PATH=/ | ||
- | HOME=/ | ||
- | XDG_DATA_HOME=/ | ||
- | XDG_CACHE_HOME=/ | ||
- | XDG_CONFIG_HOME=/ | ||
- | QEMU_AUDIO_DRV=none \ | ||
- | / | ||
- | -name guest=testvm1, | ||
- | -S \ | ||
- | -object secret, | ||
- | vm1/ | ||
- | -machine pc-q35-rhel8.2.0, | ||
- | -cpu Broadwell-IBRS, | ||
- | tsc-adjust=on, | ||
- | =on, | ||
- | y=on, | ||
- | -m 3072 \ | ||
- | -overcommit mem-lock=off \ | ||
- | --More--(3%) | ||
- | |||
- | [root@centos8 qemu]# cat guestfs-7w7bnjy7ro65665z.log | ||
- | 2021-09-04 08: | ||
- | LC_ALL=C \ | ||
- | PATH=/ | ||
- | HOME=/ | ||
- | XDG_DATA_HOME=/ | ||
- | XDG_CACHE_HOME=/ | ||
- | XDG_CONFIG_HOME=/ | ||
- | QEMU_AUDIO_DRV=none \ | ||
- | TMPDIR=/ | ||
- | / | ||
- | -name guest=guestfs-7w7bnjy7ro65665z, | ||
- | -S \ | ||
- | -object secret, | ||
- | -machine pc-i440fx-rhel7.6.0, | ||
- | -cpu host \ | ||
- | -m 1280 \ | ||
- | -overcommit mem-lock=off \ | ||
- | -smp 1, | ||
- | -uuid e6a0f63c-b33e-4ba0-bf03-9e4b9c9dd6a2 \ | ||
- | -display none \ | ||
- | -no-user-config \ | ||
- | -nodefaults \ | ||
- | -chardev socket, | ||
- | -mon chardev=charmonitor, | ||
- | -rtc base=utc, | ||
- | -global kvm-pit.lost_tick_policy=delay \ | ||
- | -no-hpet \ | ||
- | -no-reboot \ | ||
- | -no-acpi \ | ||
- | -boot strict=on \ | ||
- | -kernel / | ||
- | -initrd / | ||
- | -append ' | ||
- | -device virtio-scsi-pci, | ||
- | -device virtio-serial-pci, | ||
- | -blockdev ' | ||
- | -blockdev ' | ||
- | -device scsi-hd, | ||
- | -blockdev ' | ||
- | -blockdev ' | ||
- | -blockdev ' | ||
- | -blockdev ' | ||
- | -device scsi-hd, | ||
- | -chardev socket, | ||
- | -device isa-serial, | ||
- | -chardev socket, | ||
- | -device virtserialport, | ||
- | -object rng-random, | ||
- | -device virtio-rng-pci, | ||
- | -sandbox on, | ||
- | -msg timestamp=on | ||
- | 2021-09-04 08: | ||
- | 2021-09-04 08: | ||
- | 2021-09-04T08: | ||
- | 2021-09-04 08: | ||
- | </ | ||
- | |||
- | ====8.2 - Le Fichier / | ||
- | |||
- | Dans le fichier **/ | ||
- | |||
- | < | ||
- | [root@centos8 qemu]# cat / | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: Using msrs 4b564d01 and 4b564d00 | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: cpu 0, msr b3801001, primary cpu cloc | ||
- | k | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: using sched offset of 369654777578829 | ||
- | 1 cycles | ||
- | Sep 1 05:47:57 centos8 kernel: clocksource: | ||
- | | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-guest: stealtime: cpu 0, msr 13bc2c080 | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-guest: PV spinlocks enabled | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: cpu 1, msr b3801041, secondary cpu cl | ||
- | ock | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-guest: stealtime: cpu 1, msr 13bc6c080 | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: cpu 2, msr b3801081, secondary cpu cl | ||
- | ock | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-guest: stealtime: cpu 2, msr 13bcac080 | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: cpu 3, msr b38010c1, secondary cpu cl | ||
- | ock | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-guest: stealtime: cpu 3, msr 13bcec080 | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: cpu 4, msr b3801101, secondary cpu cl | ||
- | ock | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-guest: stealtime: cpu 4, msr 13bd2c080 | ||
- | Sep 1 05:47:57 centos8 kernel: kvm-clock: cpu 5, msr b3801141, secondary cpu cl | ||
- | ock | ||
- | --More-- | ||
</ | </ | ||
----- | ----- | ||
< | < | ||
- | <div align=" | + | <div align=" |
- | Copyright © 2021 Hugh Norris | + | Copyright © 2022 Hugh Norris |
</ | </ | ||
</ | </ | ||
----- | ----- |