Personally, it’s easiest for me to think of KVM (Kernel-based Virtual Machine) as a level of abstraction over Intel VT-x and AMD-V hardware virtualization technologies. We take a machine with a processor that supports one of these technologies, install Linux on this machine, install KVM in Linux, and as a result we get the opportunity to create virtual machines. That's pretty much how they work cloud hostings eg Amazon Web Services. Along with KVM, Xen is also sometimes used, but a discussion of this technology is beyond the scope of this post. Unlike container virtualization technologies, for example, Docker, KVM allows you to run any OS as a guest system, but it also has O Higher overhead for virtualization.

Note: The steps described below have been tested by me on Ubuntu Linux 14.04, but in theory they will be largely valid for both other versions of Ubuntu and other Linux distributions. Everything should work both on the desktop and on the server, accessed via SSH.

Installing KVM

We check whether Intel VT-x or AMD-V is supported by our processor:

grep -E "(vmx|svm)" /proc/cpuinfo

If something gets hot, it means it is supported, and you can move on.

Installing KVM:

sudo apt-get update
sudo apt-get install qemu-kvm libvirt-bin virtinst bridge-utils

What is usually stored where:

  • /var/lib/libvirt/boot/ - ISO images for installing guest systems;
  • /var/lib/libvirt/images/ - images hard drives guest systems;
  • /var/log/libvirt/ - here you should look for all logs;
  • /etc/libvirt/ - directory with configuration files;

Now that KVM is installed, let's create our first virtual machine.

Creating the first virtual machine

I chose FreeBSD as the guest system. Download the ISO image of the system:

cd /var/lib/libvirt/boot/
sudo wget http:// ftp.freebsd.org/ path/ to/ some-freebsd-disk.iso

Control virtual machines in most cases this is done using the virsh utility:

sudo virsh --help

Before launching the virtual machine, we will need to collect some additional information.

We look at the list of available networks:

sudo virsh net-list

View information about a specific network (named default):

sudo virsh net-info default

Let's look at the list of available optimizations for guest operating systems:

sudo virt-install --os-variant list

So, now we create a virtual machine with 1 CPU, 1 GB of RAM and 32 GB of disk space, connected to the default network:

sudo virt-install\
--virt-type =kvm\
--name freebsd10\
--ram 1024\
--vcpus=1\
--os-variant =freebsd8 \
--hvm\
--cdrom =/ var/ lib/ libvirt/ boot/ FreeBSD-10.2 -RELEASE-amd64-disc1.iso \
--network network =default,model =virtio \
--graphics vnc\
--disk path =/ var/ lib/ libvirt/ images/ freebsd10.img,size =32 ,bus =virtio

You can see:

WARNING Unable to connect to graphical console: virt-viewer not
installed. Please install the "virt-viewer" package.

Domain installation still in progress. You can reconnect to the console
to complete the installation process.

This is normal, this is how it should be.

Then look at the properties of the virtual machine in XML format:

sudo virsh dumpxml freebsd10

Here are the most full information. This includes, for example, a MAC address, which we will need later. For now we are finding information about VNC. In my case:

Using your favorite client (I personally use Rammina), we log in via VNC, using SSH port forwarding if necessary. We get straight into the FreeBSD installer. Then everything is as usual - Next, Next, Next, we get the installed system.

Basic commands

Let's now look at the basic commands for working with KVM.

Getting a list of all virtual machines:

sudo virsh list --all

Obtaining information about a specific virtual machine:

sudo virsh dominfo freebsd10

Launch virtual machine:

sudo virsh start freebsd10

Stop virtual machine:

sudo virsh shutdown freebsd10

Hardly nail the virtual machine (despite the name, this Not deletion):

sudo virsh destroy freebsd10

Reboot the virtual machine:

sudo virsh reboot freebsd10

Clone virtual machine:

sudo virt-clone -o freebsd10 -n freebsd10-clone \
--file /var/lib/libvirt/images/freebsd10-clone.img

Enable/disable autorun:

sudo virsh autostart freebsd10
sudo virsh autostart --disable freebsd10

Running virsh in dialog mode (all commands in dialog mode - as described above):

sudo virsh

Editing the properties of the virtual machine in XML, including here you can change the limit on the amount of memory, etc.:

sudo virsh edit freebsd10

Important! Comments from the edited XML are unfortunately removed.

When the virtual machine is stopped, the disk can also be resized:

sudo qemu-img resize /var/ lib/ libvirt/ images/ freebsd10.img -2G
sudo qemu-img info /var/lib/libvirt/images/freebsd10.img

Important! Your guest OS probably won't like the disk suddenly getting bigger or smaller. At best, it will boot into emergency mode with a proposal to repartition the disk. You probably shouldn't want to do that. It may be much easier to create a new virtual machine and migrate all the data to it.

Backup and restore are quite simple. It is enough to save the dumpxml output somewhere, as well as the disk image, and then restore them. On YouTube managed to find the video With a demonstration of this process, everything is really not difficult.

Network settings

An interesting question - how to determine what IP address the virtual machine received after loading? KVM does this in a clever way. I ended up writing this script in Python:

#!/usr/bin/env python3

# virt-ip.py script
# (c) 2016 Aleksander Alekseev
# http://site/

import sys
import re
import os
import subprocess
from xml .etree import ElementTree

def eprint(str) :
print(str, file = sys.stderr)

if len(sys.argv)< 2 :
eprint("USAGE: " + sys .argv [ 0 ] + " " )
eprint("Example: " + sys .argv [ 0 ] + " freebsd10" )
sys.exit(1)

if os .geteuid() != 0 :
eprint("ERROR: you should be root" )
eprint("Hint: run `sudo " + sys .argv [ 0 ] + " ...`" ) ;
sys.exit(1)

if subprocess .call ( "which arping 2>&1 >/dev/null", shell = True ) != 0 :
eprint("ERROR: arping not found" )
eprint( "Hint: run `sudo apt-get install arping`")
sys.exit(1)

Domain = sys.argv[1]

if not re .match ("^*$" , domain) :
eprint( "ERROR: invalid characters in domain name")
sys.exit(1)

Domout = subprocess .check_output ("virsh dumpxml " +domain+" || true" ,
shell = True)
domout = domout.decode("utf-8").strip()

if domout == "" :
# error message already printed by dumpxml
sys.exit(1)

Doc = ElementTree.fromstring(domout)

# 1. list all network interfaces
# 2. run `arping` on every interface in parallel
#3.grep replies
cmd = "(ifconfig | cut -d " " -f 1 | grep -E "." | " + \
"xargs -P0 -I IFACE arping -i IFACE -c 1 () 2>&1 | " + \
"grep "bytes from") || true"

for child in doc.iter() :
if child.tag == "mac" :
macaddr = child.attrib["address"]
macout = subprocess .check_output (cmd .format (macaddr) ,
shell = True)
print(macout.decode("utf-8"))

The script works with both the default network and the bridged network, the configuration of which we will look at later. However, in practice, it is much more convenient to configure KVM so that it always assigns the same IP addresses to guest systems. To do this, edit the network settings:

sudo virsh net-edit default

... something like this:

>



>

After making these changes


>

... and replace it with something like:




>

We reboot the guest system and check that it has received an IP via DHCP from the router. If you want the guest system to have a static IP address, this is configured as usual within the guest system itself.

virt-manager program

You may also be interested in the virt-manager program:

sudo apt-get install virt-manager
sudo usermod -a -G libvirtd USERNAME

This is what its main window looks like:

As you can see, virt-manager is not only a GUI for virtual machines running locally. With its help, you can manage virtual machines running on other hosts, as well as look at beautiful graphics in real time. I personally find it especially convenient in virt-manager that you don’t need to search through the configs to find out on which port VNC is running on a particular guest system. You just find the virtual machine in the list, double-click, and get access to the monitor.

With the help of virt-manager it is also very convenient to do things that would otherwise require labor-intensive editing of XML files and, in some cases, execution additional commands. For example, renaming virtual machines, setting CPU affinity and similar things. By the way, using CPU affinity significantly reduces the effect noisy neighbors and the impact of virtual machines on the host system. Always use it if possible.

If you decide to use KVM as a replacement for VirtualBox, keep in mind that they will not be able to share hardware virtualization between themselves. For KVM to work on your desktop, you will not only have to stop all virtual machines in VirtualBox and Vagrant, but also reboot the system. I personally find KVM much more convenient than VirtualBox, at least because it doesn't require you to run a command sudo /sbin/rcvboxdrv setup after each kernel update, it works adequately with Unity, and generally allows you to hide all windows.

KVM or Kernel Virtual Module is a virtualization module for the Linux kernel that allows you to turn your computer into a hypervisor for managing virtual machines. This module operates at the kernel level and supports hardware acceleration technologies such as Intel VT and AMD SVM.

By itself software KVM in user space does not virtualize anything. Instead, it uses the /dev/kvm file to configure virtual address spaces for the guest in the kernel. Each guest machine will have its own video card, network and sound card, hard drive and other equipment.

Also, the guest system will not have access to the components of the real operating system. The virtual machine runs in a completely isolated space. You can use kvm both on a GUI system and on servers. In this article we will look at how to install kvm Ubuntu 16.04

Before proceeding with the KVM installation itself, you need to check whether your processor supports hardware virtualization acceleration from Intel-VT or AMD-V. To do this, run the following command:

egrep -c "(vmx|svm)" /proc/cpuinfo

If the result returns 0, then your processor does not support hardware virtualization, if 1 or more, then you can use KVM on your machine.

Now we can proceed to installing KVM, a set of programs can be obtained directly from the official repositories:

sudo apt install qemu-kvm libvirt-bin bridge-utils virt-manager cpu-checker

We installed not only the kvm utility, but also the libvirt library, as well as the virtual machine manager. Once the installation is complete, you need to add your user to the libvirtd group, because only root and users in this group can use KVM virtual machines:

sudo gpasswd -a USER libvirtd

After running this command, log out and log in again. Next, let's check if everything was installed correctly. To do this, use the kvm-ok command:

INFO: /dev/kvm exists
KVM acceleration can be used

If everything was done correctly, you will see the same message.

Using KVM on Ubuntu 16.04

You have completed the task of installing kvm in Ubuntu, but you cannot yet use this virtualization environment but it still needs to be configured. Next, we will look at how kvm Ubuntu is configured. First you need to set up your network. We need to create a bridge with which the virtual machine will connect to the computer's network.

Setting up a bridge in NetworkManager

This can be done in several ways, for example, you can use the network configuration program NetworkManager.

Click the NetworkManager icon in the panel, then select change connections, then click the button Add:

Then select the connection type Bridge and press Create:

In the window that opens, click the button Add, to link our bridge to the internet connection:

From the list, select Ethernet and press Create:

In the next window, select in the field device, network interface to which our bridge should be associated:

Now you will see your bridge in the list of network connections. All that remains is to reboot the network to fully apply the changes, to do this, run:

Manual bridge setup

First you need to install the bridge-utils set of utilities if you have not already done so:

sudo apt install bridge-utils

Then, using the brctl program, we can create the bridge we need. To do this, use the following commands:

sudo brctl addbr bridge0
$ sudo ip addr show
$ sudo addif bridge0 eth0

The first command adds the bridge device br0, with the second you need to determine which network interface is the main connection to the external network, in my case it is eth0. And with the last command we connect bridge br0 to eth0.

Now you need to add a few lines to the network settings so that everything starts up automatically after the system starts. To do this, open the /etc/network/interfaces file and add the following lines there:

sudo gedit /etc/network/interfaces

loopback
auto lo bridge0
iface lo inet loopback
iface bridge0 inet dhcp
bridge_ports eth0

When the settings are added, reboot the network:

sudo systemctl restart networking

Now the installation and configuration of KVM is completely completed and you can create your first virtual machine. After this, you can view the available bridges using the command:

Creating KVM virtual machines

The Ubuntu KVM setup is complete and we can now move on to using it. First, let's look at the list of existing virtual machines:

virsh -c qemu:///system list

It's empty. You can create a virtual machine through the terminal or in the graphical interface. To create via the terminal, use the virt-install command. First let's go to the libvirt folder:

cd /var/lib/libvirt/boot/

To install CentOS the command will look like this:

sudo virt-install\
--virt-type=kvm \
--name centos7\
--ram 2048\
--vcpus=2 \
--os-variant=rhel7 \
--hvm\
--cdrom=/var/lib/libvirt/boot/CentOS-7-x86_64-DVD-1511.iso \
--network=bridge=br0,model=virtio \
--graphics vnc\
--disk path=/var/lib/libvirt/images/centos7.qcow2,size=40,bus=virtio,format=qcow2

Let's take a closer look at what the parameters of this command mean:

  • virt-type- type of virtualization, in our case kvm;
  • name- Name new car;
  • ram- amount of memory in megabytes;
  • vcpus- number of processor cores;
  • os-variant- type of operating system;
  • cdrom- installation image of the system;
  • network-bridge - network bridge, which we configured earlier;
  • graphics- a way to gain access to the graphical interface;
  • diskpath- address of the new hard drive for this virtual machine;

After the installation of the virtual machine is complete, you can find out the VNC connection parameters using the command:

sudo virsh vncdisplay centos7

Now you can enter the received data in your VNC client and connect to the virtual machine even remotely. For Debian the command will be slightly different, but everything looks similar:

Go to the folder for images:

cd /var/lib/libvirt/boot/

You can download the installation image from the Internet if necessary:

sudo wget https://mirrors.kernel.org/debian-cd/current/amd64/iso-dvd/debian-8.5.0-amd64-DVD-1.iso

Then let's create a virtual machine:

sudo virt-install\
--virt-type=kvm \
--name=debina8 \
--ram=2048\
--vcpus=2 \
--os-variant=debian8 \
--hvm\
--cdrom=/var/lib/libvirt/boot/debian-8.5.0-amd64-DVD-1.iso \
--network=bridge=bridge0,model=virtio \
--graphics vnc\
--disk path=/var/lib/libvirt/images/debian8.qcow2,size=40,bus=virtio,format=qcow2

Now let's look at the list of available machines again:

virsh -c qemu:///system list

To start the virtual machine you can use the command:

sudo virsh start machinename

To stop:

sudo virsh shutdown machinename

To switch to sleep mode:

sudo virsh suspend machinename

To reboot:

sudo virsh reboot machinename

sudo virsh reset machinename

For complete removal virtual machine:

sudo virsh destroy machinename

Creating virtual machines in GUI\

If you have access to a graphical interface, there is no need to use a terminal; you can use the full graphical interface of the Virtual Manager virtual machine manager. The program can be launched from the main menu:

To create a new machine, click on the icon with the monitor icon. Next you will need to select ISO image your system. You can also use a real CD/DVD drive:

On the next screen, select the amount of memory that will be available to the virtual machine, as well as the number of processor cores:

On this screen, you need to select the size of the hard drive that will be available in your machine:

At the last step of the wizard, you have to check that the machine settings are correct and also enter its name. You also need to specify the network bridge through which the machine will connect to the network:

After this, the machine will be ready for use and will appear in the list. You can launch it using the green triangle on the manager toolbar.

conclusions

In this article, we looked at how to install KVM Ubuntu 16.04, we looked at how to fully prepare this environment for work, as well as how to create virtual machines and use them. If you have any questions, ask in the comments!

To conclude, a lecture from Yandex about what virtualization is in Linux:

In Ubuntu, it is recommended to use the KVM hypervisor (virtual machine manager) and the libvirt library as a management tool for it. Libvirt includes a set of software APIs and custom applications management of virtual machines (VMs) virt-manager (graphical interface, GUI) or virsh (command line, CLI). As alternative managers, you can use convirt (GUI) or convirt2 (WEB interface).

Currently, only the KVM hypervisor is officially supported on Ubuntu. This hypervisor is part of the kernel code of the Linux operating system. Unlike Xen, KVM does not support paravirtualization, meaning in order to use it, your CPU must support VT technologies. You can check if your processor supports this technology by running the command in the terminal:

If you receive the following message as a result:

INFO: /dev/kvm exists KVM acceleration can be used

This means KVM will work without problems.

If you received the following message at the exit:

Your CPU does not support KVM extensions KVM acceleration can NOT be used

then you can still use the virtual machine, but it will be much slower.

    Install 64-bit systems as guests

    Allocate more than 2 GB of RAM to guest systems

Installation

Sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils

This is an installation on a server without X, i.e. it does not include a graphical interface. You can install it with the command

Sudo apt-get install virt-manager

After this, the “Virtual Machine Manager” item will appear in the menu and, with a high degree of probability, everything will work. If any problems still arise, you will need to read the instructions in the English wiki.

Creating a guest system

Procedure for creating a guest using GUI quite simple.

But the text mode can be described.

qcow2

When creating a system using the graphical interface as a hard disk, you are prompted to either select an existing image file or block device, or create new file with raw (RAW) data. However, this is far from the only file format available. Of all the disk types listed in man qemu-img, the most flexible and modern is qcow2. It supports snapshots, encryption and compression. It must be created before creating a new guest.

Qemu-img create -o preallocation=metadata -f qcow2 qcow2.img 20G

According to the same man qemu-img, preallocation of metadata (-o preallocation=metadata) makes the disk initially a little larger, but provides better performance in those moments when the image needs to grow. In fact, in this case, this option allows you to avoid an unpleasant bug. The created image initially takes up less than a megabyte of space and grows to the specified size as needed. The guest system should immediately see this final specified size, however, during the installation phase it may see the actual size of the file. Naturally, install on HDD 200 kB in size it will refuse. The bug is not specific to Ubuntu; it appears in RHEL, at least.

In addition to the type of image, you can subsequently choose the method of connecting it - IDE, SCSI or Virtio Disk. The performance of the disk subsystem will depend on this choice. There is no definite correct answer; you need to choose based on the task that will be assigned to the guest system. If the guest system is created “to look at,” then any method will do. In general, it is usually I/O that is the bottleneck of a virtual machine, so when creating a highly loaded system, this issue must be treated as responsibly as possible.

Today, many tasks that traditionally required multiple physical servers are moving to virtual environments. Virtualization technologies are also in demand by software developers, as they allow comprehensive testing of applications in various operating systems. At the same time, while simplifying many issues, virtualization systems themselves need to be managed, and this cannot be done without special solutions.

Vagrant

Virtual VirtualBox machine deservedly enjoys popularity among administrators and developers, allowing you to quickly create the desired environments using a graphical interface or interface command line. If the number of VMs does not exceed three, there are no difficulties in deployment and management, but modern projects tend to become overgrown with configurations, and the end result is a very complex infrastructure, which becomes difficult to cope with. This is the problem that the Vagrant virtual environment manager is designed to solve, allowing you to create copies of virtual machines with a predetermined configuration and dynamically redistribute VM resources (Provisioning) as needed. In the basic package, Vagrant works with VirtualBox, but the plugin system allows you to connect another virtualization system. Today, the plugin code for AWS and Rackspace Cloud is open; a plugin to support VMware Fusion/Workstation is available for a commercial subscription.

Vagrant does not create a virtual machine from scratch. For convenience, the project offers several basic images (boxes), which are imported and subsequently used for quick system deployment; a guest OS with the required configuration is assembled based on the boxes.

To simplify application deployment, boxes come pre-installed with Chef and Puppet. Besides, necessary settings can be set using the shell. The environments include a complete set for launching and developing applications in Ruby. SSH is used to access the VM; file exchange is possible through a shared directory.

Vagrant is written using Ruby and can be installed on any platform that has VirtualBox and Ruby components. Packages for Windows, Linux (deb and rpm) and OS X are available on the download page.

The installation and use process on Ubuntu is simple. Download the VirtualBox and Vagrant packages and install:

$ sudo dpkg -i virtualbox-4.2.10_amd64.deb $ sudo dpkg -i vagrant_1.2.2_x86_64.deb

At the time of writing this article, the latest current version VirtualBox 4.2.14 had problems running Vagrant, so for now it's better to use 4.2.12 or the test 4.2.15. Alternatively, you can do:

$ cd ~/.vagrant.d/boxes/BoxName/virtualbox $ openssl sha1 *.vmdk *.ovf > box.mf

I'll bring you Alternative option Vagrant installations - using Ruby:

$ sudo apt-get install ruby1.8 ruby1.8-dev rubygems1.8 $ sudo gem install vagrant

All project settings are made in special file Vagrantfile. To avoid creating the template manually, you can generate it as follows:

$ mkdir project $ cd project $ vagrant init

Now you can look into the created settings file and fill in: VM settings (config.vm. ), SSH connection options (config.ssh.), parameters of Vagrant itself (config.vagrant). All of them are well documented, the meaning of some is clear without explanation.

In fact, several such files are used at startup, each subsequent one overriding the previous one: built into Vagrant (it cannot be changed), supplied with boxes (packaged using the "--vagrantfile" switch), located in ~/.vagrant.d and the project file . This approach allows you to use default settings, overriding only what is necessary in a specific project.


All installations are performed using the vagrant command; the list of available keys can be viewed using "-h". After installation we do not have a single image, running vagrant box list will display an empty list. The finished box can be located in the local file system or on a remote server; its name is set as a parameter, by which we will refer in projects. For example, we use the official Box Ubuntu 12.04 LTS, offered by the Vagrant developers.

$ vagrant box add precise64 http://files.vagrantup.com/precise64.box

Now it can be accessed from Vagrantfile:

Config.vm.box = "precise64"

Although it’s easier to immediately specify it when initializing the project:

$vagrant init precise64

The easiest way, which does not require learning Chef and Puppet, is to use standard shell commands to configure the VM, which can be written directly in the Vagrantfile or, even better, combined into a script that is connected like this:

Vagrant.configure("2") do |config| config.vm.provision:shell, :inline => "script.sh" end

Now all commands specified in script.sh will be executed when the VM starts. When the project starts, an ovf file is created; its settings can be viewed using the VirtualBox graphical interface or the VBoxManage command:

$ VBoxManage import /home/user/.vagrant.d/boxes/precise64/virtualbox/box.ovf Virtual system 0: 0: Suggested OS type: "Ubuntu_64" (change with "--vsys 0 --ostype "; use "list ostypes" to list all possible values) 1: Suggested VM name "precise64" (change with "--vsys 0 --vmname ") 2: Number of CPUs: 2 (change with "--vsys 0 --cpus ") 3: Guest memory: 384 MB (change with "--vsys 0 --memory ")

They do not always satisfy the specified conditions, but using the provider settings, you can easily change the settings of a specific VM (see the “change with ...” tips):

Config.vm.provider:virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "1024"] end

Launch and connect to the system via SSH:

$vagrant up $vagrant ssh

To stop the VM, use the halt or destroy parameter (the second - with clearing all files, next time all operations will be performed from the beginning), if you need to send it into hibernation - vagrant suspend , return - vagrant resume . For an example of working with Chef, you can use a ready-made recipe to configure APT and Apache2:

Config.vm.provision:chef_solo do |chef| chef.recipe_url = "http://files.vagrantup.com/getting_started/cookbooks.tar.gz" chef.add_recipe("vagrant_main") end

To access the VM “from the outside”, you will need to configure port forwarding. By default, the forwarding is 22 -> 2222, allowing you to connect via SSH. Add to Vagrantfile:

Vagrant::Config.run do |config| config.vm.forward_port 80, 1111 end

The web server can now be accessed by going to http://127.0.0.1:1111/. In order not to configure the environment every time, it is better to assemble a ready-made package based on it.

$ vagrant package --vagrantfile Vagrantfile --output project.box

Now the project.box file can be distributed to other administrators, developers or ordinary users who will connect it using the vagrant box add project.box command.

ConVirt

Xen/KVM virtualization systems, released under free licenses, do not have a user-friendly interface, which is often interpreted not in their favor. However, this deficiency is easy to overcome. ConVirt allows you to deploy virtual machines across multiple Xen and KVM servers with just one click, using an easy-to-use interface. All necessary operations with virtual machines are available: starting, stopping, creating snapshots, controlling and redistributing resources, connecting to a VM via VNC, automating administration tasks. Ajax technology makes the interface interactive and similar to a desktop application. For example, you can simply drag and drop a VM from one server to another. The interface is not localized, but the controls are intuitive.


Pooling servers makes it possible to configure and control virtual machines and resources at the server pool level, rather than at the individual server level. No agents are installed on virtual systems; only the convirt-tool package is required on the physical server. This simplifies administration and deployment.

Once a new server is added, ConVirt will automatically collect its configuration and performance data, providing summary information at multiple levels - from the individual virtual machine, the physical server, to the entire pool. The collected data is used to automatically host new guests. This information is also displayed in the form of visual graphs.

To create virtual machines, templates are used - descriptions of the settings of the virtual machine, containing data about the allocated resources, the path to the OS files and additional settings. After installation there are several available ready-made templates, but if necessary, they are easy to create yourself.

All technologies are supported: load balancing, hot migration, virtual disks with growing capacity, allowing you to use resources as needed, and many other features implemented in Xen and KVM. The VM does not need to be stopped to reallocate resources.

Implemented the ability to manage a virtual environment for several administrators with the ability to audit and control their actions.

ConVirt is being developed by the Convirture company, and uses the open core concept, when only a basic set of functions is freely distributed along with the source code, the rest is available in a commercial version. IN open source This option lacks support for High Availability, VLAN integration, backup and recovery, command line management, notifications and official support.

During development, the TurboGears2 framework, ExtJs and FLOT libraries were used, MySQL was used to store information, and dnsmasq was used as a DHCP and DNS server. The required package can be found in the repositories of popular Linux distributions.

Karesansui

All features for managing virtual environments have been implemented: installing the OS, creating configurations of the disk subsystem and virtual network cards, quota management, replication, VM freezing, snapshot creation, viewing detailed statistics and log data, load monitoring. From one console you can manage several physical servers and virtual machines hosted on them. Multi-user work with shared rights is possible. As a result, the developers managed to implement a virtual environment in the browser that allows them to fully manage the systems.

Posted by Karesansui on Python language, SQLite is used as a DBMS for a single-node system. If you plan to manage Karesansui installations hosted on multiple physical servers, you should use MySQL or PostgreSQL.

You can deploy Karesansui on any Linux. The developers themselves prefer CentOS (for which the site has detailed instructions), although Karesansui works well on both Debian and Ubuntu. Before installation, you must complete all dependencies specified in the documentation. Next, the installation script is launched and the database is initialized. If a multi-server configuration is used, then you just need to specify the external database.

Subsequent work will fully compensate for the inconvenience of installation. All settings are divided into seven tabs, the purpose of which is clear from the name: Guest, Settings, Job, Network, Storage, Report and Log. Depending on the user's role, not all of them will be available to him.

You can create a new VM from a local ISO file or by specifying an HTTP/FTP resource with installation images. You will also need to set other attributes: the system name that will be displayed in the list, the network name (hostname), virtualization technology (Xen or KVM), the size of RAM and hard drive (Memory Size and Disk Size) - and select a picture that will correspond to the virtual OS, making it easier to quickly visually select in the console.

WebVirtMgr

The capabilities of the solutions described are often redundant, and their installation is not always clear to an administrator with little experience. But there is a way out here too. The service for centralized management of virtual machines WebVirtMgr was created as a simple replacement for virt-manager, which will provide comfortable work with VMs using a browser with a Java plug-in installed. KVM settings management is supported: creation, installation, configuration, launch of VMs, snapshots and backup of virtual machines. Provides management of network pool and storage pool, work with ISO, cloning images, viewing CPU and RAM load. The virtual machine is accessed via VNC. All transactions are recorded in logs. You can manage multiple KVM servers with a single installation of WebVirtMgr. To connect to them, use RPC libvirt (TCP/16509) or SSH.


The interface is written in Python/Django. For installation you will need a server under Linux control. Distributed in source code and RPM packages for CentOS, RHEL, Fedora and Oracle Linux 6. The deployment process itself is simple and well described in the project documentation (in Russian), you just need to configure libvirt and install webvirtmgr. The whole process takes five minutes. After connecting to the Dashboard, select Add Connection and specify the node parameters, then we can configure the VM.

Let's script the creation of a VM

The simplest script for creating and launching a virtual machine using VirtualBox:

#!/bin/bash vmname="debian01" VBoxManage createvm --name $(vmname) --ostype "Debian" --register VBoxManage modifyvm $(vmname) --memory 512 --acpi on --boot1 dvd VBoxManage createhd - -filename "$(vmname).vdi" --size 10000 --variant Fixed VBoxManage storagectl $(vmname) --name "IDE Controller" --add ide --controller PIIX4 VBoxManage storageattach $(vmname) --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "$(vmname).vdi" VBoxManage storageattach $(vmname) --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium /iso/debian-7.1.0-i386-netinst.iso VBoxManage modifyvm $(vmname) --nic1 bridged --bridgeadapter1 eth0 --cableconnected1 on VBoxManage modifyvm $(vmname) --vrde on screen VBoxHeadless --startvm $(vmname)

Proxmox VE

The previous solutions are good for situations where some infrastructure already exists. But if you just need to deploy it, it’s worth thinking about specialized platforms that allow you to quickly get the desired result. An example here is Proxmox Virtual Environment, which is Linux distribution(on Debian database 7.0 Wheezy), which allows you to quickly build a virtual server infrastructure using OpenVZ and KVM and is practically not inferior to such products as VMware vSphere, MS Hyper-V and Citrix XenServer.


In fact, the system only needs to be installed (a couple of simple steps), everything else already works out of the box. You can then create a VM using the web interface. For this purpose, the easiest way is to use OpenVZ templates and containers, which are loaded from external resources directly from the interface with one click (if manually, copy to the /var/lib/vz/template directory). But templates can also be created by cloning already created systems in linking mode. This option saves disk space because all linked environments use only one common copy of the reference template data without duplicating information. The interface is localized and understandable; you don’t experience any particular inconvenience when working with it.

There is support for clusters, tools for Reserve copy virtual environments, it is possible to migrate VMs between nodes without stopping work. Access control to existing objects (VM, storage, nodes) is implemented based on roles, various authentication mechanisms are supported (AD, LDAP, Linux PAM, built-in Proxmox VE). The web interface allows you to access the VM using VNC and SSH consoles, you can view job status, logs, monitoring data and much more. True, some operations specific to HA systems will still have to be performed the old fashioned way in the console, for example, creating an authorized iSCSI connection, setting up a cluster, creating a multipath and some other operations.

System requirements are small: CPU x64 (preferably with Intel VT/AMD-V), 1+ GB of RAM. The project offers a ready-made ISO image and repository for Debian.

Conclusion

All the solutions described are good in their own way and cope well with the assigned tasks. You just need to choose the one that best suits your specific situation.