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虛擬機狀態
#?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虚拟机日常管理与配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 程序包android.support.a
- 下一篇: 关闭linux系统中读写页缓存,Linu