####虚拟机的安装###
制作脚本create_vm.sh
运行脚本create_vm.sh 自动安装虚拟机
制作快照脚本vm_kuaizhao.sh
#####虚拟机管理####
#1.虚拟机管理命令
virt-manager ##开机虚拟机管理器
virsh list ##显示正在运行的虚拟机
virsh list --all ##查看所有虚拟机
virsh start desktop ##打开
virsh shutdown desktop ##正常关闭虚拟机
virsh destroy desktop ##强行关闭
virt-viewer desktop ##显示虚拟机
在家中模拟虚拟机的恢复
准备1个已经安装好的虚拟机
mv /etc/libvirt/qemu/test.xml /mnt/
mv /var/lib/libvirt/images/test.qcow2 /mnt/
在虚拟机管理器中删除这个装好的虚拟机
模拟恢复过程
cd /mnt
virsh create test.xml ##用硬件信息文启动虚拟机
在操作过程中会有以下错误:
error:Cannot access storage file '/var/lib/libvirt/images/test.qcow2' (a07, gid:107): No such file or directory
cd
解决方案:
mv /mnt/test.qcow2 /var/lib/libvirt/images/
virsh define test.xml ##永久恢复虚拟机
####自动安装虚拟机##
下载 system-config-kickstart httpd
vim /etc/www/html/ks.cfg
制作脚本vm_create.sh
运行脚本vm_create.sh产生的效果