[Virtualization] libvirt, KVM, storage pool, storage volume

Reference:
1. Virtual machine disk and qemu-img, storage pool, storage volume - Author: IDYS • Marshal

1. libvirt

1.1 Definition

It is currently the most widely used KVM-virtual machine management tool

1.2 Composition:

  1. API library
  2. daemon (libvirtd)
  3. command line tool ( virsh)

1.3 Main Support Functions

  1. Virtual Machine Management : Includes different domain lifecycle operations. Such as: start, stop, pause, save, resume and migrate. Supports hot-swapping of various device types, such as disks, network cards, memory, and CPUs.
  2. Remote machine support : As long as the libvirt daemon is running on the machine, including remote machines, all libvirt functions can be accessed and used. Support multiple network remote transmission, use the simplest SSH.
  3. Storage management : Any host running libvirt daemon can be used to manage different types of storage: create file images of different formats (qcow2, vmdk, raw, etc.), mount NFS shares, list existing LVM volume groups, create new LVM volume groups and logical volumes, partition unprocessed disk devices, mount iSCSI shares, etc.
  4. Network interface management : Any host running libvirt daemon can be used to manage physical and logical network interfaces.
  5. Virtual NAT and route-based networking : Any host running the libvirt daemon can be used to manage and create virtual networks.

1.4 use of virsh

Operations on virtual machines

virsh list --all #查看创建的所有虚拟机
virsh start VM_Name  # 启动名称为 VM_Name 的虚拟机
virsh suspend VM_Name	#挂起虚拟机
virsh shutdown VM_Name	#关闭虚拟机
virsh destroy VM_Name	# 强制关闭虚拟机
virsh reboot VM_Name	#重启虚拟机
virsh reset VM_Name	#强制重启虚拟机

2. KVM

About KVM -

2.1KVM storage mode

  • file system based storage
  • device-based storage
  • 存储池Simplify storage management with

2.2 Virtual disk type

  • Fixed:
    When configuring, specify the disk size
    . No matter how much data is actually stored on the virtual disk, it will occupy the same size of host disk space.

  • Dynamic: grow to maximum capacity, but only use more space as needed

  • Diff
    Because the creation is a differencing disk, only the changed data is saved.
    For example: install the operating system on the recovery disk, and then create a differencing disk to perform further configuration

2.3 Disk types supported by KVM

  • raw
  • cow
  • qcow
  • qcow2
  • vmdk
  • vhd \ vhdx
  • vdi

4. Storage pool

  • libvirt can 存储池manage storage in a unified manner and simplify operations in the form of
  • Storage pools and volumes are not required
  • The following storage pools are supported
dir - Filesystem Directory
disk  - Physical Disk Device
fs - Pre-Formatted Block Device
gluster - Gluster Filesystem
iscsi - iSCSI Target
logical
mpath
netfs
rbd
scsi
sheepdog

4.1 Configuration file

/etc/libvirt/storage/	#存储 存储池 的配置文件~们

4.2 Directory-based storage pool

  1. Prepare directory: set directory permissions

Operations on storage pools

virsh pool-list pool_name
virsh pool-info pool_name
virsh pool-autostart pool_name
virsh pool-build	#建立池
virsh pool-create-as	#从一组变量中创建一个池
virsh pool-create	#从一个 XML 文件中创建一个池
virsh pool-define-as	#在一组变量中定义池
virsh pool-delete pool_name
virsh pool-destroy pool_name
virsh pool-refresh pool_name
virsh pool-edit	pool_name	#编辑存储池XML配置

5. Storage volume

Storage pools are split into storage volumes ( storage volume)

Composition of storage volumes

  1. document
  2. Block devices (such as physical partitions, LVM logical volumes)

Volume Operations

  1. create
  2. clone
  3. delete
  4. move
  5. resize
virsh vol-list pool_name	#列举存储池中的存储卷
virsh vol-clone
virsh vol-create-as pool_name vol_name 2G --format qcow2 	#在存储池中创建存储卷
virsh vol-create
virsh delete
virsh vol-download
virsh vol-dumpxml	#XML 中的卷信息
virsh vol-info vol_name	#存储卷信息
virsh vol-list	#列出卷
virsh vol-name	#为给定密钥或者路径返回卷名
virsh vol-path
virsh vol-pool
virsh vol-resize	#重新定义卷大小
virsh vol-upload	#将文件内容上传到卷中
virsh vol-wipe	#擦除卷

Guess you like

Origin blog.csdn.net/Sanayeah/article/details/126739359