Unit11.虚拟机管理
发布日期:2022-02-12 16:06:47
浏览次数:17
分类:技术文章
本文共 1108 字,大约阅读时间需要 3 分钟。
##1.脚本安装虚拟机 运行脚本的命令 sh + 脚本名
#!/bin/bash virt-install –cdrom /home/kiosk/Desktop/rhel-server-7.3-x86_64-dvd.iso –ram 1024 –cpus 1 –disk /var/lib/libvirt/images/test.qcow2,bus=virtio,size=9 \ –name test \ ##虚拟机名字为test –network bridge=br0,model=virtio &##再次用这个脚本安装虚拟机会报错,因为已经存在名为test的虚拟机
##不显示输出结果, & > /dev/null ##2.虚拟机管理命令 virt-manager ##开机虚拟机管理器 virsh list ##显示正在运行的虚拟机 virsh list --all ##查看所有虚拟机 virsh start desktop ##打开 virsh shutdown desktop ##正常关闭虚拟机 ##必须进系统 virsh destroy desktop ##强行关闭 virt-viewer desktop ##显示虚拟机 virsh undefine test ##删除虚拟机在家中模拟虚拟机的恢复
准备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’ (as uid:107, gid:107): No such file or directory解决方案:
mv /mnt/test.qcow2 /var/lib/libvirt/images/virsh define test.xml ##永久恢复虚拟机
####虚拟机快照#### qemu-img create -f qcow2 -b test.qcow2 node1 ##查看desktop虚拟机信息:file rh124-desktop-vda.ovl#reset的原理:删除虚拟机和虚拟机快照,然后从本体拍一个快照,重新创建虚拟机
转载地址:https://blog.csdn.net/weixin_45426401/article/details/97615170 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年04月08日 21时10分07秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
FFmpeg初遇见_基本命令
2019-04-26
Urbansound8k声音分类深度学习实战
2019-04-26
pytorch版本下的yolov3训练实现火焰检测
2019-04-26
yolov4训练自己的数据集实现安全帽佩戴检测
2019-04-26
EfficientDet训练自己的数据集实现抽烟检测
2019-04-26
【工具篇】10分钟快速上手git与github
2019-04-26
【开发篇】10分钟快速上手spring boot
2019-04-26
【开发篇】10分钟快速spring boot+react前后端分离
2019-04-26
【开发篇】10分钟快速上手spring boot+mybatis增删改查
2019-04-26
【Leetcode刷题篇】leetcode203 移除链表元素
2019-04-26
【Leetcode刷题篇】leetcode108 将有序数组转换为二叉搜索树
2019-04-26
【Leetcode刷题篇】leetcoe109 有序链表转换二叉搜索树
2019-04-26
【Leetcode刷题篇】leetcode938 二叉搜索树的范围和
2019-04-26
【Leetcode刷题篇】leetcode235 二叉搜索树的最近公共祖先
2019-04-26
【Leetcode刷题篇】leetcode236 二叉树的最近公共祖先
2019-04-26
【Leetcode刷题篇】leetcode230 二叉搜索树中第K小的元素
2019-04-26
【Leetcode刷题篇】leetcode173 二叉搜索树迭代器
2019-04-26
【Leetcode刷题篇】leetcode99 恢复二叉搜索树
2019-04-26
【Leetcode刷题篇】leetcode451根据字符出现频率排序
2019-04-26
【Leetcode刷题篇】leetcode703 数据流中的第k大元素
2019-04-26