KVM配置之(3)- 克隆
生活随笔
收集整理的這篇文章主要介紹了
KVM配置之(3)- 克隆
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
?1.KVM主機虛擬機直接克隆
virt-clone?-o?module-IT?-n?lb-test2?-f?/data/vm/vmfiles/lb-tes2.img 說明:以modeule-IT做為源,克隆module-IT以及module-IT.img,并創(chuàng)建名稱為lb-test2,鏡像為-f?/data/vm/vmfiles/lb-tes2.img啟動虛擬機配置主機名,IP地址等
2.通過復(fù)制配置文件與磁盤文件的虛擬機克隆(適用于異機的靜態(tài)遷移)
(1)確認(rèn)源虛擬機:
[root@server?~]#?virsh?list?--allId????Name???????????????????????????State ----------------------------------------------------1?????test1??????????????????????????running2?????lu-test1???????????????????????running3?????module-IT-oa-test??????????????running4?????test2-IT???????????????????????running5?????IT-clone-TEST??????????????????running9?????LB_test1???????????????????????running10????lb-test2???????????????????????running-?????clean??????????????????????????shut?off-?????module-IT??????????????????????shut?off-?????Winprinter?????????????????????shut?off [root@server?~]#?virsh?shutdown?LB_test1 Domain?lb-test2?is?being?shutdown(2).導(dǎo)入KVM虛擬機配置文件
[root@server?~]#?virsh?dumpxml?LB_test1?>/etc/libvirt/qemu/LB_test2.xml(3).復(fù)制KVM虛擬機磁盤文件
[root@server?vmfiles]#?cp?binzai.qcow2?binzai-test2.qcow2(4).直接編輯配置文件
[root@server?vmfiles]#?vim?/etc/libvirt/qemu/LB_test2.xml? <domain?type='kvm'><name>LB_test1</name>??#由字母和數(shù)字組成,不能包含空格<uuid>9ea6f52f-1a18-5a8a-7920-611efa92c8c9</uuid>??#由命令行工具uuidgen生成<memory?unit='KiB'>1048576</memory>???#在不reboot?guest情況下,guset可以使用的最大內(nèi)存,以KB為單位<currentMemory?unit='KiB'>1048576</currentMemory>??#guest啟動時內(nèi)存,可以通過virsh?setmem來調(diào)整,但是不能大于最大可使用內(nèi)存<vcpu?placement='static'>1</vcpu>??#分配的虛擬CPU<os><type?arch='x86_64'?machine='rhel6.4.0'>hvm</type>??#架構(gòu):64位,machine:宿主機的操作系統(tǒng)<boot?dev='hd'/>??#指定啟動設(shè)備,可以重復(fù)多行,指定不同的值,作為一個啟動設(shè)備列表</os><features>???#處理器特性<acpi/><apic/><pae/></features><clock?offset='utc'/>??#(utc該為localtime)Kvm虛擬機采用utc時間,需要先修改配置文件使用KVM虛擬機的時間與虛擬主機同步。<on_poweroff>destroy</on_poweroff>?#停止虛擬機,相當(dāng)于關(guān)閉電源,Kill?kvm進(jìn)程也是一樣<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='qcow2'?cache='none'/><source?file='/var/lib/libvirt/p_w_picpaths/binzai.qcow2'/>???#使用qumu-img命令創(chuàng)建該文件,kvm?p_w_picpath的默認(rèn)目錄為:。。。。。<target?dev='vda'?bus='virtio'/><address?type='pci'?domain='0x0000'?bus='0x00'?slot='0x05'?function='0x0'/></disk>???? #采用普通的驅(qū)動,即硬盤和網(wǎng)卡都采用默認(rèn)配置情況下,硬盤為ide模式,采用virtio驅(qū)動,硬盤工作在SCSI模式下<controller?type='usb'?index='0'><address?type='pci'?domain='0x0000'?bus='0x00'?slot='0x01'?function='0x2'/></controller><interface?type='bridge'>??#網(wǎng)卡<mac?address='52:54:00:93:45:fe'/><source?bridge='br0'/><model?type='virtio'/><address?type='pci'?domain='0x0000'?bus='0x00'?slot='0x03'?function='0x0'/></interface><serial?type='pty'><target?port='0'/></serial><console?type='pty'><target?type='serial'?port='0'/></console><input?type='tablet'?bus='usb'/><input?type='mouse'?bus='ps2'/><graphics?type='vnc'?port='-1'?autoport='yes'/><sound?model='ich6'><address?type='pci'?domain='0x0000'?bus='0x00'?slot='0x04'?function='0x0'/></sound><video><model?type='cirrus'?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='0x06'?function='0x0'/></memballoon></devices> </domain>(5).定義新虛擬機配置文件
[root@server?vmfiles]#?virsh?define?/etc/libvirt/qemu/LB_test2.xml(6).啟動虛擬
virsh?start?LB_test2?
轉(zhuǎn)載于:https://blog.51cto.com/binbinwudi8688/1353171
總結(jié)
以上是生活随笔為你收集整理的KVM配置之(3)- 克隆的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Oracle中用户解锁
- 下一篇: 编码过程中的问题总结