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

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

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

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

autostart目录是配置kvm虚拟机开机自启动目录。0b24bfb37b3bb2147d3ddb9abdc81684.png

(2) virsh命令帮助

# virsh -help

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

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

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

virsh # help……

(3) 查看kvm虚拟机状态

# virsh list --all

214840966093e0094f9ebdf60bb007a5.png

2.  KVM虚拟机开机

# virsh start kvm008

42cfe8219f5c354e9fc7e60cb7a1bed4.png

3. KVM虚拟机关机或断电

(1) 关机

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

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

# chkconfig acpid on# service acpid restart

virsh关机

# virsh shutdown kvm008

fc697ebe74084bd317d9ce1809cec5e7.png

(2) 强制关闭电源

# virsh destroy kvm08

50e7c17cb4d814962ab6eb5d3dfb6593.png

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

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

4e41928a790b6d8d3bd46275084620f5.png

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

# virsh autostart kvm008

0325dade02591c38d264678d622aea61.png

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

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

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

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

1884a0605bbec1097b984e0b1deb7493.png

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

7. 添加与删除KVM虚拟机

(1)  删除kvm虚拟机

# virshundefinekvm008

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

2f76e219879f77aa67e0563b9ffff84c.png

(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

b07b5ac82d496c19501d05b42fe45791.png

(2) 恢复服务器

# virsh  resume kvm08

83e2252009901ed00cfb843b2146071f.png

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                           退出这个非交互式终端

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/573267.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

hdu5726-GCD-ST表+二分

先用st表处理出所有l-r的GCD值&#xff0c;然后二分求得这些值一共出现了多少次。 1 #include<bits/stdc.h>2 3 #define inf 0x3f3f3f3f4 5 const int maxn100000;6 7 using namespace std;8 9 typedef pair<int,int> P;10 11 int l,r;12 13 int icase;14 15 int t…

linux桌面环境是什么意思,Linux 黑话解释:什么是桌面环境?

在桌面 Linux 世界中&#xff0c;最常用的术语之一就是 桌面环境(Desktop Environment)(DE)。如果你是 Linux 的新手&#xff0c;你应该了解一下这个经常使用的术语。什么是 Linux 中的桌面环境?桌面环境是一个组件的组合体&#xff0c;为你提供常见的 图形用户界面(graphical…

redhat linux 安装ftp服务,RedHat Linux 9.0为例介绍一下如何安装和配置vsftpd服务器

本文以RedHat Linux 9.0为例介绍一下如何安装和配置vsftpd服务器。安装服务器程序程序下载地址&#xff1a;&#xff0c;目前最新版本为2.0.3&#xff0c;源程序文件名为vsftpd-2.0.3.tar.gz。1&#xff0e;安装之前的准备&#xff1a;安装之前我们应该看看用户“nobody”和目录…

Hadoop 2.5.1集群安装配置

本文的安装只涉及了hadoop-common、hadoop-hdfs、hadoop-mapreduce和hadoop-yarn&#xff0c;并不包含HBase、Hive和Pig等。 http://blog.csdn.net/aquester/article/details/24621005 1. 规划 1.1. 机器列表 NameNode SecondaryNameNode DataNodes 172.16.0.100 172.16.0.…

linux杀掉进程后总是重启,Linux监控进程,进程关闭自动重启方案

Linux监控进程&#xff0c;进程关闭自动重启方案corntabshell脚本检测进程这个方案简单不用额外安装软件。缺点是存在间隔&#xff0c;corntab设置1秒执行一次shell脚本也是存在间隔的#!/bin/bash#author smallForest#email 1032817724qq.comproc_name"xiaofei.php" …

C语言atan2()函数:求y/x的反正切值

头文件&#xff1a;#include <math.h>atan2() 函数用于求 y / x 的反正切值。其原型为&#xff1a; double atan2(double y, double x);【参数】x为坐标的X轴值&#xff0c;y为坐标的Y轴值。如果 x 和 y 的值都为 0&#xff0c;将会导致错误。atan2() 求坐标 x 和 y 的…

Linux qt程序打包依赖库,Linux打包免安装的Qt程序(编写导出依赖包的脚本copylib.sh,程序启动脚本MyApp.sh)...

本文介绍如何打包Qt程序&#xff0c;使其在没有安装Qt的系统可以运行。默认前提&#xff1a;另外一个系统和本系统是同一个系统版本。1&#xff0c;编写导出依赖包的脚本copylib.sh#!/bin/bashLibDir$PWD"/lib"Target$1lib_array($(ldd $Target | grep -o "/.*&…

ubuntu14.04 x86编译upx 3.92 及so加固

的参考文章&#xff1a; http://www.cnblogs.com/fishou/p/4202061.html 1.download upx和所依赖的组件 upx3.92&#xff1a;https://www.pysol.org:4443/hg/upx.hg/archive/tip.tar.gzLZMA4.43&#xff1a;http://nchc.dl.sourceforge.net/project/sevenzip/LZMA%20SDK/4.43/l…

linux磁盘分区面试题,一套Linux面试模拟题及答案

一、填空题1、查找在当前目录中文件属主具有读、写权限&#xff0c;并且文件所属组的用户和其他用户具有读权限的文件&#xff0c;使用的命令是( find . -perm 644 )&#xff1b;查找在/tmp目录中&#xff0c;属主是benet用户的文件( find /tmp –user benet)&#xff1b;删除当…

jQuery中的渐变动画效果

jQuery中的渐变动画效果jQuery中的渐变动画效果转载于:https://www.cnblogs.com/DreamDrive/p/5780292.html

linux vi编辑器 Ctrl s,Linux命令-----vi/vim编辑器

也可建立vi到vim的符号连接(即实际调用的是vim)# mv /bin/vi /bin/vi.bak# ln -s /usr/bin/vim /bin/vi进入vi的命令&#xff1a;vi 直接进入编辑并创建新文件vi filename 编辑文件(不存在则创建文件)&#xff0c;并将光标置于第一行首vi n filename 打开文件&#xff0c;并…

insert sort

插入排序将数据分为前面有序部分和后面无序部分,取无序部分的第一个元素插入到有序序列中.注意与选择排序的区别. // insert sortvoid insertionSort(int arr[], int length) {int i, j, tmp;for (i 1; i < length; i) {j i;while (j > 0 && arr[j 1] > ar…

关闭linux系统中读写页缓存,Linux文件系统FAQ

Linux文件系统FAQ2010年03月25日最近实验室搞了一些列讲座&#xff0c;阿福师兄关于文件系统的讲座帮我弄清楚了一些以前不清楚的问题&#xff0c;以问答的形式对文件系统常见的问题进行了总结。Q: 文件系统如何看待底层物理块设备&#xff1f;文件系统把块设备简单的看做线性的…

《JS权威指南学习总结--6.1原型》

内容要点&#xff1a; 一.每一个JS对象&#xff08;null除外&#xff09;都和另一个对象相关联。"另一个"对象就是我们熟知的原型&#xff0c;每一个对象都从原型继承属性. 二.所有通过对象直接量创建的对象都具有同一个原型对象&#xff0c;并可以通过JS代码Object.…

linux下执行shell修改用户密码,[转] 关于linux下通过shell命令(自动)修改用户密码...

本文章总结了如何手动、自动修改本地用户密码及远程机器的用户密码。对做自动化测试提供了自动修改用户密码的原理及方法。修改本地用户密码&#xff1a;1、交互配置本地用户&#xff1a;以root用户&#xff1a;passwd Changing password for user dewang.New UNIX password:BA…

Visual Studio提示Bonjour backend初始化失败

Visual Studio提示Bonjour backend初始化失败 错误信息&#xff1a;The Bonjour backend failed to initialize, automatic Mac Build server discovery will not be available.这是由于Windows下的Bonjour服务没有开启&#xff0c;需要到服务管理中&#xff0c;开启该服务&…

104 规约模拟器linux,变电站自动化系统调试装置 Substation automation system debugging device...

摘要&#xff1a;本发明涉及一种在电力系统中应用的变电站自动化系统调试装置,其结构为电源与触电保安器相连,触电保安器分别与平板电脑,标准规约模拟器,交换机及调制解调器相连;平板电脑通过多功能接口盒与交换机和电度表相连;通讯管理机分别与调制解调器,交换机及电度表相连.…

Unity3d 札记-Let's try shooting 知识点汇总

1\LineRenderer LineRenderer是用来在3d场景画直线的一个工具。 public LineRenderer laserline;laserline.SetPositon(0,startposition);laserline.SetPositon(1,endposition);//设置结束位置startpositon,endposition均为Vector3 ,空间三维坐标 laserline.enabled(true); las…

c语言如何控制电脑串口,C语言直接驱动硬件实现PC机的串口操作

熟悉C语言的人都知道&#xff0c;虽然C语言是一门高级语言&#xff0c;拥有很多高级语言的特性&#xff0c;但是作为一种由低级语言到高级的过渡&#xff0c;他又继承了很多低级语言的特性&#xff0c;那就是可以直接操作计算机的硬件设备。本人近日在学习有关PLC网络方面的知识…

iOS ReactiveCocoa 最全常用API整理(可做为手册查询)

本文出出http://www.code4app.com/blog-721976-195.html 本文适合有一定RAC基础的童鞋做不时的查询&#xff0c;所以本文不做详细解释。 一、常见类 1、RACSiganl 信号类。 RACEmptySignal &#xff1a;空信号&#xff0c;用来实现 RACSignal 的 empty 方法&#xff1b; RACRet…