1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > linux查看xml文件的配置 3 kvm虚拟机日常管理与配置

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

时间:2022-05-17 07:45:28

相关推荐

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

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

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

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

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

(2)virsh命令帮助

#virsh-help

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

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

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

virsh#help……

(3)查看kvm虚拟机状态

#virshlist--all

2.KVM虚拟机开机

#virshstartkvm008

3.KVM虚拟机关机或断电

(1)关机

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

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

#chkconfigacpidon#serviceacpidrestart

virsh关机

#virshshutdownkvm008

(2)强制关闭电源

#virshdestroykvm08

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

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

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

#virshautostartkvm008

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

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

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

#virshdumpxml/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虚拟机配置文件

#virsheditkvm08

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

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

9.virshconsole控制台管理linux虚拟机

虚拟机要开机 才可以

#virshconsolekvm08

10.其它virsh命令

(1)挂起服务器

#virshsuspendkvm08

(2)恢复服务器

#virshresumekvm08

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

virsh 命令:

virsh#help

Groupedcommands:

DomainManagement(helpkeyword'domain'):

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

attach-disk附加磁盘设备

attach-interface获得网络界面

autostart自动开始一个域

blkdeviotuneSetorqueryablockdeviceI/Otuningparameters.

blkiotuneGetorsetblkioparameters

blockcommitStartablockcommitoperation.

blockcopyStartablockcopyoperation.

blockjobManageactiveblockoperations

blockpullPopulateadiskfromitsbackingp_w_picpath.

blockresizeResizeblockdeviceofdomain.

change-mediaChangemediaofCDorfloppydrive

console连接到客户会话

cpu-baselinecomputebaselineCPU

cpu-comparecomparehostCPUwithaCPUdescribedbyanXMLfile

cpu-statsshowdomaincpustatistics

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

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

descshoworsetdomain'sdescriptionortitle

destroydestroy(stop)adomain

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

detach-disk分离磁盘设备

detach-interface分离网络界面

domdisplaydomaindisplayconnectionURI

domhostnameprintthedomain'shostname

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

domif-setlinksetlinkstateofavirtualinterface

domiftuneget/setparametersofavirtualinterface

domjobabortabortactivedomainjob

domjobinfodomainjobinformation

domname将域id或UUID转换为域名

dompmsuspendsuspendadomaingracefullyusingpowermanagementfunctions

dompmwakeupwakeupadomainfrompmsuspendedstate

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

domxml-from-nativeConvertnativeconfigtodomainXML

domxml-to-nativeConvertdomainXMLtonativeconfig

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

dumpxmlXML中的域信息

edit编辑某个域的XML配置

inject-nmiInjectNMItotheguest

send-keySendkeycodestotheguest

managedsavemanagedsaveofadomainstate

managedsave-removeRemovemanagedsaveofadomain

maxvcpusconnectionvcpumaximum

memtuneGetorsetmemoryparameters

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

migrate-setmaxdowntimesetmaximumtolerabledowntime

migrate-setspeedSetthemaximummigrationbandwidth

migrate-getspeedGetthemaximummigrationbandwidth

numatuneGetorsetnumaparameters

reboot重新启动一个域

resetresetadomain

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

resume重新恢复一个域

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

save-p_w_picpath-defineredefinetheXMLforadomain'ssavedstatefile

save-p_w_picpath-dumpxmlsavedstatedomaininformationinXML

save-p_w_picpath-editeditXMLforadomain'ssavedstatefile

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

screenshottakeascreenshotofacurrentdomainconsoleandstoreitintoafile

setmaxmem改变最大内存限制值

setmem改变内存的分配

setvcpus改变虚拟CPU的号

shutdown关闭一个域

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

suspend挂起一个域

ttyconsoletty控制台

undefineundefineadomain

update-deviceupdatedevicefromanXMLfile

vcpucountdomainvcpucounts

vcpuinfodetaileddomainvcpuinformation

vcpupincontrolorquerydomainvcpuaffinity

emulatorpincontrolorquerydomainemulatoraffinity

vncdisplayvnc显示

DomainMonitoring(helpkeyword'monitor'):

domblkerrorShowerrorsonblockdevices

domblkinfodomainblockdevicesizeinformation

domblklistlistalldomainblocks

domblkstat获得域设备块状态

domcontroldomaincontrolinterfacestate

domif-getlinkgetlinkstateofavirtualinterface

domiflistlistalldomainvirtualinterfaces

domifstat获得域网络接口状态

dominfo域信息

dommemstatgetmemorystatisticsforadomain

domstate域状态

list列出域

HostandHypervisor(helpkeyword'host'):

capabilities性能

freecellNUMA可用内存

hostname打印管理程序主机名

node-memory-tuneGetorsetnodememoryparameters

nodecpustatsPrintscpustatsofthenode.

nodeinfo节点信息

nodememstatsPrintsmemorystatsofthenode.

nodesuspendsuspendthehostnodeforagiventimeduration

qemu-attachQEMUAttach

qemu-monitor-commandQEMUMonitorCommand

qemu-agent-commandQEMUGuestAgentCommand

sysinfoprintthehypervisorsysinfo

uri打印管理程序典型的URI

version显示版本

Interface(helpkeyword'interface'):

iface-begincreateasnapshotofcurrentinterfacessettings,whichcanbelatercommitted(iface-commit)orrestored(iface-rollback)

iface-bridgecreateabridgedeviceandattachanexistingnetworkdevicetoit

iface-commitcommitchangesmadesinceiface-beginandfreerestorepoint

iface-definedefine(butdon'tstart)aphysicalhostinterfacefromanXMLfile

iface-destroydestroyaphysicalhostinterface(disableit/"if-down")

iface-dumpxmlinterfaceinformationinXML

iface-editeditXMLconfigurationforaphysicalhostinterface

iface-listlistphysicalhostinterfaces

iface-macconvertaninterfacenametointerfaceMACaddress

iface-nameconvertaninterfaceMACaddresstointerfacename

iface-rollbackrollbacktoprevioussavedconfigurationcreatedviaiface-begin

iface-startstartaphysicalhostinterface(enableit/"if-up")

iface-unbridgeundefineabridgedeviceafterdetachingitsslavedevice

iface-undefineundefineaphysicalhostinterface(removeitfromconfiguration)

NetworkFilter(helpkeyword'filter'):

nwfilter-definedefineorupdateanetworkfilterfromanXMLfile

nwfilter-dumpxmlnetworkfilterinformationinXML

nwfilter-editeditXMLconfigurationforanetworkfilter

nwfilter-listlistnetworkfilters

nwfilter-undefineundefineanetworkfilter

Networking(helpkeyword'network'):

net-autostart自动开始网络

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

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

net-destroydestroy(stop)anetwork

net-dumpxmlXML中的网络信息

net-edit为网络编辑XML配置

net-infonetworkinformation

net-list列出网络

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

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

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

net-updateupdatepartsofanexistingnetwork'sconfiguration

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

NodeDevice(helpkeyword'nodedev'):

nodedev-createcreateadevicedefinedbyanXMLfileonthenode

nodedev-destroydestroy(stop)adeviceonthenode

nodedev-detachdetachnodedevicefromitsdevicedriver

nodedev-dumpxmlXML中的节点设备详情

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

nodedev-reattachreattachnodedevicetoitsdevicedriver

nodedev-reset重置节点设备

Secret(helpkeyword'secret'):

secret-definedefineormodifyasecretfromanXMLfile

secret-dumpxmlsecretattributesinXML

secret-get-valueOutputasecretvalue

secret-listlistsecrets

secret-set-valuesetasecretvalue

secret-undefineundefineasecret

Snapshot(helpkeyword'snapshot'):

snapshot-createCreateasnapshotfromXML

snapshot-create-asCreateasnapshotfromasetofargs

snapshot-currentGetorsetthecurrentsnapshot

snapshot-deleteDeleteadomainsnapshot

snapshot-dumpxmlDumpXMLforadomainsnapshot

snapshot-editeditXMLforasnapshot

snapshot-infosnapshotinformation

snapshot-listListsnapshotsforadomain

snapshot-parentGetthenameoftheparentofasnapshot

snapshot-revertRevertadomaintoasnapshot

StoragePool(helpkeyword'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-destroydestroy(stop)apool

pool-dumpxmlXML中的池信息

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

pool-info存储池信息

pool-list列出池

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

pool-refresh刷新池

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

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

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

StorageVolume(helpkeyword'volume'):

vol-clonecloneavolume.

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

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

vol-create-fromcreateavol,usinganothervolumeasinput

vol-delete删除卷

vol-downloaddownloadvolumecontentstoafile

vol-dumpxmlXML中的卷信息

vol-info存储卷信息

vol-keyreturnsthevolumekeyforagivenvolumenameorpath

vol-list列出卷

vol-namereturnsthevolumenameforagivenvolumekeyorpath

vol-pathreturnsthevolumepathforagivenvolumenameorkey

vol-poolreturnsthestoragepoolforagivenvolumekeyorpath

vol-resizeresizeavol

vol-uploaduploadfilecontentstoavolume

vol-wipewipeavol

Virshitself(helpkeyword'virsh'):

cdchangethecurrentdirectory

connect连接(重新连接)到hypervisor

echoechoarguments

exit退出这个非交互式终端

help打印帮助

pwdprintthecurrentdirectory

quit退出这个非交互式终端

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。