Create a virtual machine through KVM under Centos7

Create a virtual machine through KVM under Centos7
Note: This Centos7 is also a virtual machine, created by VMware, and the weapon has virtualization support:
Insert picture description here

1. Install KVM:
centos7 environment yum install qemu virt kvm -y to
start the service: systemctl start libvirtd

2. Create a virtual machine through a graphical interface.
Execute virt-manager. The graphical interface reports an error:
Failed to probe QEMU binary with QMP: /usr/libexec/qemu-kvm: symbol lookup error: /usr/libexec/qemu-kvm: undefined symbol: epoxy_eglExportDMABUFImageQueryMESA

Solution: add yum install libepoxy -y

Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here

Insert picture description here

Insert picture description here
Insert picture description here

If there is no response when clicking, and it is stuck, please execute virt-manager -debug to view the log while creating it. It is found that the KVM has an abnormal GDK graphical interface:

DEBUG (cli:257) Uncaught exception:

Traceback (most recent call last):

File “/usr/share/virt-manager/virtManager/createnet.py”, line 830, in finish

self.set_finish_cursor()

File “/usr/share/virt-manager/virtManager/baseclass.py”, line 272, in set_finish_cursor

cursor = Gdk.Cursor.new_from_name(gdk_window.get_display(), “progress”)

TypeError: constructor returned NULL

Need to edit /usr/share/virt-manager/virtManager/baseclass.py to comment out the line involving Gdk.Cursor.new_from_name

#cursor = Gdk.Cursor.new_from_name(gdk_window.get_display(), “progress”)

#gdk_window.set_cursor(cursor)

#cursor = Gdk.Cursor.new_from_name(gdk_window.get_display(), “default”)

#gdk_window.set_cursor(cursor)

Also edit /usr/share/virt-manager/virtManager/asyncjob.py to comment out the line involving Gdk.Cursor.new_from_name:

#gdk_window.set_cursor(

Gdk.Cursor.new_from_name(gdk_window.get_display(), “progress”))**

Reference: https://blog.csdn.net/weixin_40762393/article/details/106406441
https://bbs.huaweicloud.com/forum/forum.php?mod=viewthread&tid=49136

Re-clock the graphical interface to continue to:
Insert picture description here

After the client is installed, you need to set up a network interface for it to communicate with the host network and the network between the client. In fact, if you want to use network communication during installation, you need to set up the client's network connection in advance.

There are two ways of kvm client network connection:

User Networking: NAT is a simple way for virtual machines to access resources on the host, the Internet, or the local network, but they cannot be accessed from the network or other clients, and performance needs major adjustments.
Virtual Bridge: Bridge mode, this mode is more complicated than the user network, but the communication between the client and the host is very easy to set up the client and the Internet.

Bridge mode principle:
Bridge mode is the network connection mode of virtual bridge, which is that the client and the machines in the subnet can communicate with each other. You can make a virtual machine a host with a separate IP in the network.

Bridged network (also called physical device sharing) is used to copy a physical device to a virtual machine. The bridge is mostly used for advanced settings, especially when the host has multiple network interfaces.

The scope of application of the Bridge method: server host virtualization.

Because of the graphical interface to install the card, finally use the command line to install:
virt-install --name=centos7kvm02 --memory=2048,maxmemory=2048 --vcpus=1,maxvcpus=2 --os-type=linux --location =/var/lib/docker/CentOS-7-x86_64-DVD-1611.iso --disk path=/kvm_data/centos7kvm02.qcow2,size=8 --graphics=none --console=pty,target_type=serial - extra-args="console=tty0 console=ttyS0" After
Insert picture description here
starting the installation, under normal circumstances, you will enter such an interface:
Insert picture description here
This is for us to configure language, time zone, installation source, network, password and other information, just like us in VMware Installing the CentOS virtual machine is the same, except that this is a command line form, while VMware is a graphical interface:

First set the language, press number 1, and press Enter to enter the following interface:
For example, if I want to select Chinese, press number 68 and press Enter. After pressing enter, you will be asked to choose Chinese simplified or traditional, and press the corresponding number and press enter. Car: After the
Insert picture description here
Insert picture description here
configuration is completed, it will return to the configuration interface again. This time we will set the time zone:
Insert picture description here
Insert picture description here
Insert picture description here
set the system installation disk:
Insert picture description here
Insert picture description here

Press the C key to continue other settings. The operation steps are similar. The process of setting the root password, network, and user is omitted here, and finally press the B key to start the installation:
Insert picture description here
finally the installation is complete, enter the root password to directly enter the created virtual machine:
Insert picture description here

If you find that you cannot access the external network, check the network card with ip a and find that the network card does not obtain an IP address. You can restart the network card to obtain the IP address through DHCP. Generally, it can be solved:
Insert picture description here
either dhclient ifcfg-ens2 or service network start can be tried.

The virtual machine network mode created by default is NAT mode. You can view the mapping relationship between the vnet0 virtual network device and the virtual machine's network card:
NAT network model:
Insert picture description here

Host virtual network device:
Insert picture description here
brctl show:
Insert picture description here

Virtual machine network card information:
Insert picture description here
view the virtual machine configuration file: virsh dumpxml centos7kvm02Insert picture description here

Guess you like

Origin blog.csdn.net/yangyi_CSDN/article/details/108804422