linxu virtual machine operation
Installation conditions and virtualization related information
- Installation conditions
-inter cpu ------------> vmx file
-amd cpu ------------> svm file
2. Related information
-service name: libvirtd
-virtualization Core: qemu/kvm
-virtualization storage directory (virtual machine hard disk) /var/lib/libvirt/images/westos.qcow2-virtualization
hardware information: /etc/libvirt/qemu/westos.xml
Virtualization installation process
Manual installation
-
Install the components required for virtualization
Virtualization Client ##虚拟机客户端 Virtualization Tools ##虚拟化工具 Virtualization Hypervisor ##虚拟化核心套件
Find the software group and install it to see if the installation is successful.
-
Turn on virtualization services
-
Create a virtual machine and make related settings (images can be downloaded in advance)
If the final installation is not successful, you can check if your memory is not enough, mine is because of insufficient memory, adjusted to 1024, and the installation is successful.
Red Hat system internal installation
Wait for the progress bar to finish and restart.
Virtual machine snapshot
- Set virtual machine snapshot
- Use the snapshot to install the virtual machine
and then all the next step, you can find that it will directly enter the system without repeating the installation.
Script installation
-
Install via hard disk script
-
Install via snapshot script
Virtual machine management commands
virt-manager ##打开虚拟机管理界面
virsh list ##列出所有正在运行的虚拟机
virsh list --all ##列出所有虚拟机,包括关机的
virsh start xxx ##启动名字为xxx的虚拟机
virsh shutdown xxx ##正常关机
virsh destroy ##强制关机
virt-viewer xxx ##显示虚拟机界面
Transmission and Recovery of Virtual Machine in Linux
Virtual machine transfer command
There are two important files for transmission: one is the master disk file, located in /var/lib/libvirt/images/xxx.qcow2, and the other is the file ending in .xml under /etc/libvirt/qemu/ (the name is the master disk Name), which is the .xml file corresponding to the master disk
Command:
Copy someone else’s virtual machine master disk and corresponding files
scp [email protected]:/var/lib/libvirt/images/母盘名称.qcow2 /var/lib/libvirt/images/
scp [email protected]:/etc/libvirt/qemu/母盘名称.xml /etc/libvirt/qemu/
Recovery commands for virtual machines
virsh define westos.xml ##通过硬件信息文件恢复虚拟机
virsh create westos.xml ##通过硬件信息文件打开虚拟机,虚拟机关闭后消失
virsh undefine westos ##删除虚拟机硬件信息