Installation and use of KVM virtualization technology under Linux

Source: Internet
Author: User

Installation and use of KVM virtualization technology under Linux

The advent of the cloud era, the widespread use of virtualization. Let's redefine the technology . And today's well-known virtualization products are VMware vsphere, HYPER-V,XEN,KVM. VMware is a marketplace for virtualization, and Hyper-V is virtualization under the Windows platform, and Xen is a semi-virtualized product. KVM is the object we are introducing today.

( KVM is a shorthand for kernel virtual module )KVM is the latest virtualization technology product since Red Hat's 5.4 release. It and vpc,virtual box are all part of a fully virtualized product, and Xen is a semi-virtualized product. PS: here the full virtualization and semi-virtualized in the subsequent blog will be updated can also check the online information.

The implementation of the full virtualization of Xen requires the support of the hardware, its implementation is the need for CPU is the support of VT technology, this technology in inter company CPU is called VMX, and on AMD is called SVM, Although the full virtualization of Xen has not done much, it does not affect his dominance in the semi-virtualized world.

KVM is also a reference to many of the achievements in Xen para-virtualization, although KVM is fully virtualized , but supporting semi-virtualized virtio on critical hard drives and network cards , to a large extent, improves performance,and KVM is the representative of lightweight virtualization, Support is also required for hardware VT technology, and from the operator interface,Xen and KVM are all using the Virt-manager tool, which is not very different, but can not be installed and run simultaneously on the same machine Xen and KVM , and KVM can only be run on the Red Hat Enterprise 5.4 system , while the SELinux needs to be turned off .

KVM refers to a Linux kernel-based virtual machine (kernel-based). Adding KVM to the Linux kernel is an important milestone in Linux development and is the first virtualization technology to be integrated into the Linux mainline core.

The method used by KVM is to convert the Linux kernel to a hypervisor by simply loading the kernel modules. This kernel module exports a device called/DEV/KVM, which enables the kernel's customer mode (in addition to the traditional kernel mode and user mode). With the/DEV/KVM device, the VM makes its own address space independent of the address space of the kernel or any other VM running. Devices in the device tree (/dev) are common to all user-space processes. But each process that opens the/DEV/KVM sees a different mapping (in order to support isolation between VMS). After KVM installs KVM, you can start the guest operating system in user space. Each guest operating system is a single process for the host operating system (or hypervisor).

1. KVM management tools for virtual machines

 accurately speaking,Kvmis onlyLinuxa module in the kernel. Manage and create a completeKvmvirtual machines require more assistive tools. Qemu-kvm: InLinuxsystem, first we can useModprobeCommand LoadKvmmodule, if usedRpminstallationKvmsoftware package, the system automatically loads the module at startup. After the module is loaded, you can further create the virtual machine from another tool. But there are onlyKvmmodules are far from enough because users cannot directly control the kernel modules to do things and must also have a user-space tool. Tools for user space,Kvmdeveloper chose the already formed open source virtualization softwareQemu. Qemuis a powerful virtualization software, it can be virtual differentCpuarchitecture. For example, inx86of theCpuon the virtual onePowerof theCpuand use it to compile a run-Poweron the program. Kvmused aQemuof based onx86part, and a little modification to form a controllableKvmuser space tools for kernel modulesQemu-kvm. SoLinuxin the release version is divided intokernel part of theKvmkernel modules andQemu-kvmtools. This isKvmand theQemuthe relationship. Libvirt,Virsh,Virt-manager: AlthoughQemu-kvmtools to create and manageKvmvirtual machines,RedHatto beKvmmore assistive tools have been developed, such asLibvirt,Libguestfsand so on. Reason isQemutools are inefficient and not easy to use. Libvirtis a set of interfaces that provide multiple languages.Api, provides a convenient and reliable programming interface for various virtualization tools, not only supportsKvm, and SupportXenand other virtual machines. UseLibvirt, you just need to passLibvirtthe provided function is connected to theKvmorXenhost, you can use the same command to control different virtual machines. Libvirtnot only provides aApiand comes with a set of text-based commands for managing virtual machinesVirsh, you can use theVirshcommand to useLibvirtall the functions. But the end user is more eager for the graphical user interface, which isVirt-manager. He is a set ofPythonthe virtual machine Management graphical interface is written to allow users to intuitively manipulate different virtual machines. Virt-manageris to useLibvirtof theApiimplemented.

2, the installation of KVM virtual machine.

(a) Before installing the virtualization function to turn on the CPU, if the physical machine directly into the BIOS on the virtualization option to open, if it is

VMware worksation

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5D/FC/wKiom1Uof6LiaQdfAAGLJwhqsLI269.jpg "title=" Virtualization check. jpg "alt=" wkiom1uof6liaqdfaagljwhqsli269.jpg "/>

If it is vsphere, it is also in the settings to find the CPU settings to turn on virtualization support.

Check that virtualization is successfully supported after Setup:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5D/FC/wKiom1UogJbDJGTdAAQeMzerK-4798.jpg "title=" Check whether virtualization is supported. jpg "alt=" wkiom1uogjbdjgtdaaqemzerk-4798.jpg "/>

Good support for success.

(ii) installation of KVM software

#yum Install KVM Virt-manager libvirt#service libvirtd start#chkconfig libvirt on

KVM-KVM Module Package

Virt-manageer Management Pack for KVM

Libvirt a toolkit for creating virtual machines

(iii) Check the correct installation of the module

Use Lsmod to check module installation

#[[email protected] ~]# lsmod | grep KVM#KVM 333172 0

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5D/F7/wKioL1UogxOQURoxAAAaVLgfPFE529.jpg "title=" Check if the KVM module is installed. jpg "alt=" wkiol1uogxoquroxaaaavlgfpfe529.jpg "/>

(iv) check if KVM is installed successfully

#virsh-C Qemu:///system List

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5D/FC/wKiom1UognLwhoyqAAA9H-JNLFs241.jpg "title=" Check that the KVM is successfully installed. jpg "alt=" wkiom1uognlwhoyqaaa9h-jnlfs241.jpg "/>

Since I created a virtual machine here before, there will be a display here, the initial installation of the horizontal line is not normal under. In addition, if the error, check whether the above service starts normally.

Network configuration for 3,KVM

one is default, which supports host-to-virtual-machine visits and also enables virtual machines to access the Internet, but does not support outside access to virtual machines.

Another way is Bridge mode, which can be used as a host with independent IP in the network .

I am using the second network configuration here.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5D/FC/wKiom1Uog2qih620AARPv4JmCxo938.jpg "title=" NIC configuration. jpg "alt=" wkiom1uog2qih620aarpv4jmcxo938.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5D/FC/wKiom1Uog4jjdarrAADGUex0WV4272.jpg "title=" Network card file view. jpg "alt=" wkiom1uog4jjdarraadguex0wv4272.jpg "/>

#[[email protected] network-scripts]# VI ifcfg-br0#device=br0#type=bridge#bootrpoto=static#ipaddr=192.168.7.2# Netmask=255.255.255.0#onboot=yes #[[email protected] network-scripts]# VI ifcfg-eth0#device=eth0#hwaddr=c0:3f:d5:3 a:fd:c4#type=ethernet#uuid=ea494507-eb1f-45a7-9582-64671dc60298#onboot=yes#nm_controlled=yes#bootproto=none# Ipaddr=192.168.7.2#prefix=16#bridge=br0

The above is the KVM configuration down to start the virtual machine installation.

Virt-manager is a libvirt -based, graphical virtual machine management software, note that different versions of Virt-manager may be different , and the graphics interface and operating methods may be different. This article uses the Red Hat 6 Enterprise Edition of virt-manager-0.8.4-8. The simplest way to create a KVM virtual machine is through the Virt-manager interface. Launch the tool from the console window, enter the Virt-manager command from root , and click on the " new " option in the File menu Virt-manager Interface interface.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/F7/wKioL1Uohb-wbX8vAAHJHxfTL1g760.jpg "title=" 1.png " alt= "Wkiol1uohb-wbx8vaahjhxftl1g760.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/FC/wKiom1UohHPRTtz8AAHq2QE5LAU644.jpg "title=" 2.png " alt= "Wkiom1uohhprttz8aahq2qe5lau644.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/F7/wKioL1Uohb-gFmcEAAFrrY0QuWo485.jpg "title=" 3.png " alt= "Wkiol1uohb-gfmceaafrry0quwo485.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/FC/wKiom1UohHOg6S9DAAG7KNQnjIA130.jpg "title=" 4.png " alt= "Wkiom1uohhog6s9daag7knqnjia130.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/F8/wKioL1UohcDy4JLZAAHWZ73R_Ms215.jpg "title=" 5.png " alt= "Wkiol1uohcdy4jlzaahwz73r_ms215.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/FC/wKiom1UohHTQrCQGAAGD8gEj4kw171.jpg "title=" 6.png " alt= "Wkiom1uohhtqrcqgaagd8gej4kw171.jpg"/>


Down is the installation of the system is not much to do introduction!

4. Using Virsh to manage KVM

the management of Virsh is more complicated. But another alternative way to Virt-manager The flaw isthat Virt-manager needs to run inside the system, which wastes resources and provides an additional point of attack for people with a purpose. Another big drawback of Virt-manager is the need to run remote access through a graphics workstation to manage the virtual machines on the server. Virsh can perform a variety of administrative tasks through the command line. It is difficult to learn virsh because there are many commands. Virsh manages each virtual machine feature through the main command and subcommands. To view all commands, enter Virsh help. You may find a lot of commands, but each command has a Help guide, and you only need to enter Virsh. For example , you can see all the Help for the Virsh URI command using the Virsh helper URI. Here is an example of the virsh command:

Create a name that is myWin7 of the Windows 7 virtual machines,

#[[email protected] ~]# yuminstall virt-viewer#[[email protected] ~]# virt-install--name mywin7--ram 1024x768--file=/var/li B/libvirt/images/mywin7.img--file-size=15--vnc--cdrom=/iso/win7_32.iso--network network:br0

Common Parameters Introduction:

-N NAME,--name=name Specify machine name

-R MEMORY,--ram=memory Specify memory size

--vcpus=vcpus Specifies the virtual machine's Number of CPUs

-F diskfile,--file=diskfile Virtual machine virtual disks, which can be files, disk partitions, or LVM. Use this option to specify the path to the virtual disk

-S disksize,--file-size=disksize Specifies the size of the virtual disk, in units of G; If-the file path specified by files does not exist, and the-nonsparse option is not specified, storage space is not pre-allocated for this file.

-W NETWORK,--network=network the NETWORK has three options,bridge:bridge,network:name and user

-C CDROM,--cdrom=cdrom             Specifies the virtual Guest ISO image file, or it can be a CDROM device, or it can be a URL can be accessed and retrieved Boot.iso Mirror. If it is omitted, then in the- location option must be specified kernel and initrd location, you can also use- PXE parameters are installed over the network.

--pxe Use The PXE Boot protocol is used to load the initialized RAMDisk and kernelso that the installation of the Guset segment is initiated into the process. If you do not specify-PXE, then you must specify-cdrom and --location one .

-L location,--location=location Specifies the installation source for kernel and initrd , which is required for para-virtualization. For full virtualization, either use --location or use --cdrom to specify an ISO or cdrom mirror.

It must conform to the following four formats:

DIRECTORY

Nfs:host:/path

Http://host/path

Ftp://host/path

-xextra,--extra-args=extra used to provide additional kernel command-line arguments to the loaded kernel and INITRD.

( with detailed parameters and how to use the method see Manvirt-install)

After the command is executed, the management interface to the KVM will be Win7.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/FC/wKiom1UohfeRbr14AAQuf5wf_eQ477.jpg "title=" 7.png " alt= "Wkiom1uohferbr14aaquf5wf_eq477.jpg"/>

Down the Win7 installation system will not say much!

At this point KVM installation and use of the introduction of so much, there are insufficient please advise!

This article is from "Big and Small" blog, make sure to keep this source http://chongge.blog.51cto.com/8894476/1631140

Installation and use of KVM virtualization technology under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.