In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you what is the use of KVM, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. Virtualization 1. Background
The US Environmental Protection EPA report once counted a group of statistics: when EPA studied the energy efficiency of servers and data centers, it was found that in fact, only 5% of the time the server was working and the rest of the time was dormant, so the utilization rate of the server would be very low, and these servers would be powered on all the time, so they would naturally consume a lot of energy.
2. Introduction of virtualization technology
Through virtualization technology, a computer is virtualized into multiple logical computers, and multiple logical computers are run on one computer at the same time, and each logical computer can run a different operating system at the same time. Applications can run in independent spaces without affecting each other, thus improving the work efficiency of the computer.
3. The development of virtualization technology
Prototype:
In 1961, the IBM709 machine implemented a time-sharing system, dividing the CPU occupancy into a number of very short time slices (1/100sec), each performing a different job, by polling these time slices.
To disguise a CPU as multiple CPU
In 1972, IBM officially named the time-sharing system of system 370 as virtual machine.
In 1990, the system 390 launched by IBM supports logical partitioning (dividing a CPU into multiple parts, independent of each other, that is, logical segmentation).
Xen was introduced in 2003 as an external hypervisor program (hypervisor) that controls virtual machines and allocates resources to multiple clients.
KVM:2007, which is now built into the kernel kernel
Virtualization technologies supported by Xen: full virtualization, paravirtualization
KVM: supported Virtualization Technology: full Virtualization
4. Virtualization type
1) full virtualization: all physical hardware resources are abstracted by software, and finally called
Method used: using hypervisor (VMM) software, the principle is to establish an abstraction layer between the underlying hardware and the server, while the core-based virtual machine is an open source product for Linux systems, hypervisor (VMM) can capture CPU instructions and act as an intermediary for instructions to access hardware controllers and peripherals.
2) paravirtualization: the operating system needs to be modified
3) cut-through: direct use of physical hardware resources (need support, not perfect)
5. The characteristics of virtualization:
Advantages:
Centralized management (remote management, maintenance)
Improved hardware utilization (low physical resource utilization-for example, peak, virtualization solves "idle" capacity)
Dynamically adjust the machine / resource configuration (virtualization separates the application and service hardware of the system and improves flexibility)
High reliability (additional features and solutions can be deployed to improve application environments such as transparent load balancing, migration, replication, etc.)
Disadvantages:
High upfront cost (initial hardware support)
Reduce hardware utilization (specific scenarios-such as applications that eat too much resources may not be suitable for virtualization)
Larger error impact area (local physical machine down causes virtual machines to be unavailable and all files in the virtual machines may be corrupted)
Complex configuration and management (difficulties in operation and maintenance of managers and troubleshooting)
Certain limitations (virtualization technology involves various restrictions and must be used in conjunction with servers, applications, and vendors that support / compatible virtualization)
Security (security risks of virtualization technology itself)
II. Overview of KVM 1. Introduction to KVM
KVM is an open source Linux native full virtualization solution based on X86 hardware of virtualization extensions (Intel VT or AMD-V). In KVM, the virtual machine is implemented as a regular Linux process, which is scheduled by the standard Linux scheduler, and each virtual CPU of the virtual machine is implemented as a regular Linux thread. This allows KMV to use the existing features of the Linux kernel.
The abbreviation of Kernel-based Virtual Machine, an open source system virtualization module, is the latest virtualization technology introduced by RHEL 5.4. at present, Red Hat only supports running KVM above 64-bit RHEL L5.4, while the hardware needs to support VT technology, so KVM must be used in 64-bit bit environment. It has been integrated in major releases of Linux since Linux 2.6.20. It is managed by Linux's own scheduler, so its core source code is relatively small compared to Xen. KVM has become one of the mainstream VMM in academic circles.
KVM virtualization requires hardware support (such as Intel VT technology or AMD V technology). Is full virtualization based on hardware. In the early days, Xen was based on software simulation of Para-Virtualization, while the new version was based on full virtualization supported by hardware. But Xen itself has its own process scheduler, storage management module and so on, so the code is relatively large. The widely spread business system virtualization software VMware ESX series is based on software simulation of Full-Virtualization.
You can check whether the system supports VT with the following command
Cat / proc/cpuinfo | grep 'vmx'
KVM, formerly known as QEMU, was acquired by Red Hat in 2008 and acquired a technology hypervisor, but RedHat's KVM is considered to be the mainstream of Linux hypervisor in the future.
2. The function of KVM
Improve resource utilization of physical servers (less investment in hardware)
Can be deployed in batches
Implementation of real-time snapshot technology
Support for cloning technology
Enables offline and dynamic migration of virtual machines (improving the flexibility of IT deployment)
Resources can be adjusted dynamically (traditional IT architecture resources are fixed and cannot be dynamically allocated)
3. KVM Virtualization Architecture / three modes
Customer mode (guestOS): OS in VM is GuestOS
The mode in which the client runs in the operating system. The client is divided into user mode and Linux kernel mode, and the functions are as follows:
User mode:
To provide users with user space tools for virtual machine management and to perform Qemu Qemu work on behalf of users in this mode (main functions of VMs)
Linux kernel mode:
Simulate CPU, memory, switch client mode, deal with the introduction of client mode, and KVM runs in this mode
4. Core components and functions of KVM
Guest: client systems, including CPU (vCPU), memory, drivers (Console, network card, Imax O device driver, etc.), are run in a restricted CPU mode by KVM.
KVM: runs in kernel space, providing virtual levels of CPU and memory, as well as the client's Imax O interception. After being intercepted by KVM, the Guest's Icano is handed over to QEMU for processing.
QEMU: modified QEMU code for use in KVM virtual machines, running in user space, providing hardware I dev/kvm O virtualization, and interaction with KVM through IOCTL / dev/kvm devices.
5. KVM workflow
Qemu in user mode enters kernel mode through ioctl system calls using the interface libkvm. The KVM driver creates virtual CPU and virtual memory for the virtual machine, then executes the VMLAU NCH instruction to enter client mode, loads Guest OS, and runs. If an exception occurs during the operation of Guest OS, the operation of Guest OS is paused and the current state is saved while exiting to kernel mode to handle these exceptions.
When handling these exceptions in kernel mode, if you do not need IZP O, you will return to client mode after the processing is complete. If you need to enter the user mode, then Qemu will handle it. After the processing, enter the kernel mode and then enter the client mode.
6. Advantages of KVM
1) advantages of KVM and VMware
The bottom layer of ESX is VMkernel + linux,VMkernel starts to take over the hardware management, and then starts the first linux virtual machine to assist VMkernel to manage and schedule hardware resources.
KVM directly turns linux kernel into hypervisor, which only needs to be booted from the standard linux kernel, and all the features that linux kernel has can be utilized. KVM's architectural advantages make it so concise that it has been incorporated into the standard kernel in just over three months of development.
2) the advantages of KVM and Xen
The biggest difference between Kvm and xen is the architecture. KVM is built directly on linux kernel, turning linux kernel into hypervisor, which is based on the existing functions of kernel. KVM does not have the function.
Xen's hypervisor is built from scratch, the scheduling management of hardware resources, the management of virtual machines, and many interfaces are not compatible with linux kernel, and then for xen,hypervisor, it is necessary to provide hardware access driver support to virtual machines through Domain0.
Although xen is now incorporated into the 3.0 kernel, most linux OS kernels are 2.6, and even some new distributions of OS still have 2.6 kernels, and the new kernels need to be upgraded separately.
Deployment of KVM Virtualization platform 1. Virtual machine resources
CPU: dual Core and dual Thread-CPU Virtualization enabled
Memory: 8GB
Hard disk: 300g
Dual network card: single network card
Operating system: Centos 7.4 (1708)
2. Experimental environment
1) modify the hostname
[root@kvm ~] # hostnamectl set-hostname kvm [root@kvm ~] # bash
2) set the mirrored CD to auto / permanent mount
[root@kvm ~] # vim / etc/fstab/dev/cdrom / mnt iso9660 defaults 00 [root@kvm ~] # mount-a [root@kvm ~] # df-hT/dev/sr0 iso9660 4.3G 4.3G 0 100% / mnt
3) Environmental optimization
# whether to decode DNS. Setting it to NO allows the client to connect to the server faster.
[root@kvm ~] # vim / etc/ssh/sshd_config UseDNS no # uncomment DNS and change it to NO
4) make local YUM warehouse
[root@kvm ~] # mkdir / abc [root@kvm ~] # cd / etc/yum.repos.d/ [root@kvm yum.repos.d] # lsCentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repoCentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo [root@kvm yum.repos.d] # mkdir bak [root@kvm yum.repos.d] # mv CentOS-* bak [root@kvm yum.repos.d] # lsbak [root@kvm yum.repos .d] # vim local.repo [local] name=kvmbaseurl= file:///abcgpgcheck=0enabled=1[root@kvm yum.repos.d] # yum clean all [root@kvm yum.repos.d] # yum repolist
5) turn off firewall and core protection
[root@kvm yum.repos.d] # systemctl stop firewalld [root@kvm yum.repos.d] # systemctl disable firewalldRemoved symlink / etc/systemd/system/multi-user.target.wants/firewalld.service.Removed symlink / etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@kvm yum.repos.d] # setenforce 03, install KVM
1) install the basic components of KVM
# install GNOME desktop environment if you install graphical interface, you don't need to install yum groupinstall-y "GNOME Desktop" # KVM module yum-y install qemu-kvm# install KVM debugging tool, but do not install yum-y install qemu-kvm-tools# command line tool yum-y install virt-install# qemu component to build virtual machine Yum-y install qemu-img# network support tools such as creating disks and starting virtual machines yum-y install bridge-utils# virtual machine management tools yum-y install libvirt# graphical interface management virtual machine yum-y install virt-manager
2) check whether CPU supports virtualization
[root@kvm ~] # cat / proc/cpuinfo | grep vmx flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid mpx rdseed adx smap Clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilitie
3) check whether the KVM module is installed
Lsmod: displays loaded system modules
[root@kvm ~] # lsmod | grep kvmkvm_intel 183621 0 kvm 586948 1 kvm_intelirqbypass 13503 1 kvm
4) set the display mode that opens the startup interface
[root@kvm ~] # ln-sf / lib/systemd/system/graphical.target / etc/systemd/system/default.target4, set KVM network
1) two modes of KVM network:
① NAT: default setting, packets are carried out by NAT through the interface of the host
Transport, can access the external network, but cannot access the virtual machine network from the outside
* * ② bridge: * * this mode allows a virtual machine to have a network like an independent host. External machines can directly access the inside of the virtual machine, but it needs to be supported by a network card (generally supported by wired network cards)
Deploy using Bridge bridge mode
[root@bdqn ~] # vim / etc/sysconfig/network-scripts/ifcfg-ens33TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noBOOTPROTO=noneDEFROUTE=yesIPV4_FAILURE_FATAL=noIPV6INIT=noIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=ens33UUID=aac61931-47a6-40e5-9511-68adf20e97c5DEVICE=ens33ONBOOT=yes#IPADDR=192.168.100.46#PREFIX=24#GATEWAY=192.168.100.1BRIDGE=br0 # Delete the previous address, set it to bridge mode, and associate the br0 network card
2) create and edit bridge network card
[root@bdqn ~] # vim / etc/sysconfig/network-scripts/ifcfg-br0TYPE=BridgeBOOTPROTO=staticDEFROUTE=yesPEERDNS=yesPEERROUTES=yesIPV4_FAILURE_FATAL=noIPV6INIT=yesIPV6_AUTOCONF=yesIPV6_DEFROUTE=yesIPV6_PEERDNS=yesIPV6_PEERROUTES=yesIPV6_FAILURE_FATAL=noIPV6_ADDR_GEN_MODE=stable-privacyNAME=br0DEVICE=br0ONBOOT=yesIPADDR=192.168.226.200NETMASK=255.255.255.0GATEWAY=192.168.226.25, KVM deployment and Management
1) create a directory where KVM stores and mirror data, and upload centos7 images
[root@kvm network-scripts] # mkdir-p / data_kvm/ iso[ root @ kvm network-scripts] # mkdir-p / data/_kvm/ store [root @ kvm network-scripts] # mkdir / abc [root@kvm network-scripts] # mount.cifs / / 192.168.226.1/LAMP-C7 / mntPassword for root@//192.168.226.1/LAMP-C7: [root@kvm network-scripts] # cd / abc [root@kvm abc] # cp-p CentOS-7- X86_64-DVD-1806.iso / data_kvm/iso/# View Image [root@kvm abc] # ll / data_kvm/iso/ Total usage 4481024-rwxr-xr-x. 1 root root 4588568576 February 20 2019 CentOS-7-x86_64-DVD-1810.iso
2) use Virtual system Manager to manage virtual machines
[root@kvm kvmdata] # virt-manager
3) Operation steps
Step 1 of ①: create a storage pool
The same operation creates an iso storage pool
② creates storage volumes in the store storage pool
③ creates a virtual machine
Enable minimized installation to save space
The above is all the content of this article "what's the use of KVM?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.