本篇內(nèi)容介紹了“怎么在KVM虛擬機(jī)中的配置xml”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
在RHEL6中,用于從磁盤(pán)啟動(dòng)的XML文件
這里以dcs01.xml為例:
<domain type='kvm'> <name>dcs01</name> <uuid>e5fff551-bbe1-e748-c8e4-8ecb3bffb902</uuid> <memory>1048576</memory> <currentMemory>1048576</currentMemory> <vcpu>1</vcpu> <os> <type arch='x86_64' machine='rhel6.0.0'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='localtime'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/home/kvm/images/dcs01.img'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' unit='0'/> </disk> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='52:54:00:ad:75:98'/> <source bridge='br0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <video> <model type='vga' vram='9216' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> </domain>
注釋如下:
1、kvm guest 定義開(kāi)始
<domain type='kvm'>
2、guest的short name。由字母和數(shù)字組成,不能包含空格
<name>dcs01</name>
3、uuid,由命令行工具 uuidgen生成。
<uuid>e5fff551-bbe1-e748-c8e4-8ecb3bffb902</uuid>
4、在不reboot guest的情況下,guset可以使用的大內(nèi)存,以KB為單位
<memory>1048576</memory>
5、guest啟動(dòng)時(shí)內(nèi)存,可以通過(guò)virsh setmem來(lái)調(diào)整內(nèi)存,但不能大于大可使用內(nèi)存。
<currentMemory>1048576</currentMemory>
6、分配的虛擬cpu
<vcpu>1</vcpu>
7、有關(guān)OS
架構(gòu):i686、x86_64
machine:宿主機(jī)的操作系統(tǒng)
boot:指定啟動(dòng)設(shè)備,可以重復(fù)多行,指定不同的值,作為一個(gè)啟動(dòng)設(shè)備列表。
<os> <type arch='x86_64' machine='rhel6.0.0'>hvm</type> <boot dev='hd'/> </os>
8、處理器特性
<features> <acpi/> <apic/> <pae/> </features>
9、時(shí)鐘。使用本地時(shí)間:localtime
<clock offset='localtime'/>
10、定義了在kvm環(huán)境中power off,reboot,或crash時(shí)的默認(rèn)的動(dòng)作分別為destroy和restart。其他允許的動(dòng)作包括: preserve,rename-restart.。
destroy:停止該虛擬機(jī)。相當(dāng)于關(guān)閉電源。
restart重啟虛擬機(jī)。
<on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash>
11、設(shè)備定義開(kāi)始
<devices>
12、模擬元素,此處寫(xiě)法用于kvm的guest
<emulator>/usr/libexec/qemu-kvm</emulator>
13、用于kvm存儲(chǔ)的文件。在這個(gè)例子中,在guest中顯示為IDE設(shè)備。
使用qemu-img命令創(chuàng)建該文件,kvm image的默認(rèn)目錄為:/var/lib/libvirt/images/
<disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/home/kvm/images/dcs01.img'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' unit='0'/> </disk>
補(bǔ)充:可以定義多個(gè)磁盤(pán)。
使用virtio:
采用普通的驅(qū)動(dòng),即硬盤(pán)和網(wǎng)卡都采用默認(rèn)配置情況下,網(wǎng)卡工作在 模擬的rtl 8139 網(wǎng)卡下,速度為100M 全雙工。采用 virtio 驅(qū)動(dòng)后,網(wǎng)卡工作在 1000M 的模式下。
采用普通的驅(qū)動(dòng),即硬盤(pán)和網(wǎng)卡都采用默認(rèn)配置情況下,硬盤(pán)是 ide 模式。采用 virtio 驅(qū)動(dòng)后,硬盤(pán)工作是SCSI模式下。
<disk type='file' device='disk'> <driver name='qemu' type='raw'/> <source file='/usr/local/kvm/vmsample/disk.os'/> <target dev='vda' bus='virtio'/> </disk>
CD-ROM device:
<disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' unit='0'/> </disk>
14、使用網(wǎng)橋類型。確保每個(gè)kvm guest的mac地址唯一。將創(chuàng)建tun設(shè)備,名稱為vnetx(x為0,1,2...)
<interface type='bridge'> <mac address='52:54:00:ad:75:98'/> <source bridge='br0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>
補(bǔ)充:
使用默認(rèn)的虛擬網(wǎng)絡(luò)代替網(wǎng)橋,即guest為NAT模式。也可以省略mac地址元素,這樣將自動(dòng)生成mac地址。
<interface type='network'> <source network='default'/> <mac address="3B:6E:01:69:3A:11"/> </interface>
默認(rèn)分配192.168.122.x/24的地址,也可以手動(dòng)指定。網(wǎng)關(guān)為192.168.122.1
使用virtio:
采用普通的驅(qū)動(dòng),即硬盤(pán)和網(wǎng)卡都采用默認(rèn)配置情況下,網(wǎng)卡工作在 模擬的rtl 8139 網(wǎng)卡下,速度為100M 全雙工。采用 virtio 驅(qū)動(dòng)后,網(wǎng)卡工作在 1000M 的模式下。
<interface type='bridge'> <source bridge='br1'/> <model type='virtio' /> </interface>
15、輸入設(shè)備
<input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/>
16、定義與guset交互的圖形設(shè)備。在這個(gè)例子中,使用vnc協(xié)議。listen的地址為host的地址。prot為-1,表示自動(dòng)分配端口號(hào),通過(guò)以下的命令查找端口號(hào):
virsh vncdisplay <KVM Guest Name>
這里未設(shè)置
<graphics type='vnc' port='-1' autoport='yes'/>
17、設(shè)備定義結(jié)束
</devices>
18、KVM定義結(jié)束
</domain>
centos_x86_6.4
b9dcdd92-9b9b-14d6-3938-1982a9746a12
2097152
2097152
1
hvm
destroy
restart
restart
/bin/qemu-kvm
<disk type='file' device='disk'> <driver name='qemu' type='qcow2'/>
#目的鏡像路徑 在這個(gè)例子中,在guest中顯示為IDE設(shè)備。
<source file='/home/template_make/centos_x86_6.4.img'> <seclabel model='selinux' relabel='no'/> </source> <target dev='hda' bus='ide'/> <alias name='ide0-0-0'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/home/template_make/CentOS-6.4-x86_64-bin-DVD1.iso'/> <target dev='hdc' bus='ide'/> <readonly/> <alias name='ide0-1-0'/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <alias name='usb0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='ide' index='0'> <alias name='ide0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'>
#虛擬機(jī)網(wǎng)絡(luò)連接方式
<mac address='52:54:00:78:f9:5a'/> <source bridge='br0'/> <target dev='vnet27'/>
## 使用virtio: 采用普通的驅(qū)動(dòng),即硬盤(pán)和網(wǎng)卡都采用默認(rèn)配置情況下,硬盤(pán)是 ide 模式, 而網(wǎng)卡工作在 模擬的rtl 8139 網(wǎng)卡下,速度為100M 全雙工。 采用 virtio 驅(qū)動(dòng)后,網(wǎng)卡工作在 1000M 的模式下,硬盤(pán)工作是SCSI模式下
<model type='virtio'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <input type='mouse' bus='ps2'/>
#vnc方式登錄,端口號(hào)自動(dòng)分配 可以通過(guò)virsh vncdisplay來(lái)查詢[vncdisplay domainId]
<graphics type='vnc' port='5915' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <video> <model type='cirrus' vram='9216' heads='1'/> <alias name='video0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <alias name='balloon0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </memballoon> </devices> <seclabel type='dynamic' model='selinux' relabel='yes'> <label>unconfined_u:system_r:svirt_t:s0:c362,c396</label> <imagelabel>unconfined_u:object_r:svirt_image_t:s0:c362,c396</imagelabel> </seclabel></domain>
“怎么在KVM虛擬機(jī)中的配置xml”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
當(dāng)前題目:怎么在KVM虛擬機(jī)中的配置xml-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)URL:http://aaarwkj.com/article26/cdhhcg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、做網(wǎng)站、搜索引擎優(yōu)化、面包屑導(dǎo)航、品牌網(wǎng)站制作、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容