Only use VMware to turn on virtual machine? Let's take a look at the more powerful KVM virtualization technology
Old demon 2021-02-23 03:34:29

Please pay attention to this headline , Keep updating original dry goods technical articles every day .

To learn video , Please search the official account at WeChat. “ Zhichuan.com ” Go straight to self-help video learning

1. Preface

This article explains KVM The advantages of virtualization and how to Ubuntu 20.04 Installation on system KVM Virtualization Suite .

Let's get to know KVM Virtualization technology :

Here's a quote from red hat's website :

1.1 KVM What is it? ?


KVM It's a kernel based virtual machine Kernel-based Virtual Machine(KVM) It's built-in Linux? Open source virtualization technology in . To be specific ,KVM Can help you to Linux Turn it into a hypervisor , Enables host computers to run multiple isolated virtual environments , Virtual client or virtual machine (VM).

KVM yes Linux Part of .Linux 2.6.20 Or newer versions include KVM.KVM On 2006 First published in , And merge into the mainstream one year later Linux In kernel version . because KVM Belong to the existing Linux Code , So it can immediately enjoy every new Linux function 、 Restoration and development , No additional work is required .

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Ubuntu 20.04 How to install and create KVM virtual machine


1.2 Linux KVM What are the advantages of virtualization ?


Security : KVM Take advantage of security enhanced Linux(SELinux) And security virtualization (sVirt) Combination to enhance the security and isolation of virtual machine .SELinux Establishing security boundaries around virtual machines .sVirt Then expand SELinux The function of , Make mandatory access control (MAC) The security mechanism is applied to the client virtual machine , And prevent manual tagging errors .

Storage :KVM Able to use Linux Any storage supported , Including some local disks and network attached storage (NAS). You can also take advantage of multipathing I/O To enhance storage and provide redundancy .KVM It also supports shared file systems , Therefore, the virtual machine image can be shared by multiple hosts . Disk mirroring supports thin provisioning , Storage can be allocated on demand , There's no need to prepare everything in advance .

Hardware support :KVM You can use a variety of Authentication Linux Compatible hardware platform . Because hardware vendors often help kernel development , therefore Linux The kernel is usually able to quickly adopt the latest hardware features .

memory management :KVM Inherited Linux Memory management function of , Including non-uniform memory access and kernel page merging . The memory of the virtual machine can be exchanged , You can also improve performance by supporting large volumes , It can also be shared or supported by disk files .

Live migration :KVM Supports live migration , That is, the ability to move running virtual machines between physical hosts , Without service disruption . The virtual machine remains on , Network connections stay active , Each application will also run normally during the relocation of the virtual machine .KVM It also saves the current state of the virtual machine , So it can be stored for future recovery .

Performance and scalability :KVM Inherited Linux Performance of , Scale for the growth of clients and requests , Meet the needs of the load .KVM Virtualize the most demanding application workloads , And that's the foundation of many enterprise virtualization settings , Such as data center and private cloud ( adopt OpenStack?).

Scheduling and resource control : stay KVM In the model , Virtual machine is a kind of Linux process , It's scheduled and managed by the kernel . adopt Linux The scheduler , Can be assigned to Linux Fine control of process resources , And guarantee the service quality of specific process . stay KVM in , This includes a completely fair scheduler 、 Control group 、 Network namespace and real time extension .

Lower latency , Higher priority : Linux The kernel provides real-time extensions , Allow virtual machine based applications with lower latency 、 Higher priority to run ( Relative to bare metal recovery ). The kernel also divides processes that require long-time computation into smaller components , And then the corresponding scheduling and processing .

To understand the KVM The characteristics and advantages of , We started at Linux Installation on system KVM Suite and try to start a virtual machine .

2. Check the hardware condition of our own server first

2.1 Check CPU Is virtualization supported

Let's check this machine first CPU Whether virtualization can be supported .

grep -Eoc '(vmx|svm)' /proc/cpuinfo

Output results

96

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Ubuntu 20.04 Check CPU Is virtualization supported


My output shows that , It was matched 96 Time . Why 96 And then ? Because every one of my servers CPU All with virtualization , common 96 individual CPU, Every CPU All match once . So executing this command on each machine may be different . As long as the output is greater than 0 It means that your CPU Support virtualization .

notes :Linux On the system CPU Quantity and CPU The same number of threads , That is, one thread counts one CPU

2.2 Check if virtualization is on on the motherboard

CPU Support virtualization can be used normally KVM Has the acceleration function been activated ? Not necessarily , We also need to be on the motherboard BIOS Turn on virtualization on the Internet .

Use the following instructions to check KVM Whether acceleration is available .

Install the inspection tool first :

Ubuntu The system executes the following command :

sudo apt update && sudo apt install cpu-checker -y

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Ubuntu 20.04 install KVM Accelerated testing kit


The author is in CentOS Find... On the system kvm-ok Command the corresponding software package , Be prompted to all EPEL The warehouse removed the software package corresponding to the command .

lookup kvm-ok The package corresponding to the command

yum provides kvm-ok

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

lookup kvm-ok The package corresponding to the command


Output results :

https://centos.anexia.at/epel/7/x86_64/repodata/83cce7d719a366a5ebc50fd9a1ff70f575d9df83a6994f948f582850213897f7-filelists.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found

Prompt file not found .

Ubuntu After installation , Execute the following command :

kvm-ok

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Ubuntu 20.04 testing KVM Whether virtualization acceleration is enabled


The output on my server is as follows :

INFO: /dev/kvm existsKVM acceleration can be used

indicate kvm Acceleration is available .

3. install KVM Virtualization Suite

confirm CPU And motherboard can support after . Next install kvm Virtualization Suite :

Ubuntu System :

sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst virt-manager -y

qemu-kvm: Provide hardware underlying virtualization .
libvirt-daemon-system: by libvirt Running as a daemons for system services .
libvirt-clients: Provide long-term stable service for different virtual machines C API
bridge-utils: Provide network bridging function
virtinst: by libvirt Creating a virtual machine provides a series of command line work
virt-manager: KVM Virtual machine management GUI , If the server does not have a graphical interface installed , There's no need to install it .

Check libvirtd Is it running :

sudo systemctl is-active libvirtd

Output results :

active

Indicates that my server is running libvirtd

Want to create and manage virtual machines , You need to add your users to libvirt and kvm User group . Input :

sudo usermod -aG libvirt $USERsudo usermod -aG kvm $USER

If you don't add users to a group , Then add... Before each command sudo Get higher permissions .

4. View the virtual network

View the virtual bridge , You can understand it as a virtual switch with multiple interfaces :

brctl show

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

View the virtual network


My server outputs :

The bridge is used to provide virtual machines with the ability to connect to physical networks , That is, virtual machines can access other machines , Other machines can also access it directly .

But this article does not discuss it , Because I'm just going to show you NAT Pattern .

5. establish KVM virtual machine

Get the operating system ready first ISO Image file :
I'm ready CentOS 7.8 Installation image of , Its position is :

/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-2003.iso

First, plan the parameters of the virtual machine :

  • name :centos7_2003
  • Memory :4096M
  • CPU:2
  • type :linux
  • Template :centos7.0
  • Virtual display :VNC, Define password , Define the port number 5911
  • Network mode :NAT
  • Virtual disk file :/var/lib/libvirt/images/CentOS7.qcow2
  • ISO Install the image : /var/lib/libvirt/images/CentOS-7-x86_64-Minimal-2003.iso

Command line creation :

sudo virt-install  --name=centos7_2003  --ram=4096  --vcpus=2 --virt-type=kvm --os-type=linux --os-variant=centos7.0  --network default,model=virtio --graphics=vnc,password=linuxrumen.com,port=5911,listen=0.0.0.0 --noautoconsole  --accelerate  --cdrom=/var/lib/libvirt/images/CentOS-7-x86_64-Minimal-2003.iso --disk path=/var/lib/libvirt/images/CentOS7.qcow2,device=disk,format=qcow2,bus=virtio,cache=writeback,size=40

 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

stay Ubuntu 20.04 To create a KVM virtual machine


The output of the following result indicates that the creation is successful :

 Start installation ...... Allocating  'CentOS7.qcow2'                                                                                                                  |  40 GB  00:00:00      Domain installation is still in progress . You can reconnect to the console to complete the installation process .

Of course , You can also visit Linux Using graphical interface in desktop environment virt-manager Create it .

6. Connect KVM Virtual machine display

stay Windows Installation on system VNC viewer client :
Connect the display of the newly created virtual machine :

VNC Server address :

IP+ port

such as 192.168.20.35:5911

stay VNC viewer client :

Add a VNC host :


 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Connect KVM Virtual machine display


Input create KVM The password configured for the virtual machine :


 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Input KVM Virtual machine display password



 Only VMware Turn on virtual machine ? To learn about the more powerful KVM Virtualization technology

Successfully connected to KVM virtual machine


7. Conclusion :

This article mainly demonstrates how to use Ubuntu 20.04 Installation on system KVM And use KVM Basic function .Linux KVM Virtualization platform is very worthy of in-depth study and learning . It can provide stable and high performance virtualization technology . Maintenance is better than Exsi Simple . The command line suite can cover all the functions . I usually use the command line to create , One SSH The terminal window can do everything . If you have a cool usage . Please leave a message .

This article has been synchronized to the blog site , Respect for the original , Please attach the following link to the text when reprinting :
https://www.linuxrumen.com/rmxx/1866.html

Click to learn more , Quick view more technical article lists .

版权声明
本文为[Old demon]所创,转载请带上原文链接,感谢
https://fheadline.com/2021/02/20210223032018622k.html
相似文章

2021-08-09