KVM virtual machine platform

Build KVM server:
components: KVM / QEMU / LIBVIRTD
KVM is a module of Linux kernel, it needs CPU support, adopts hardware-assisted virtualization technology Intel-VT, AMD-V, memory related such as Intel EPT and AMD RVI ;
QEMU is a virtualized simulation tool, through ioctl interacts with the kernel kvm to complete the hardware virtualization support;
Libvirt is an interface and tool for virtualization management, providing user-side programs virsh, virt-install, virt-manager, virt-view interacts with the user.
Software package: qemu-kvm, libvirt-daemon, libvirt-client, libvirt-daemon-driver-qemu
Optional functions: virt-install system installation tool, virt-manager graphics management tool, virt-v2v virtual machine migration tool, virt- P2v physical machine migration tool
daemon: libvirtd

The composition of the virtual machine: -Kernel
virtualization module (KVM) -System
equipment emulation (QEMU)
-Virtual machine management program (LIBVIRT)
XML virtual machine configuration file: / etc / libvirt / qemu /
disk image file (virtual machine hard disk) : / Var / lib / libvirt / images /

The virsh tool, which can be interactive, provides a command interface for managing each virtual machine. Format: virsh control command [virtual machine name] [parameters]
View KVM nodes: virsh nodeinfo
lists virtual machines: virsh list [--all]
lists virtual networks : Virsh net-list [--all]
View the specified virtual machine: virsh dominfo virtual machine name
run | restart | shut down the specified virtual machine: virsh start | reboot | shutdown The virtual machine name
forces the specified virtual machine to shut down: virsh destroy virtual machine The name
sets the specified virtual machine to auto-startup: virsh autostart virtual machine name

KVM virtual machine disk image QCOW2 format supports compression, back-end disk multiplexing, and snapshots.
qemu-img tool is a virtual machine's disk management commands support raw, qcow2, vdi, vmdk and other disk formats
qemu-img command format: qemu-img command parameters Block File Name Size
commonly used commands: create, convert, info, snapshot
to create a new Mirror disk file: qemu-img create -f disk format disk path size
using back-end disk template file: qemu-img create -b back-end disk path -f disk format disk path
COW technical principle

Connect to the local / remote KVM
using virsh to connect to the remote: virsh connect qemu + ssh: // user @ ip: port / system
Use virt-manager to connect and manage through add connection, but you need to use SSH to log in without password. If not, install python separately Ssh related modules

Create a virtual switch
libvirtd network interface, principle: call dnsmasq to provide DNS, DHCP and other functions to
create a configuration file: /etc/libvirt/qemu/networks/XXXX.xml
virsh management virtual network:
net-list
net-define / etc / libvirt / qemu /networks/XXXX.xml #Create virtual network
net-undefine virtual network file
net-start virtual network file
net-destroy virtual network file #stop virtual network
net-edit virtual network file
net-autostart virtual network file

xml virtual machine file management:
default file:
/etc/libvirt/qemu/...xml export: virsh dumpxml virtual machine name> virtual machine name.xml
adjust the configuration of the virtual machine: virsh edit virtual machine name
create a new virtual machine : Virsh define XML virtual machine file
delete virtual machine: virsh undefine virtual machine name


Customize the virtual machine template:
1. Create a virtual machine, configure the files and software you need
2. Save the virtual machine configuration file, open and delete the id attribute and uuid attribute
3. You can delete the <resource> resource configuration and <clock > Wait, mainly modified to meet the characteristics of their own needs

Offline access to virtual machines, using the guestmount tool, to facilitate the
basic usage of virtual machine customization and repair : guestmount -a virtual machine disk path -i mount point

Guess you like

Origin www.cnblogs.com/Haihong72H/p/12679236.html