KVM虚拟机的管理主要是通过virsh命令对虚拟机进行管理。

1.  查看KVM虚拟机配置文件及运行状态

(1) KVM虚拟机默认配置文件位置: /etc/libvirt/qemu/

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

(2) virsh命令帮助

# virsh -help

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

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

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

virsh # help……

(3) 查看kvm虚拟机状态

# virsh list --all

2.  KVM虚拟机开机

# virsh start kvm008

3. KVM虚拟机关机或断电

(1) 关机

默认情况下virsh工具不能对linux虚拟机进行关机操作,linux操作系统需要开启与启动acpid服务。

在安装KVM linux虚拟机之前必须配置此服务。

# chkconfig acpid on# service acpid restart

virsh关机

# virsh shutdown kvm008

(2) 强制关闭电源

# virsh destroy kvm08

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

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

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

# virsh autostart kvm008

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

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

虚拟机要关机     不然会操作 失败哦~

# virsh dumpxml/etc/libvirt/qemu/kvm008 > /etc/libvirt/qemu/kvm.xml

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

7. 添加与删除KVM虚拟机

(1)  删除kvm虚拟机

# virshundefinekvm008

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

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

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

# mv /etc/libvirt/qemu/kvm.xml /etc/libvirt/qemu/kvm008.xml

# virshdefine/etc/libvirt/qemu/kvm008.xml

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

# virsh edit kvm08

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

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

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

虚拟机要开机 才可以

# virsh console kvm08

10. 其它virsh命令

(1) 挂起服务器

# virsh suspend kvm08

(2) 恢复服务器

# virsh  resume kvm08

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

virsh  命令:

virsh # help

Grouped commands:

Domain Management (help keyword 'domain'):

attach-device                  从一个XML文件附加装置

attach-disk                    附加磁盘设备

attach-interface               获得网络界面

autostart                      自动开始一个域

blkdeviotune                   Set or query a block device I/O tuning parameters.

blkiotune                      Get or set blkio parameters

blockcommit                    Start a block commit operation.

blockcopy                      Start a block copy operation.

blockjob                       Manage active block operations

blockpull                      Populate a disk from its backing p_w_picpath.

blockresize                    Resize block device of domain.

change-media                   Change media of CD or floppy drive

console                        连接到客户会话

cpu-baseline                   compute baseline CPU

cpu-compare                    compare host CPU with a CPU described by an XML file

cpu-stats                      show domain cpu statistics

create                         从一个 XML 文件创建一个域

define                         从一个 XML 文件定义(但不开始)一个域

desc                           show or set domain's description or title

destroy                        destroy (stop) a domain

detach-device                  从一个 XML 文件分离设备

detach-disk                    分离磁盘设备

detach-interface               分离网络界面

domdisplay                     domain display connection URI

domhostname                    print the domain's hostname

domid                          把一个域名或 UUID 转换为域 id

domif-setlink                  set link state of a virtual interface

domiftune                      get/set parameters of a virtual interface

domjobabort                    abort active domain job

domjobinfo                     domain job information

domname                        将域 id 或 UUID 转换为域名

dompmsuspend                   suspend a domain gracefully using power management functions

dompmwakeup                    wakeup a domain from pmsuspended state

domuuid                        把一个域名或 id 转换为域 UUID

domxml-from-native             Convert native config to domain XML

domxml-to-native               Convert domain XML to native config

dump                           把一个域的内核 dump 到一个文件中以方便分析

dumpxml                        XML 中的域信息

edit                           编辑某个域的 XML 配置

inject-nmi                     Inject NMI to the guest

send-key                       Send keycodes to the guest

managedsave                    managed save of a domain state

managedsave-remove             Remove managed save of a domain

maxvcpus                       connection vcpu maximum

memtune                        Get or set memory parameters

migrate                        将域迁移到另一个主机中

migrate-setmaxdowntime         set maximum tolerable downtime

migrate-setspeed               Set the maximum migration bandwidth

migrate-getspeed               Get the maximum migration bandwidth

numatune                       Get or set numa parameters

reboot                         重新启动一个域

reset                          reset a domain

restore                        从一个存在一个文件中的状态恢复一个域

resume                         重新恢复一个域

save                           把一个域的状态保存到一个文件

save-p_w_picpath-define              redefine the XML for a domain's saved state file

save-p_w_picpath-dumpxml             saved state domain information in XML

save-p_w_picpath-edit                edit XML for a domain's saved state file

schedinfo                      显示/设置日程安排变量

screenshot                     take a screenshot of a current domain console and store it into a file

setmaxmem                      改变最大内存限制值

setmem                         改变内存的分配

setvcpus                       改变虚拟 CPU 的号

shutdown                       关闭一个域

start                          开始一个(以前定义的)非活跃的域

suspend                        挂起一个域

ttyconsole                     tty 控制台

undefine                       undefine a domain

update-device                  update device from an XML file

vcpucount                      domain vcpu counts

vcpuinfo                       detailed domain vcpu information

vcpupin                        control or query domain vcpu affinity

emulatorpin                    control or query domain emulator affinity

vncdisplay                     vnc 显示

Domain Monitoring (help keyword 'monitor'):

domblkerror                    Show errors on block devices

domblkinfo                     domain block device size information

domblklist                     list all domain blocks

domblkstat                     获得域设备块状态

domcontrol                     domain control interface state

domif-getlink                  get link state of a virtual interface

domiflist                      list all domain virtual interfaces

domifstat                      获得域网络接口状态

dominfo                        域信息

dommemstat                     get memory statistics for a domain

domstate                       域状态

list                           列出域

Host and Hypervisor (help keyword 'host'):

capabilities                   性能

freecell                       NUMA可用内存

hostname                       打印管理程序主机名

node-memory-tune               Get or set node memory parameters

nodecpustats                   Prints cpu stats of the node.

nodeinfo                       节点信息

nodememstats                   Prints memory stats of the node.

nodesuspend                    suspend the host node for a given time duration

qemu-attach                    QEMU Attach

qemu-monitor-command           QEMU Monitor Command

qemu-agent-command             QEMU Guest Agent Command

sysinfo                        print the hypervisor sysinfo

uri                            打印管理程序典型的URI

version                        显示版本

Interface (help keyword 'interface'):

iface-begin                    create a snapshot of current interfaces settings, which can be later committed (iface-commit) or restored (iface-rollback)

iface-bridge                   create a bridge device and attach an existing network device to it

iface-commit                   commit changes made since iface-begin and free restore point

iface-define                   define (but don't start) a physical host interface from an XML file

iface-destroy                  destroy a physical host interface (disable it / "if-down")

iface-dumpxml                  interface information in XML

iface-edit                     edit XML configuration for a physical host interface

iface-list                     list physical host interfaces

iface-mac                      convert an interface name to interface MAC address

iface-name                     convert an interface MAC address to interface name

iface-rollback                 rollback to previous saved configuration created via iface-begin

iface-start                    start a physical host interface (enable it / "if-up")

iface-unbridge                 undefine a bridge device after detaching its slave device

iface-undefine                 undefine a physical host interface (remove it from configuration)

Network Filter (help keyword 'filter'):

nwfilter-define                define or update a network filter from an XML file

nwfilter-dumpxml               network filter information in XML

nwfilter-edit                  edit XML configuration for a network filter

nwfilter-list                  list network filters

nwfilter-undefine              undefine a network filter

Networking (help keyword 'network'):

net-autostart                  自动开始网络

net-create                     从一个 XML 文件创建一个网络

net-define                     从一个 XML 文件定义(但不开始)一个网络

net-destroy                    destroy (stop) a network

net-dumpxml                    XML 中的网络信息

net-edit                       为网络编辑 XML 配置

net-info                       network information

net-list                       列出网络

net-name                       把一个网络UUID 转换为网络名

net-start                      开始一个(以前定义的)不活跃的网络

net-undefine                   取消定义一个非活跃的网络

net-update                     update parts of an existing network's configuration

net-uuid                       把一个网络名转换为网络UUID

Node Device (help keyword 'nodedev'):

nodedev-create                 create a device defined by an XML file on the node

nodedev-destroy                destroy (stop) a device on the node

nodedev-detach                 detach node device from its device driver

nodedev-dumpxml                XML 中的节点设备详情

nodedev-list                   这台主机中中的枚举设备

nodedev-reattach               reattach node device to its device driver

nodedev-reset                  重置节点设备

Secret (help keyword 'secret'):

secret-define                  define or modify a secret from an XML file

secret-dumpxml                 secret attributes in XML

secret-get-value               Output a secret value

secret-list                    list secrets

secret-set-value               set a secret value

secret-undefine                undefine a secret

Snapshot (help keyword 'snapshot'):

snapshot-create                Create a snapshot from XML

snapshot-create-as             Create a snapshot from a set of args

snapshot-current               Get or set the current snapshot

snapshot-delete                Delete a domain snapshot

snapshot-dumpxml               Dump XML for a domain snapshot

snapshot-edit                  edit XML for a snapshot

snapshot-info                  snapshot information

snapshot-list                  List snapshots for a domain

snapshot-parent                Get the name of the parent of a snapshot

snapshot-revert                Revert a domain to a snapshot

Storage Pool (help keyword 'pool'):

find-storage-pool-sources-as   找到潜在存储池源

find-storage-pool-sources      发现潜在存储池源

pool-autostart                 自动启动某个池

pool-build                     建立池

pool-create-as                 从一组变量中创建一个池

pool-create                    从一个 XML 文件中创建一个池

pool-define-as                 在一组变量中定义池

pool-define                    在一个 XML 文件中定义(但不启动)一个池

pool-delete                    删除池

pool-destroy                   destroy (stop) a pool

pool-dumpxml                   XML 中的池信息

pool-edit                      为存储池编辑 XML 配置

pool-info                      存储池信息

pool-list                      列出池

pool-name                      将池 UUID 转换为池名称

pool-refresh                   刷新池

pool-start                     启动一个(以前定义的)非活跃的池

pool-undefine                  取消定义一个不活跃的池

pool-uuid                      把一个池名称转换为池 UUID

Storage Volume (help keyword 'volume'):

vol-clone                      clone a volume.

vol-create-as                  从一组变量中创建卷

vol-create                     从一个 XML 文件创建一个卷

vol-create-from                create a vol, using another volume as input

vol-delete                     删除卷

vol-download                   download volume contents to a file

vol-dumpxml                    XML 中的卷信息

vol-info                       存储卷信息

vol-key                        returns the volume key for a given volume name or path

vol-list                       列出卷

vol-name                       returns the volume name for a given volume key or path

vol-path                       returns the volume path for a given volume name or key

vol-pool                       returns the storage pool for a given volume key or path

vol-resize                     resize a vol

vol-upload                     upload file contents to a volume

vol-wipe                       wipe a vol

Virsh itself (help keyword 'virsh'):

cd                             change the current directory

connect                        连接(重新连接)到 hypervisor

echo                           echo arguments

exit                           退出这个非交互式终端

help                           打印帮助

pwd                            print the current directory

quit                           退出这个非交互式终端

linux查看xml文件的配置,3、kvm虚拟机日常管理与配置相关推荐

  1. linux查看xml文件的配置,Hibernate配置文件hibernate.cfg.xml的详细解释

    Hibernate配置文件hibernate.cfg.xml的详细解释 [日期:2012-12-13] 来源:Linux社区 作者:jqyp [字体:大 中 小] /p> "-//Hi ...

  2. linux打开xml文件,查看 XML 文件

    查看 XML 文件 在所有主流的浏览器中,均能够查看原始的 XML 文件. 不要指望 XML 文件会直接显示为 HTML 页面. 查看 XML 文件 - Tove Jani Reminder 查看这个 ...

  3. linux view查看日志命令,【Linux】linux查看日志文件内容命令tail、cat、tac、head、echo...

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log 你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, --------- ...

  4. linux view查看日志命令,linux查看日志文件内容命令tail、cat、tac、head、echo、vi

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log 你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, --------- ...

  5. java查看日志命令_[Java教程]【Linux】linux查看日志文件内容命令tail、cat、tac、head、echo...

    [Java教程][Linux]linux查看日志文件内容命令tail.cat.tac.head.echo 0 2017-11-14 12:00:29 linux查看日志文件内容命令tail.cat.t ...

  6. linux读整个文件内容,Linux查看整个文件

    Linux查看整个文件 使用cat命令显示文本文件的内容 使用cat命令可以显示文本文件的内容.cat后面可以不加任何选项,直接跟文件名 功能说明:查看某个文件的内容 ###cat命令语法 cat [ ...

  7. 如何在Web浏览器中查看XML文件

    一旦了解到HTML是XML的一种形式,您可能会想知道如果尝试在浏览器中查看XML文件会发生什么. 结果令人非常失望-Firefox在页面顶部显示一条横幅,上面写着:"此XML文件似乎没有与之 ...

  8. linux查看日志文件内容命令tail、cat、tac、head、echo、vi

    linux查看日志文件内容命令tail.cat.tac.head.echo tail -f test.log 你会看到屏幕不断有内容被打印出来. 这时候中断第一个进程Ctrl-C, --------- ...

  9. linux查看文件隐藏字符,Linux查看整个文件

    Linux查看整个文件 使用cat命令显示文本文件的内容 使用cat命令可以显示文本文件的内容.cat后面可以不加任何选项,直接跟文件名 功能说明:查看某个文件的内容 cat命令语法 cat [参数] ...

最新文章

  1. Solaris9 Sparc下安装JDK6.0和tomcat6.0
  2. sql去除空值_SQL汇总分析
  3. Jdbc访问mysql查询聚合函数_JDBC连接参数设置对Oracle数据库的影响分析
  4. 英法德三门语言同时达到c1,【分享】插翅而飞的孩子(转载)
  5. selenium框架安装及webdriver安装
  6. PyTorch载入图片后ToTensor解读(含PIL和OpenCV读取图片对比)
  7. 学习SQL:SQL Server日期和时间函数
  8. iOS自动布局之autoresizingi
  9. Fragment的使用
  10. WPS 破解宏 安装VBA VBA for WPS
  11. 为什么unity中我的模型是红颜色的
  12. SAP UI5 进阶 - XML 视图里定义的 UI 控件,运行时实例化的技术细节剖析试读版
  13. phpcmsV9 全站搜索功能如何实现
  14. 尝试manjar20.03、fedora32、ubuntu20.04作为主力操作系统
  15. mysql查看数据库的容量及表容量
  16. iOS攻防 - (十)theos的介绍,安装和使用
  17. 模型剪枝经典论文解读:《Learning Efficient Convolutional Networks through Network Slimming》
  18. 儿童监控录像软件:用电脑摄像头即可监控儿童
  19. 转云风的博客——无欲则刚
  20. app 启动页面功能

热门文章

  1. 受迫阻尼 matlab 仿真,MATLAB系统仿真报告——有阻尼受迫振动系统
  2. hybrid7 宝马active_【图】宝马ActiveHybrid7系 动力节能完美结合_汽车之家
  3. Java 分割字符串
  4. Dev C++ 实现Hello World
  5. mysql srid_mysql8 参考手册--索引优化
  6. mysql数据库自动化脚本备份_mysql 自动化脚本备份
  7. 【OpenCV 例程200篇】35. 图像的投影变换(边界填充)
  8. oracle tb级别数据量,备份TB级别Oracle数据库的一些技巧
  9. mysql安装版安装
  10. ele-plus包的安装和使用