Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
redhat:virtualization-redhat:start [2017/09/09 17:44] – [KVM Hypervisor unter Redhat / CentOS] michael | redhat:virtualization-redhat:start [2020/04/01 12:05] – [Configure KVM Environment] michael | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== KVM Hypervisor | + | ====== KVM Hypervisor |
- | **KVM** ist eine Open Source Hardware Virtualisierungslösung, | + | |
- | <wrap em>Bevor mit der Installation des Hypervisors begonnen wird, solle immer zuerst überprüfen; | + | **KVM** is an open source hardware virtualization solution which can be used to run several Linux-based or Windows-based systems in parallel on one host. |
- | < | + | |
- | # grep -E ' | + | |
- | </ | + | |
- | Wenn man nun den Output | + | KVM is known as a so-called "**Kernel based Virtual Machine**". This is because after installing the package, the KVM module is loaded with the kernel at the next boot, turning a //normal Linux server// into a bare metal hypervisor. |
- | ---- | + | Now I will describe how to set up such a [[https:// |
- | ===== Installation von KVM ===== | + | * [[redhat: |
- | Jetzt kann die Installation | + | |
- | < | ||
- | # yum install qemu-kvm qemu-img virt-manager libvirt libvirt-python libvirt-client virt-install virt-viewer bridge-utils | ||
- | </ | ||
- | Nach erfolgreicher Installation müssen die Services gestartet & aktiviert werden. | + | ---- |
+ | |||
+ | <WRAP center round important 100%> | ||
+ | <wrap em> | ||
< | < | ||
- | # systemctl start libvirtd | + | # lscpu | grep Virtualization |
- | # systemctl enable libvirtd | + | |
</ | </ | ||
+ | <sxh bash; gutter: false;> | ||
+ | Virtualization: | ||
+ | Virtualization type: full | ||
+ | </ | ||
- | Nun sollte überprüft werden, ob KVM erfolgreich seine beiden Core-Module laden konnte. | + | The output of the above command shows that, our server kvm-virtualization-01.recipes.com supports Virtualization. |
- | <WRAP center box 100%> | + | However, if the above command returns no result on your server then, |
- | < | + | |
- | # lsmod | grep kvm | + | |
- | </ | + | |
- | <sxh bash; gutter: false> | + | - '' |
- | kvm_intel | + | |
- | kvm | + | |
- | </ | + | |
</ | </ | ||
- | Stimmt die Ausgabe mit der oben aufgelisteten Ausgabe in etwa überein, so sollte nun schon alles parat sein zum Virtualisierungen. | ||
- | <WRAP center round tip 100%> | ||
- | '' | ||
- | Falls Redhat 7 oder CentOS 7 als minimal Installation installiert wurde, so fehlt nun noch das sogenannte x-window Pakage, welches jedoch zum anzeigen des Virt-managers unumgänglich ist. Zum nachinstallieren folgenden Befehl ausführen:'' | ||
- | < | ||
- | # yum install "@X Window System" | ||
- | </ | ||
- | </ | ||
- | ---- | ||
- | ===== Vorbereitungen zu starten des Virt-Managers | + | ===== Installing KVM and QEMU ===== |
- | Befindet man sich auf einem Server mit GUI und arbeitet auch direkt auf diesem, so kann man ganz einfach via Konsole den **virt-manager** aufrufen und das Programm wird gestartet. | + | |
- | Ist man jedoch so wie ich, per **Putty** von einem **Windows System** aus verbunden, so wird dies nicht ganz so einfach funktionieren. Es muss nämlich hierzu zuerst noch ein spezielles Programm Namens: " | + | |
- | auf dem Windows System installiert werden. **Xming** erlaubt es Grafikdarstellungen welche via SSH gesendet werden | + | In CentOS 8 / RHEL 8, virtualization components including KVM and QEMU hypervisors are bundled in virt module. Therefore, it is really simple now to configure a KVM virtualization host in CentOS 8. |
<WRAP center box 100%> | <WRAP center box 100%> | ||
- | ==== Xming Installation ==== | + | We are installing virt module using dnf command. |
- | - '' | + | |
- | - '' | + | |
- | - ''< | + | |
- | - '' | + | |
- | - '' | + | |
- | '' | + | <code> |
+ | # dnf install -y @virt | ||
+ | </ | ||
+ | <sxh bash; gutter: false;> | ||
+ | ... | ||
+ | ================================================================================ | ||
+ | Installed: | ||
+ | libguestfs-1: | ||
+ | libvirt-client-4.5.0-24.3.module_el8.0.0+189+f9babebb.x86_64 | ||
+ | libvirt-daemon-config-network-4.5.0-24.3.module_el8.0.0+189+f9babebb.x86_64 | ||
+ | libvirt-daemon-kvm-4.5.0-24.3.module_el8.0.0+189+f9babebb.x86_64 | ||
+ | alsa-lib-1.1.6-3.el8.x86_64 | ||
+ | autogen-libopts-5.18.12-7.el8.x86_64 | ||
+ | boost-atomic-1.66.0-6.el8.x86_64 | ||
+ | boost-chrono-1.66.0-6.el8.x86_64 | ||
+ | boost-date-time-1.66.0-6.el8.x86_64 | ||
+ | boost-iostreams-1.66.0-6.el8.x86_64 | ||
+ | boost-program-options-1.66.0-6.el8.x86_64 | ||
+ | boost-random-1.66.0-6.el8.x86_64 | ||
+ | boost-regex-1.66.0-6.el8.x86_64 | ||
+ | boost-system-1.66.0-6.el8.x86_64 | ||
+ | boost-thread-1.66.0-6.el8.x86_64 | ||
+ | cairo-1.15.12-3.el8.x86_64 | ||
+ | celt051-0.5.1.3-15.el8.x86_64 | ||
+ | dnsmasq-2.79-4.el8.x86_64 | ||
+ | edk2-ovmf-20180508gitee3198e672e2-9.el8_0.1.noarch | ||
+ | fribidi-1.0.4-6.el8.x86_64 | ||
+ | genisoimage-1.1.11-39.el8.x86_64 | ||
+ | glusterfs-api-3.12.2-40.2.el8.x86_64 | ||
+ | glusterfs-cli-3.12.2-40.2.el8.x86_64 | ||
+ | gnutls-dane-3.6.5-2.el8.x86_64 | ||
+ | gnutls-utils-3.6.5-2.el8.x86_64 | ||
+ | graphite2-1.3.10-10.el8.x86_64 | ||
+ | gstreamer1-1.14.0-3.el8.x86_64 | ||
+ | gstreamer1-plugins-base-1.14.0-4.el8.x86_64 | ||
+ | harfbuzz-1.7.5-3.el8.x86_64 | ||
+ | hivex-1.3.15-7.module_el8.0.0+189+f9babebb.x86_64 | ||
+ | ipxe-roms-qemu-20181214-1.git133f4c47.el8.noarch | ||
+ | iso-codes-3.79-2.el8.noarch | ||
+ | libX11-1.6.7-1.el8.x86_64 | ||
+ | libX11-common-1.6.7-1.el8.noarch | ||
+ | libX11-xcb-1.6.7-1.el8.x86_64 | ||
+ | libXau-1.0.8-13.el8.x86_64 | ||
+ | ... | ||
+ | </sxh> | ||
</ | </ | ||
- | ---- | + | <WRAP center box 100%> |
- | + | We are also installing | |
- | ===== Starten des Virt Managers ===== | + | |
- | + | ||
- | Virt Manager is a graphical tool through which we can install and manage virtual machines. To start the virt manager type the '**virt-manager**' | + | |
< | < | ||
- | # virt-manager | + | # dnf install -y virt-install |
</ | </ | ||
- | {{:redhat:virtualization-redhat:virt-manger-1.jpg? | + | <sxh bash; gutter: false;> |
+ | ... | ||
+ | ================================================================================ | ||
+ | Installing: | ||
+ | virt-install | ||
+ | Installing dependencies: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | virt-manager-common noarch 2.0.0-5.1.el8 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
- | ---- | + | Transaction Summary |
+ | ================================================================================ | ||
+ | Install | ||
+ | ... | ||
+ | </ | ||
- | ===== Configure Bridge Interface ===== | + | </ |
- | Before Start creating VMs , let’s first create the bridge interface. Bridge interface is required if you want to access virtual machines from outside of your hypervisor network. | + | |
- | < | ||
- | # cd / | ||
- | # cp ifcfg-eno49 ifcfg-br0 | ||
- | </ | ||
- | <WRAP center | + | <WRAP center box 100%> |
- | **Edit** | + | '' |
< | < | ||
- | # vim ifcfg-eno49 | + | # virt-host-validate |
</ | </ | ||
- | * '' | + | <sxh bash; gutter: false;> |
- | | + | QEMU: Checking for hardware virtualization |
- | | + | QEMU: Checking if device /dev/kvm exists |
- | | + | QEMU: Checking if device /dev/kvm is accessible |
- | | + | QEMU: Checking if device / |
+ | QEMU: Checking if device / | ||
+ | QEMU: Checking for cgroup | ||
+ | QEMU: Checking for cgroup | ||
+ | | ||
+ | QEMU: Checking for cgroup | ||
+ | | ||
+ | QEMU: Checking for cgroup | ||
+ | | ||
+ | QEMU: Checking for cgroup | ||
+ | | ||
+ | QEMU: Checking for cgroup | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for device assignment IOMMU support | ||
+ | QEMU: Checking if IOMMU is enabled by kernel | ||
+ | </ | ||
- | </ | + | It looks like '' |
- | <WRAP center round box 100%> | + | The solution is already suggested by the above command. Therefore, we are adding |
- | **Edit** | + | |
- | < | + | < |
- | # vim ifcfg-br0 | + | |
- | </ | + | |
- | * '' | + | <wrap em>To take effect, restart your machine!</ |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | <wrap em> | + | After reboot, again run the '' |
- | </ | + | |
- | Restart the network Service to enable the bridge interface. | + | <sxh bash; gutter: false;> |
+ | QEMU: Checking for hardware virtualization | ||
+ | QEMU: Checking if device /dev/kvm exists | ||
+ | QEMU: Checking if device /dev/kvm is accessible | ||
+ | QEMU: Checking if device / | ||
+ | QEMU: Checking if device / | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for cgroup ' | ||
+ | QEMU: Checking for device assignment IOMMU support | ||
+ | QEMU: Checking if IOMMU is enabled by kernel | ||
+ | </ | ||
- | < | + | '' |
- | # systemctl restart network | + | </WRAP> |
- | </code> | + | |
- | Check the Bridge interface configuration, | + | KVM and QEMU hypervisors has been installed on CentOS 8. |
- | < | ||
- | # ip addr show br0 | ||
- | </ | ||
- | ---- | + | ===== Configure KVM Environment |
- | + | ||
- | ===== Start Creating Virtual Machines. | + | |
- | Create Virtual Machine either from the command line using ' | + | |
<WRAP center box 100%> | <WRAP center box 100%> | ||
- | '' | + | '' |
- | | + | If you want to allow your login user (non-root) to run virsh command or other KVM/QEMU commands, or use these commands without sudo, (needed by cockpit) then add your login user to the libvirt group as follows: |
- | - Go to the File Option, click on '' | + | |
- | - We will be using ISO file as installation media. In the next step Specify the path of ISO file.{{: | + | |
- | - Click on Forward. And specify the Compute Resources : RAM and CPU as per your setup. {{: | + | |
- | - Click on Forward | + | |
- | - In the Next step Specify the Name of Virtual Machine and select network | + | |
- | - Click on Finish to start the installation. {{: | + | |
- | + | ||
- | ''< | + | |
+ | < | ||
+ | # usermod -aG libvirt YOURUSERNAME | ||
+ | </ | ||
</ | </ | ||
+ | |||
+ | <WRAP center box 100%> | ||
+ | '' | ||
---- | ---- | ||
- | ===== Creating a virtual Machine from Command Line: ===== | + | Create needed directories: |
- | + | ||
- | Virtual Machines can be created from the console as well using the '' | + | |
< | < | ||
- | # virt-install --name=Ubuntu-16-04 --file=/var/lib/libvirt/images/ | + | # mkdir -p /data01/vm-storage |
+ | # mkdir /data01/iso-images | ||
</ | </ | ||
- | The above **virt-install** command consitst of following options : | + | ---- |
- | * **–name** = <Name of the Virtual Machine> | + | Make the virsh pool configuration changes: |
- | * **–file** = < | + | |
- | * **–file-size** = < Size of the Virtual Machine, in my case it is 20GB > | + | |
- | * **–nonsparse** = < Allocate the whole storage while creating> | + | |
- | * **–graphics** = < Specify the graphical tool for interactive installation, | + | |
- | * **–vcpu** = < Number of virtual CPU for the Machine > | + | |
- | * **–ram** = < RAM size for the virtual Machine > | + | |
- | * **–cdrom** = < Virtual CD ROM which specify the installation media like ISO file > | + | |
- | * **–network** = < it is used to specify which network we will use for the virtual machine, in this example I am bridge interface> | + | |
- | * **–os-type** = < Operating system type like linux and window> | + | |
- | * **–os-variant**= <KVM maintains the OS variants like ‘fedora18′, | + | |
+ | - Listing current pools: < | ||
- | Open now the Virt Viewer | + | Name |
+ | ------------------------------------------- | ||
+ | default | ||
+ | </sxh> | ||
+ | - Destroying pool:< | ||
+ | - Undefine pool:< | ||
+ | - Defining a new pool with name " | ||
+ | - Set pool to be started when libvirt daemons starts:< | ||
+ | - Start pool:# virsh pool-start default</ | ||
+ | - Checking pool state:< | ||
+ | Name | ||
+ | ------------------------------------------- | ||
+ | default | ||
+ | </ | ||
- | {{: | + | From now, when creating virtual machines, Virtual Machine Manager will inform you that the *.img file (virtual disk of your VM), will be saved at ''/ |
+ | </ | ||
- | Follow the instruction now and complete the installation. | + | ===== Installing Cockpit Web Interface in CentOS 8 ===== |
- | Once the Installation is completed | + | Although, KVM commandline-tools are quite sufficient for managing a Virtualization environment. But, we can also use the CentOS 8 native Web UI i.e. Cockpit to manage virtual machines via a graphical interface. |
- | {{: | + | We are installing Cockpit using dnf command. To add support of managing virtual machines, we have to install cockpit-machines package as well. |
- | That’s it, basic installation and configuration of KVM hypervisor is completed. | ||
- | |||
- | ---- | ||
<WRAP center box 100%> | <WRAP center box 100%> | ||
- | ===== KVM Manageing (web-Based): | + | < |
- | Solutions to manage and supervise virtual | + | # dnf install -y cockpit cockpit-machines |
+ | </ | ||
- | <WRAP center round tip 100%> | + | <sxh bash; gutter: false;> |
- | * '' | + | ... |
- | * '' | + | ================================================================================ |
+ | Installing: | ||
+ | | ||
+ | cockpit-machines | ||
+ | Installing dependencies: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | ... | ||
+ | </sxh> | ||
</ | </ | ||
+ | <WRAP center box 100%> | ||
+ | Enable and start Cockpit Unit. | ||
+ | < | ||
+ | # systemctl enable --now cockpit.socket | ||
+ | </ | ||
+ | |||
+ | <sxh bash; gutter: false;> | ||
+ | Created symlink / | ||
+ | </ | ||
- | '' | + | '' |
- | * https:// | + | |
- | * https:// | + | |
</ | </ | ||
+ | Browse URL https:// | ||
+ | |||
+ | The Cockpit uses a self-signed SSL certificate, | ||
+ | Ignore the Security warning and continue to the website. | ||
- | ---- | ||
- | ===== Redhat Dokumentation zum Thema ===== | ||
- | <WRAP center round download 80%> | ||
- | '' | ||
- | </ | ||