KVM虛擬機的管理主要是通過virsh命令對虛擬機進行管理。
站在用戶的角度思考問題,與客戶深入溝通,找到蘇尼特左網(wǎng)站設(shè)計與蘇尼特左網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、外貿(mào)營銷網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、國際域名空間、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋蘇尼特左地區(qū)。
(1) KVM虛擬機默認(rèn)配置文件位置: /etc/libvirt/qemu/
autostart目錄是配置kvm虛擬機開機自啟動目錄。
(2) virsh命令幫助
# virsh -help
或直接virsh命令和,再執(zhí)行子命令。如下所示。
# virsh
歡迎使用 virsh,虛擬化的交互式終端。
輸入:'help' 來獲得命令的幫助信息
'quit' 退出
virsh # help
……
(3) 查看kvm虛擬機狀態(tài)
# virsh list --all
# virsh start kvm008
(1) 關(guān)機
默認(rèn)情況下virsh工具不能對linux虛擬機進行關(guān)機操作,linux操作系統(tǒng)需要開啟與啟動acpid服務(wù)。
在安裝KVM linux虛擬機之前必須配置此服務(wù)。
# chkconfig acpid on
# service acpid restart
virsh關(guān)機
# virsh shutdown kvm008
(2) 強制關(guān)閉電源
# virsh destroy kvm08
# virsh create /etc/libvirt/qemu/kvm008.xml
# virsh autostart kvm008
autostart目錄是kvm虛擬機開機自啟動目錄,可以看到該目錄中有KVM配置文件鏈接。
虛擬機要關(guān)機 不然會操作 失敗哦~
# virsh dumpxml /etc/libvirt/qemu/kvm008 > /etc/libvirt/qemu/kvm.xml
KVM虛擬機配置文件可以通過這種方式進行備份。
(1) 刪除kvm虛擬機
# virsh undefine kvm008
說明:該命令只是刪除 kvm008的配置文件,并不刪除虛擬磁盤文件。如下圖所示。
(2) 重新定義虛擬機配置文件
通過導(dǎo)出備份的配置文件恢復(fù)原KVM虛擬機的定義,并重新定義虛擬機。
# mv /etc/libvirt/qemu/kvm.xml /etc/libvirt/qemu/kvm008.xml
# virsh define /etc/libvirt/qemu/kvm008.xml
# virsh edit kvm08
virsh edit將調(diào)用vi命令編輯/etc/libvirt/qemu/kvm08.xml配置文件。也可以直接通過vi命令進行編輯,修改,保存。
可以但不建議直接通過vi編輯。
虛擬機要開機 才可以
# virsh console kvm08
(1) 掛起服務(wù)器
# virsh suspend kvm08
(2) 恢復(fù)服務(wù)器
# virsh resume kvm08
virsh命令豐富??梢詧?zhí)行各種維護任務(wù),本文只是從維護與管理的角度例舉了常用的命令,為該命令的使用提供一個思路。
virsh 命令:
virsh # help
Grouped commands:
Domain Management (help keyword 'domain'):
attach-device 從一個XML文件附加裝置
attach-disk 附加磁盤設(shè)備
attach-interface 獲得網(wǎng)絡(luò)界面
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 文件創(chuàng)建一個域
define 從一個 XML 文件定義(但不開始)一個域
desc show or set domain's description or title
destroy destroy (stop) a domain
detach-device 從一個 XML 文件分離設(shè)備
detach-disk 分離磁盤設(shè)備
detach-interface 分離網(wǎng)絡(luò)界面
domdisplay domain display connection URI
domhostname print the domain's hostname
domid 把一個域名或 UUID 轉(zhuǎn)換為域 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 轉(zhuǎn)換為域名
dompmsuspend suspend a domain gracefully using power management functions
dompmwakeup wakeup a domain from pmsuspended state
domuuid 把一個域名或 id 轉(zhuǎn)換為域 UUID
domxml-from-native Convert native config to domain XML
domxml-to-native Convert domain XML to native config
dump 把一個域的內(nèi)核 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 從一個存在一個文件中的狀態(tài)恢復(fù)一個域
resume 重新恢復(fù)一個域
save 把一個域的狀態(tài)保存到一個文件
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 顯示/設(shè)置日程安排變量
screenshot take a screenshot of a current domain console and store it into a file
setmaxmem 改變最大內(nèi)存限制值
setmem 改變內(nèi)存的分配
setvcpus 改變虛擬 CPU 的號
shutdown 關(guān)閉一個域
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 獲得域設(shè)備塊狀態(tài)
domcontrol domain control interface state
domif-getlink get link state of a virtual interface
domiflist list all domain virtual interfaces
domifstat 獲得域網(wǎng)絡(luò)接口狀態(tài)
dominfo 域信息
dommemstat get memory statistics for a domain
domstate 域狀態(tài)
list 列出域
Host and Hypervisor (help keyword 'host'):
capabilities 性能
freecell NUMA可用內(nèi)存
hostname 打印管理程序主機名
node-memory-tune Get or set node memory parameters
nodecpustats Prints cpu stats of the node.
nodeinfo 節(jié)點信息
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 自動開始網(wǎng)絡(luò)
net-create 從一個 XML 文件創(chuàng)建一個網(wǎng)絡(luò)
net-define 從一個 XML 文件定義(但不開始)一個網(wǎng)絡(luò)
net-destroy destroy (stop) a network
net-dumpxml XML 中的網(wǎng)絡(luò)信息
net-edit 為網(wǎng)絡(luò)編輯 XML 配置
net-info network information
net-list 列出網(wǎng)絡(luò)
net-name 把一個網(wǎng)絡(luò)UUID 轉(zhuǎn)換為網(wǎng)絡(luò)名
net-start 開始一個(以前定義的)不活躍的網(wǎng)絡(luò)
net-undefine 取消定義一個非活躍的網(wǎng)絡(luò)
net-update update parts of an existing network's configuration
net-uuid 把一個網(wǎng)絡(luò)名轉(zhuǎn)換為網(wǎng)絡(luò)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 中的節(jié)點設(shè)備詳情
nodedev-list 這臺主機中中的枚舉設(shè)備
nodedev-reattach reattach node device to its device driver
nodedev-reset 重置節(jié)點設(shè)備
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 發(fā)現(xiàn)潛在存儲池源
pool-autostart 自動啟動某個池
pool-build 建立池
pool-create-as 從一組變量中創(chuàng)建一個池
pool-create 從一個 XML 文件中創(chuàng)建一個池
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 轉(zhuǎn)換為池名稱
pool-refresh 刷新池
pool-start 啟動一個(以前定義的)非活躍的池
pool-undefine 取消定義一個不活躍的池
pool-uuid 把一個池名稱轉(zhuǎn)換為池 UUID
Storage Volume (help keyword 'volume'):
vol-clone clone a volume.
vol-create-as 從一組變量中創(chuàng)建卷
vol-create 從一個 XML 文件創(chuàng)建一個卷
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 退出這個非交互式終端
新聞名稱:3、kvm虛擬機日常管理與配置
網(wǎng)站地址:http://aaarwkj.com/article10/igiogo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗、網(wǎng)站制作、App設(shè)計、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站排名、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)