首页 > 其他 > 详细

KVM ---------virsh常用操作

时间:2015-10-16 06:31:03      阅读:222      评论:0      收藏:0      [点我收藏+]

查看虚拟机

[root@localhost kvm]# virsh list
Id    Name                           State
----------------------------------------------------
1     caimz_1                        running
3     caimz_2                        running
4     caimz_3                        running
6     caimz_4                        running

2、查看所有的虚拟机关机,开机的

[root@localhost kvm]# virsh list --all
Id    Name                           State
----------------------------------------------------
1     caimz_1                        running
3     caimz_2                        running
4     caimz_3                        running
6     caimz_4                        running

3、进入系统

     名字进入或者ip进入

[root@localhost ~]#  virsh console caimz_2

Connected to domain caimz_2
Escape character is ^]

[root@localhost usr]# ifconfig
eth0      Link encap:Ethernet  HWaddr 52:54:00:A6:31:A5 
          inet addr:192.168.0.115  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fea6:31a5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:18505 errors:0 dropped:0 overruns:0 frame:0
          TX packets:54 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1797742 (1.7 MiB)  TX bytes:5815 (5.6 KiB)

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

3、关机

          子机要安装电池管理。yum install -y acpid

          启动

          [root@localhost usr]# /etc/init.d/acpid start
          Starting acpi daemon: [  OK  ]

          [root@localhost ~]# virsh shutdown caimz_2

          Domain caimz_2 is being shutdown

          过一会

          [root@localhost ~]# virsh list --all

          Id    Name                           State
          ----------------------------------------------------
          1     caimz_1                        running
          4     caimz_3                        running
          6     caimz_4                        running
-               caimz_2                        shut off

4、开机

     virsh start  caimz_2 --console

     [root@localhost ~]# virsh start caimz_2  --console
     Domain caimz_2 started
     Connected to domain caimz_2
     Escape character is ^]

5、删除虚拟机

    [root@localhost ~]# virsh destroy caimz_1

    Domain caimz_1 destroyed

    只是不在列表中了。没有真正的意义上的删除,文件还在。

6、挂起虚拟机

     [root@localhost ~]# virsh suspend caimz_2

    Domain caimz_2 suspended

    挂起后恢复

     [root@localhost ~]# virsh resume caimz_2

     Domain caimz_2 resumed

7、开机自启动,子机随母机启动

     [root@localhost ~]# virsh autostart caimz_2

     Domain caimz_2 marked as autostarted

8、取消开机自启动

     [root@localhost ~]# virsh autostart --disable caimz_2

     Domain caimz_2 unmarked as autostarted

9、彻底删除虚拟

      [root@localhost ~]# virsh destroy caimz_1
      Domain caimz_1 destroyed

     [root@localhost ~]# virsh undefine caimz_1
     Domain caimz_1 has been undefined

     [root@localhost caimz]# rm -rf caimz.img #删除文件


KVM ---------virsh常用操作

原文:http://caimengzhi.blog.51cto.com/9787265/1703344

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!