1. 查看KVM虚拟机配置文件及运行状态
(1) KVM虚拟机默认配置文件位置: /etc/libvirt/qemu/

autostart目录是配置kvm虚拟机开机自启动目录。

(2) virsh命令帮助

# virsh -help

或直接virsh命令和,再执行子命令。如下所示。

[root@node1 ~]# virsh 

欢迎使用 virsh,虚拟化的交互式终端。

输入:'help' 来获得命令的帮助信息
'quit' 退出

virsh # help 

(3) 查看kvm虚拟机状态

# virsh list --all

2. KVM虚拟机开机

# virsh start oeltest01

3. KVM虚拟机关机或断电
(1) 关机

默认情况下virsh工具不能对linux虚拟机进行关机操作,linux操作系统需要开启与启动acpid服务。在安装KVM linux虚拟机必须配置此服务。

# chkconfig acpid on
# service acpid restart

virsh关机

# virsh shutdown oeltest01

(2) 强制关闭电源

# virsh destroy wintest01

4. 通过配置文件启动虚拟机

# virsh create /etc/libvirt/qemu/wintest01.xml 

5. 配置开机自启动虚拟机

# virsh autostart oeltest01 

autostart目录是kvm虚拟机开机自启动目录,可以看到该目录中有KVM配置文件链接。

6. 导出KVM虚拟机配置文件

# virsh dumpxml wintest01 > /etc/libvirt/qemu/wintest02.xml

KVM虚拟机配置文件可以通过这种方式进行备份。

7. 添加与删除KVM虚拟机
(1) 删除kvm虚拟机

# virsh undefine wintest01

说明:该命令只是删除wintest01的配置文件,并不删除虚拟磁盘文件。如下图所示。

(2) 重新定义虚拟机配置文件

通过导出备份的配置文件恢复原KVM虚拟机的定义,并重新定义虚拟机。

# mv /etc/libvirt/qemu/wintest02.xml /etc/libvirt/qemu/wintest01.xml

# virsh define /etc/libvirt/qemu/wintest01.xml 

8. 编辑KVM虚拟机配置文件

# virsh edit wintest01

virsh edit将调用vi命令编辑/etc/libvirt/qemu/wintest01.xml配置文件。也可以直接通过vi命令进行编辑,修改,保存。

可以但不建议直接通过vi编辑。

[root@node1 qemu]# vi /etc/libvirt/qemu/wintest01.xml

<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh edit wintest01
or other application using the libvirt API.
-->
<domain type='kvm'>
<name>wintest01</name>
<uuid>fe31ea48-7d6a-f3cb-cede-2f9bd9dec2bd</uuid>
<memory unit='KiB'></memory>
<currentMemory unit='KiB'></currentMemory>
<vcpu placement='static'></vcpu>
<os>
<type arch='x86_64' machine='rhel6.4.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/usr/libexec/qemu-kvm</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='none'/>
<source file='/data/wintest01.img'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='' bus='' target='' unit=''/>
</disk>
<disk type='block' device='cdrom'>
<driver name='qemu' type='raw'/>
<target dev='hdc' bus='ide'/>
<readonly/>
<address type='drive' controller='' bus='' target='' unit=''/>
</disk>
<controller type='usb' index=''>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='ide' index=''>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:2b:2f:fe'/>
<source bridge='br0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<target port=''/>
</serial>
<console type='pty'>
<target type='serial' port=''/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='' autoport='no' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='cirrus' vram='' heads=''/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</memballoon>
</devices>
<seclabel type='none'/>
</domain>

9. virsh console 控制台管理linux虚拟机

配置virsh console

# virsh console oeltest01 

10. 其它virsh命令
(1) 挂起服务器

# virsh suspend oeltest01 

(2) 恢复服务器

# virsh resume oeltest01 

virsh命令丰富。可以执行各种维护任务,本文只是从维护与管理的角度例举了常用的命令,为该命令的使用提供一个思路。

KVM虚拟机的日常管理与配置的更多相关文章

  1. kvm虚拟化学习笔记(四)之kvm虚拟机日常管理与配置

    KVM虚拟化学习笔记系列文章列表----------------------------------------kvm虚拟化学习笔记(一)之kvm虚拟化环境安装http://koumm.blog.51 ...

  2. kvm虚拟机日常管理和配置操作命令梳理

    KVM虚拟机的管理主要是通过virsh命令对虚拟机进行管理.1)查看KVM虚拟机配置文件及运行状态KVM虚拟机默认配置文件位置: /etc/libvirt/qemu/autostart目录是配置kvm ...

  3. kvm虚拟机日常管理与配置

    1.  查看KVM虚拟机配置文件及运行状态 (1) KVM虚拟机默认配置文件位置: /etc/libvirt/qemu/ autostart目录是配置kvm虚拟机开机自启动目录.    (2) vir ...

  4. OpenStack入门篇(四)之KVM虚拟机介绍和管理

    1.查看虚拟机,启动虚拟机 [root@linux-node1 ~]# virsh list --all Id Name State --------------------------------- ...

  5. KVM虚拟机安装及桥接网络配置

    1.查看CPU是否支持intel或AMD的虚拟技术 cat /proc/cpuinfo | grep -E "vmx|svm" --color --vmx intel的CPU sv ...

  6. 使用Python-Libvirt GUI 实现KVM 虚拟机 界面化管理

    一.KVM环境的搭建 1.安装VMware(略) 2.在VMware中安装Linux系统(略,Ubuntu16.04) 打开支持虚拟化 网络选择桥接模式 3.安装qemu apt-get instal ...

  7. 记录KVM虚拟机常用操作管理命令

    环境说明 centos7中的KVM NAT方式是kvm安装后的默认方式.它支持主机与虚拟机的互访,同时也支持虚拟机访问互联网,但不支持外界访问虚拟机. 检查当前的网络设置 # virsh net-li ...

  8. linux kvm虚拟机使用

    安装配置kvm 1.安装kvm软件包 [root@kvm ~]# yum install kvm python-virtinst libvirt tunctl bridge-utils virt-ma ...

  9. kvm虚拟化学习笔记(三)之windows kvm虚拟机安装

    KVM虚拟化学习笔记系列文章列表----------------------------------------kvm虚拟化学习笔记(一)之kvm虚拟化环境安装http://koumm.blog.51 ...

随机推荐

  1. 从零玩转JavaWeb系列7web服务器-----表单的提交

    在企业开放中如何提交一张表单? 例如:用户注册表 <!--表单内容--> <form action="/28-mystore/regist" id="R ...

  2. Linux常用命令----基本文件系统常用命令

    1.查看当前工作目录---pwd sunny@sunny-ThinkPad-T450:~$ pwd /home/sunny sunny@sunny-ThinkPad-T450:~$ cd Worksp ...

  3. 使apk具有system权限

    使apk具有system权限的方法:   方法一:   1. 在应用程序的AndroidManifest.xml中的manifest节点中加入   android:sharedUserId=" ...

  4. glTexGen

    [glTexGen] Rather than having to explicitly provide a texture coordinate for each vertex, we can use ...

  5. MySQL 基础常用命令

    一.启动与关闭 1.1 Linux下启动mysql 的命令: a. rpm包安装:service mysqld start b. 源码包安装:/usr/local/mysql/bin/mysqld_s ...

  6. xdebug 一直报错 upstream timed out (110: Connection timed out) while reading response header from upstream

    本地主机(Windows环境192.168.66.1)访问虚拟机(192.168.66.139)里面的搭建的php环境(系统centos6.5版本,php版本是5.5.30 ,xdebug 2.4.0 ...

  7. jquery简单ajax示例_读取json文件数据

    来自于<jquery权威指南> -------------------------------------- 点击button后,获取到json文件数据,显示如下: Json文件: [ { ...

  8. Red Hat 6.5 nfs服务的搭建

    nfs服务是实现Linux和Linux之间的文件共享,nfs服务的搭建比较简单. 现在介绍如何在红帽6.5系统中搭建nfs服务. 1.关闭selinux服务 如果已经关闭该服务的可以直接跳过该步骤. ...

  9. 后台注册js代码的方法

    Page.ClientScript.RegisterClientScriptBlock(JSUtil.CurrentPage.GetType(), Util.NewGuid(), @"< ...

  10. HBase列族高级配置

    转自:http://blog.sina.com.cn/s/blog_ae33b83901018euz.html ------------------ HBase有几个高级特性,在你设计表时可以使用.这 ...