Zusammenfassung der Ressource
102.6 Linux as a
virtualization
guest
- Introduction
- 1.-Virtual machine
2.- Linux container
3.- Application
container 4.- Guest
drivers 5.- SSH host
keys 6.- D-Bus
machine id
- Conceptos
- to use Linux as a
means of hosting other
operating systems,
- versatility
- hability
- great strengths
of Linux
- isolated and
secure
environment
- the concepts of
virtualization and
container technologie
- Virtualization Overview
- Virtualization
- Hypervisor
- sotfware platform that
allows to run processes
that contain a fully
emulated computer
system.
- is responsible for managing
the physical hardware’s
resources that can be used
by individual virtual
machines.
- guest
- Virtual Machine
- A virtual machine has
many aspects of a
physical computer
emulated in software
- System Bios
- Hard Drive Disk
Controllers
- often use
hard disk
images
- stored as
individual files,
- will have access to the host
machine’s RAM and CPU
through the hypervisor
software.
- Commonly used
hypervisors for Linux
include:
- Xen
- Type-1
hypervisor
- not rely on an
underlying
operating system
to function.
- bare-metal hypervisor
since the computer can
boot directly into the
hypervisor.
- KVM
- both Type-1
and Type-2
- although it needs a
generic Linux
operating system to
work,
- it is able to perform
as a hypervisor
perfectly well by
integrating with a
running Linux
installation
- use the libvirt daemon
and associated software
utilities to be created
and managed.
- VirtualBox
- t is a Type-2
hypervisor.
- VirtualBox requires an
underlying operating
system to run
- migration,
- Some hypervisors allow for
the dynamic relocation of a
virtual machine
- Implemets
- system
shutdown
- system
Runs
- The process of moving a
virtual machine from one
hypervisor installation to
another
- Types of
Virtual
Machines
- Fully Virtualized
- no additional software drivers are
installed within the guest to
translate the instructions to
either simulated or real hardware
- All instructions is
expected to run
- is unaware that it
is a running
virtual machine
instance
- to take place on
x86 based
hardware the
Intel VT-x or
AMD-V CPU
extensions
- Configured
Bios
- Paravirtualized
- is aware that it
is a running
virtual
machine
instance.
- make use of a
modified kernel
and special drivers
(known as guest
drivers
- will help the guest
operating system
utilize software and
hardware resources
of the hypervisor
- The performance of a
paravirtualized guest is
often better than that of
the fully virtualized
- Hybrid
- Paravirtualization
and full
virtualization can
be combined
- to allow unmodified operating
systems to receive near native I/O
performance by using paravirtualized
drivers on fully virtualized operating
systems.
- The paravirtualized
drivers contain
- Storage
Drivers
- Network
Drivers
- with
enhanced
disk
- network I/O
performance.
- Virtualization platforms often
provide packaged guest drivers for
virtualized operating systems.
- . The KVM utilizes
drivers from the
Virtio project
- Oracle VM VirtualBox
uses Guest Extensions
available
- libvirt Virtual
Machine
- uses the
KVM
hypervisor.
- consists of a group of
files, primarily an XML
file that defines the
virtual machine
- hardware configuration,
network connectivity,
display capabilities, and
more
- $ ls
/etc/libvirt/qemu
networks (d)
rhel8.0.xml (f)
- networks
- default.xml
- <network>
<name>default</name>
<uuid>55ab064f</uuid>
<forward mode='nat'/> <bridge
name='virbr0' stp='on'
delay='0'/> <mac
address='52:54:00:b8:e0:15'/>
<ip address='192.168.122.1'
netmask='255.255.255.0'>
<dhcp> <range
start='192.168.122.2'
end='192.168.122.254'/>
</dhcp> </ip> </network>
- Defined The
Network
- rhel8.0.xml
- virtual machine definition file
- <domain type='kvm'>
<name>rhel8.0</name> <memory
unit='KiB'>4194304</memory> <vcpu
placement='static'>2</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash> <disk
type='file' device='disk'> <driver
name='qemu' type='qcow2'/> <source
file='/var/lib/libvirt/images/rhel8'/> <target
dev='vda' bus='virtio'/><interface
type='network'> <mac
address='52:54:00:50:a7:18'/> <source
network='default'/> <model
type='virtio'/></interface><input
type='mouse' bus='ps2'/> <input
type='keyboard' bus='ps2'/> <graphics
type='spice' autoport='yes'>
- an associated hard disk
image file that contains
the installation of the
operating system and
its software
- /var/lib/libvirt/images/rhel8.
- This virtual machine’s hard
disk image
- sudo ls -lh
/var/lib/libvirt/images/rhel8
- 5.5G Oct 25 15:57
/var/lib/libvirt/images/rhel8
- $ lsblk
- COW
- The disk image size only
increases as new data is
written to the disk.
- RAW
- A raw or full disk type is
a file that has all of its
space pre-allocated.
- 102.6 Linux as
a virtualization
guest
- Working with
Virtual Machine
Templates
- virtual machines are
typically just files
running on a
hypervisor,
- it is easy to create templates
that can be customized for
particular deployment
scenarios.
- the new guest would get
renamed, a new MAC
address generated for its
network interface, and other
modification
- The D-Bus
Machine ID
- machine identification
number generated at
install time
- if a virtual machine is
cloned to be used as a
template for other virtual
machine installations,
- a new D-Bus machine ID would need to
be created to ensure that system
resources from the hypervisor get
directed to the appropriate guest
system.
- dbus-uuidgen --ensure
- can be used to
validate that a
D-Bus machine ID
exists for the
running system:
- To view the current
D-Bus machine ID, run
the following:
- $ dbus-uuidgen --get
17f2e0698e844e31b12ccd3f9aa4d94a
- Located
- /var/lib/dbus/machine-id
and is symbolically linked
to /etc/machine-id
- two virtual machines do have
the same D-Bus machine ID,
follow the procedure below to
generate a new one:
- $ sudo rm -f /etc/machine-id
- $ sudo dbus-uuidgen --ensure=/etc/machine-id
- Deploying
Virtual Machines
to the Cloud
- 1.- There are a multitude of IaaS
(infrastructure as a service) providers
available that run hypervisor systems and
that can deploy virtual guest images for
an organization.
- 1.- all of these providers have tools in place
that allows an administrator to build,
deploy and configure custom virtual
machines based on a variety of Linux
distributions.
- 2.- Many of these companies also
have systems in place that allow
for the deployment and
migrations of virtual machines
built from within a customer’s
organization.
- 2.- Deployment
- 1.- Computing Instances
- 1.-Many cloud providers will
charge usage rates based on
“computing instances”
- 2.- Careful planning of how
much processing time
applications
- 3.- refer to the number of
virtual machines that are
provisioned in a cloud
environment.
- 2.- Block Storage
- 1.- Cloud providers also
have various levels of
block storage
- 2.- Some offerings are simply
meant to be web-based
network storage for files,
- 4.- offerings relate to external storage
for a cloud provisioned virtual
machine to use for hosting files.
- 3.- The cost for such offerings will
vary based on the amount of
storage used, and the speed of
the storage
- 3.- Networking
- 1.-web-based utilities that can be
utilized for the design and
implementation of different
network routes, subnetting, and
firewall configurations.
- 2.- Some will even provide DNS
solutions so that publicly
accessible FQDN (fully qualified
domain names) can be assigned
to your internet facing systems.
- 3.- There are even “hybrid” solutions
available that can connect an existing,
on-premise network infrastructure to a
cloud-based infrastructure through the
means of a VPN (
- Securely Accessing
Guests in the Cloud
- The most prevalent method in use for
accessing a remote virtual guest on a cloud
platform is through the use of OpenSSH
software.
- Administrator
- ssh-keygen
- and follow the prompts to
create a public and private
SSH key pair
- Private Key
- (stored in ~/.ssh/)
System Local
- permissions 0600
- Public Key
- copied to the
remote cloud
system
- permissions
0644
- $ ssh-copy-id -i <public_key> user@cloud_server
- this will copy the public SSH key from the key pair
just generated to the remote cloud server.
- The public key will be recorded in the
~/.ssh/authorized_keys file of the cloud
server
- Some cloud providers will automatically
generate a key pair when a new Linux
system is provisioned.
- The administrator will then need to download the
public key for the new system from the cloud
provider and store it on their local system
- Preconfiguring
Cloud Systems
- the cloud-init utility.
- A useful tool that simplifies the
deployments of cloud-based virtual
machine
- with the associated configuration
files and pre-defined virtual
machine image,
- Utilizing YAML (YAML Ain’t Markup
Language) plain-text files an administrator
can pre-configure network settings,
software package selections,
- cloud-init will read in the settings from
YAML configurations files and apply them.
This process only needs to apply to a
system’s initial setup, and makes deploying
a fleet of new systems on a cloud provider’s
platform easy.
- #cloud-config
timezone:
Africa/Dar_es_Salaam
hostname: test-system
# Update the system
when it first boots up
apt_update: true
apt_upgrade: true #
Install the Nginx web
server packages: -
nginx
- Containers
- 1.- Container technology is similar in some
aspects to a virtual machine, where you get
an isolated environment to easily deploy an
application.
- 6.- a container uses just enough
software to run an application. In
this way, there is far less
overhead.
- 2.- Containers allow for greater flexibility
over that of a virtual machine.
- 3.- An application container can be migrated
from one host to another, just as a virtual
machine can be migrated from one
hypervisor to another
- 5.- Containers also make it easy to
deploy new versions of applications
in tandem with an existing version
- 4.- Containers make use of the control groups
(better known as cgroups) mechanism
within the Linux kernel
- cgroups
- 1.- is a way to partition
system resources
- such as memory,
processor time as well as
disk and network
bandwidth for an
individual application.
- 2.- An administrator can use cgroups
directly to set system resource
limits on an application,
- 3.- or a group of applications that
could exist within a single
cgroup.
- Pregutas y Respeustas
- 1.- What CPU extensions are necessary on an x86
based hardware platform that will run fully
virtualized guests?
- VT-x for Intel CPUs or
AMD-V for AMD CPUs
- 2.- A mission-critical server installation that will
require the fastest performance will likely use
what type of virtualization?
- paravirtualizado
- 3.- Two virtual machines that have been cloned from the same
template and that utilize D-Bus are performing erratically. They both
have separate hostnames and network configuration settings. What
command would be used to determine if each of the virtual machines
have different D-Bus Machine IDs?
- dbus-uuidgen --get
- Pregntas Exploratorias
- 1.- Run the following command to see if your system
already has CPU extensions enabled to run a virtual
machine (your results may vary depending on your CPU):
grep --color -E "vmx|svm" /proc/cpuinfo
- vmx highlighted (for Intel VT-x enabled CPU’s) or
svm highlighted (for AMD SVM enabled CPU’s).
- 2.- If your processor supports virtualizations,
seek out your distribution’s documentation
for running a KVM hypervisor.
- Ubuntu — https://help.ubuntu.com/lts/serverguide/libvirt.html
Fedora — https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-virtualization/
Arch Linux — https://wiki.archlinux.org/index.php/KVM
- 3.- If you are using a graphical desktop environment, it is
recommended to also install the virt-manager application which is a
graphical front-end that can be used on a KVM installation. This will aid
in virtual machine installations and management.3
- $ sudo apt install virt-manager
- 4.- Download a Linux distribution ISO image of your
choice, and following your distribution’s
documentation create a new virtual machine
using this ISO.
- This task is easily handled by the virt-manager
package. However a virtual machine can be created
from the command-line using the virt-install
command. Try both methods to get an
understanding of how virtual machines are
deployed.