Under Linux kvm virtualization deployment

lab environment

Redhat Enterprise 8 real host: kvm higher hardware requirements for the host, try to do the experiment in real linux machine
on this host structures yum source , you can install the software;
on the host set up a DHCP server , virtual machine is allocated to the new IP ;
on the host configuration vsftpd service for shared image resource
for the kvm interface to configure the network bridge
①: write ifcfg-br0, ifcfg-ens160 file separately
Here Insert Picture Description
Here Insert Picture Description
②: restart the network, view the device connections, view IP, network configuration was successful
Here Insert Picture Description
Here Insert Picture Description

1. kvm installation

1.1 Installation conditions

  • inter cpu support function vmx
  • amd cpu support function svm

1.2 Installation

Package Explanation
Virtualization Client Client virtualization
Virtualization Tools Virtualization tools
Virtualization Hypervisor Virtualization core suite

Three or more mounting assembly
Here Insert Picture Description

2. virtualization-related information

  • Service Name: libvirtd
  • Virtualization Core: qemu / kvm
  • Virtualized storage directory (virtual hard disk): / var / lib / libvirt / images / xxxx.qcow2
  • Virtualized hardware information: /etc/libvirt/qemu/xxxx.xml

3. Manually install the virtual machine

3.1, install the virtual machine local resources
①: Open the Virtual Machine Manager:virt-manager
Here Insert Picture Description

②: new virtual machine, select the local installation
Here Insert Picture Description
②: a virtual machine configured to set: the graphics virtual machine is mounted, minimum 768MB memory, a hard disk 6GB minimum size, selecting a network connection bridge mode
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
③: the virtual machine is created, can be information on the hardware adjustment, generally choose the default, click begin install, start installing virtual machine
Here Insert Picture Description
Here Insert Picture Description
④: virtual machine can be installed into the system interface, our installation instructions set no problem, you can install the system properly
Here Insert Picture Description
3.2, install the virtual machine network resources
①: Before doing the experiment network installation, make sure you can access through the browser to the mirror system resources, and DHCP service turned
Here Insert Picture Description
②: create a new virtual machine, select Network Installation
Here Insert Picture Description
③: Fill system image path, setting hardware information
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
④: Click to begin installation, start install virtual machine
Here Insert Picture Description
⑤: virtual machine can be installed into the page, the system can be normal to start the installation
Here Insert Picture Description

4. Virtual Machine Manager command

command Explanation
virt-viewer virtest Virtual machine display virtest
virt-manager Open Virtual Machine Controller
virsh list Column running virtual machines
virsh list --all Lists all the virtual machines
virsh start virtest Open virtest virtual machine
virsh shutdow virtest Normally closed virtest virtual machine
virsh destory virtest Virtual machine off virtest
virsh define virtest.xml Restore virtual machine hardware information file
virsh create virtest.xml Open the virtual machine hardware information file
virsh undefine virtset To delete a virtual machine hardware information

Example:Here Insert Picture Description
Here Insert Picture Description

5. Virtual machine snapshots

  • A snapshot is a timely copy virtual machine disk files at some point. System crash or system anomalies, you can revert to the snapshot file system and to keep the disk storage system by using.
  • The difference between snapshots and clones: Snapshots can not be run independently from the original virtual machine, cloning is part from the original virtual machine, full clones are completely divorced from the original virtual machine.
  • Create a virtual machine snapshot: Example: virtest-1.qcow2 to the original virtual machine image file, node1.qcow2 the snapshot file
qemu-img create -f qcow2 -b /var/lib/libvirt/images/virtest-1.qcow2  /var/lib/libvirt/images/node1.qcow2

Here Insert Picture Description

6. virtual machine snapshot script

We will create a snapshot of command and command to import a snapshot of the virtual machine installation script is written, you need to install a new virtual machine, you can execute the script
①: vir_test.sh write a script, file extension must besh
Here Insert Picture Description
②:&1When a script executes, said character input, where as a virtual machine snapshot name and file name
Here Insert Picture Description
③: save and exit the script file, perform the installation snapshot script (node2 is the name of a custom virtual machine), you can see the virtual machine page, node2 virtual installation success
Here Insert Picture Description

Published 23 original articles · won praise 25 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_42006358/article/details/104658307