KVM is the most widely used Hypervisor in OpenStack, and this section describes how to build a KVM lab environment
installing KVM
The previous section said that KVM is type 2 virtualization, which runs on top of the operating system, so we need to install a Linux first. Ubuntu, Redhat, CentOS can be, here we take Ubuntu14.04 as an example.
after the basic Ubuntu operating system is installed, install the required packages for KVM
$ sudo apt-get install QEMU-KVM qemu-system libvirt-bin virt-manager bridge-utils VLAN
With these installation packages we'll review the KVM knowledge described in the previous section by the way.
-
QEMU-KVM and Qemu-system are core packages of KVM and QEMU, providing CPU , Memory and IO virtualization features
-
libvirt-bin is Libvirt, for managing KVM, etc. Hypervisor
-
virt-manager is a KVM graphical management tool
-
bridge-utils and VLANs, primarily network virtualization needs, KVM The implementation of network virtualization is based on Linux-bridge and VLANs, which we will discuss later.
Ubuntu does not install the graphical interface by default, manually install
sudo apt-get install xinitsudo apt-get install gdmsudo apt-get Install Kubuntu-desktop
apt defaults to the official website to download the installation package, the speed is very slow, we can use the domestic mirror site.
config/etc/apt/sources.list
deb http://mirrors.163.com/ubuntu/trusty main restricted universe Multiversedeb http://mirrors.163.com/ubuntu/trusty-security main restricted universe Multiversedeb/HTTP Mirrors.163.com/ubuntu/trusty-updates main restricted universe Multiversedeb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiversedeb http://mirrors.163.com/ubuntu/trusty-backports main restricted Universe multiversedeb-src http://mirrors.163.com/ubuntu/trusty main restricted universe MULTIVERSEDEB-SRC/HTTP Mirrors.163.com/ubuntu/trusty-security main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/ Trusty-updates main restricted universe multiversedeb-src http://mirrors.163.com/ubuntu/trusty-proposed main Restricted Universe multiversedeb-src http://mirrors.163.com/ubuntu/trusty-backports main restricted universe Multiverse
then execute the following command to update the installation package index
# APT Update
The Redhat and CentOS installations are relatively straightforward, and the virtualization and graphics components are selected during installation.
tip: Ubuntu default is not allow root via SSH Direct login, you can modify the/etc/ssh/sshd_config, set
Permitrootlogin Yes
Then restart the SSH service to
# service SSH restartssh stop/waitingssh start/running, Process 27639
Experiment on a virtual machine
As a KVM for type 2 virtualization, virtualization nesting is supported, which allows us to experiment with KVM in virtual machines. For example, I installed a Ubuntu14.04 virtual machine in VMWare Workstation, in order to enable KVM to create nested virtual machine, to the CPU virtualization function to open. For example, set the following CPU mode in VMWare
after Ubuntu starts, use the following command to confirm that the CPU supports virtualization
# egrep-o ' (VMX|SVM) '/proc/cpuinfo# vmx
Confirm that the LIBVIRTD service is started
# service Libvirt-bin Statuslibvirt-bin start/running, process 1478
Prepare a KVM lab environment-5 minutes a day to play OpenStack (3)