KVM (Kernel-based Virtual Machine) is a virtualization technology based on the Linux kernel. It uses the Linux kernel as the underlying operating system of the virtual machine and uses hardware virtualization to support the creation and management of virtual machines. KVM virtualization technology is widely used in cloud computing, virtualized servers, virtualized desktops and other scenarios.
The main features of KVM virtualization technology include:
1. Hardware virtualization support: KVM virtualization technology uses hardware virtualization technology (such as Intel VT, AMD-V, etc.) to provide virtualization support, so that various operating systems can be run in virtual machines without the need to modify applications. Revise.
2. Superior performance: KVM virtualization technology uses hardware virtualization support. The performance of running applications in a virtual machine is almost the same as that of running on a physical machine, so it has very high performance.
3. Safe and reliable: KVM virtualization technology uses hardware virtualization support, and each virtual machine is independent, so it can provide higher security and reliability.
4. High flexibility: KVM virtualization technology supports multiple operating systems, can run multiple virtual machines on the same physical machine, thereby improving hardware utilization, and can create and delete virtual machines on demand, thus improving flexibility.
The working principle of KVM virtualization technology is to use the Linux kernel as the underlying operating system of the virtual machine, use hardware virtualization support to create virtual machines, and provide allocated virtual hardware resources for each virtual machine, including CPU, memory, disk and network, etc. . Each virtual machine can run its own operating system and applications and is isolated from other virtual machines. KVM virtualization technology uses QEMU (Quick Emulator) to provide virtual machine management functions, including virtual machine creation, startup, stop, and deletion operations.
Environment
Turn on AMD virtualization
Check whether it is supported
Support if there is output
[root@localhost ~]# egrep -o ‘vmx|svm’ /proc/cpuinfo
svm
svm
svm
svm
Turn off the firewall
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri ‘s/^(SELINUX=).*/\1disabled/g’ /etc/selinux/config
Download the required software packages
[root@centos32 ~]# yum -y install qemu-kvm qemu-kvm-tools virt-install qemu-img bridge-utils libvirt virt-manager
Adjust the network card configuration file
[root@centos32 ~]# cd /etc/sysconfig/network-scripts/
[root@centos32 network-scripts]# cp ifcfg-ens32 ifcfg-br0
[root@centos32 network-scripts]# vim ifcfg-br0
[root@localhost ggggS]# cat /etc/sysconfig/network-scripts/ifcfg-ens33 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 DEVICE=ens33 ONBOOT=yes BRIDGE=br0 [root@localhost ggggS]# cat /etc/sysconfig/network-scripts/ifcfg-br0 TYPE=Bridge PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=br0 DEVICE=br0 ONBOOT=yes IPADDR=192.168.50.66 NETMASK=255.255.255.0
GUI installation
Enter the command to enter virt-manager
any name
Set up a path
Prepare image
[root@localhost ~]# cd /vfasffaf/ggggS/ Enter the directory and drag the image into it
Prepare to generate a virtual machine
Select path
Set up memory
You don’t have to do it
Start in the upper left corner
Complete page
View virtual machine
[root@localhost ~]# virsh list –all
Id Name Status
————————————————– —
1ubuntu14.04 running
Shut down the virtual machine
[root@localhost ~]# virsh shutdown ubuntu14.04
Domain ubuntu14.04 is shut down
[root@localhost ~]# virsh list –all
Id Name Status
————————————————– —
1ubuntu14.04 running
Start the virtual machine
[root@localhost ~]# virsh start ubuntu14.04
Force shutdown
[root@localhost ~]# virsh destroy ubuntu14.04
Domain ubuntu14.04 was deleted
[root@localhost ~]# virsh list –all
Id Name Status
————————————————– —
– ubuntu14.04 closed
[root@localhost ~]# virsh start ubuntu14.04
Domain ubuntu14.04 started
Resume a suspended virtual machine
[root@localhost ~]# virsh resume ubuntu14.04
Suspend virtual machine
[root@localhost ~]# virsh suspend ubuntu14.04
Domain ubuntu14.04 is hung
Resume a suspended virtual machine
[root@localhost ~]# virsh resume ubuntu14.04
Domain ubuntu14.04 is restored
Set the virtual machine to automatically start at the same time as the physical machine
[root@localhost ~]# virsh autostart ubuntu14.04
Domain ubuntu14.04 marked for autostart
Back up the virtual machine configuration file and back up the virtual machine to the root directory
[root@localhost ~]# virsh dumpxml ubuntu14.04 > /ubuntu14.04
[root@localhost ~]# ll /ubuntu14.04
-rw-r–r– 1 root root 5322 August 30 14:28 /ubuntu14.04
Deleting a virtual machine and restoring a backup virtual machine
[root@localhost ~]# virsh undefine ubuntu14.04
Domain ubuntu14.04 has been undefined
[root@localhost ~]# virsh create ubuntu14.04
Clones and snapshots of virtual machines
1) Clone the virtual machine, clone Centos to the specified virtual machine disk file type
[root@localhost ~]# virt-clone -o ubuntu14.04 -n ubuntu14.04 -f /virtual/KVM /ubuntu14.04
usage: virt-clone –original [NAME] …
2) virt-clone: error: unrecognized arguments: /ubuntu14.04
Create a snapshot of a virtual machine
[root@localhost ~]# virsh snapshot-create ubuntu14.04
3) Restore user-created snapshots
[root@localhost ~]# virsh snapshot-revert ubuntu14.041574074089
4) View snapshot
[root@localhost ~]# virsh snapshot-list ubuntu14.04
5) Delete the snapshot created by the virtual machine
[root@localhost ~]# virsh snapshot-delete ubuntu14.04 1574074089
6) Modify the name of the snapshot created by the virtual machine
[root@localhost ~]# virsh snapshot-edit ubuntu14.04
–snapshotname 1574074089 –rename