kvm 虚拟化技术 1.2之kvm基础操作

1.虚拟机基础操作

(1).查看。编辑。备份kvm配置文件以及查看kvm状态

[root@hd1 ~]# cd /etc/libvirt/qemu
[root@hd1 qemu]# ls
centos7.5.xml  networks
 
2)备份KVM 虚拟机配置文件
virsh edit centos7.5
3 )正在运行的KVM 虚拟机的状态可以用virsh list 查看:
 
[root@hd1 ~]# virsh list
Id    名称                         状态
----------------------------------------------------
2     centos7.5                      running
 
4) 查看所有的虚拟机 
 
[root@hd1 ~]# virsh list --all

 

 

5) KVM 虚拟机开启(启动)关闭
 [root@hd1 ~]# virsh start centos7.5
 [root@hd1 ~]# virsh shutdown  centos7.5
 
6) 重启KVM 虚拟机,要想重启kvm 虚拟机,先在kvm 虚拟机里面安装acpid 服务,并且启动设置为随机启动,否则使用virsh reboot 无效(centos6版本需要安装acpid服务,centos7不需要)
[root@hd1 ~]# virsh reboot cetos7.5
 
7 )暂停(挂起)KVM 虚拟机:
virsh  suspend centos7.5

 

 

8 ) 恢复被挂起的 KVM 虚拟机
 
[root@hd1 ~]# virsh resume centos7.5
域 centos7.5 被重新恢复

 

 

9 ) 删除虚拟机 ,该方法只删除配置文件,磁盘文件未删除,相当于从虚拟机中移除。
 [root@hd1 ~]#virsh undefine centos7.5
 
10 )KVM 设置为随物理机启动而启动(开机启动):
 root@hd1 ~]# virsh autostart centos7.5
域 centos7.5标记为自动
 
 
 
posted @ 2022-04-28 22:45  多次拒绝黄宗泽  阅读(176)  评论(0)    收藏  举报