北大青鸟小游网:值得大家信赖的游戏下载站!
发布时间:2021-06-30 10:42:22来源:北大青鸟手游网作者:北大青鸟手游网
实验目的:通过一个基础镜像(node.img),里面把各个虚拟机都需要的环境都搭建好,然后基于这个镜像建立起一个个增量镜像,每个增量镜像对应一个虚拟机,虚拟机对镜像中所有的改变都记录在增量镜像里面,基础镜像始终保持不变。
功能:节省磁盘空间,快速复制虚拟机。
环境:
基本镜像文件:node.img 虚拟机ID:node
增量镜像文件:node4.img 虚拟机ID:node4
要求:以基本镜像文件node.omg为基础,创建一个镜像文件node4.img,以此创建一个虚拟机机node4,虚拟机node4的改变将存储于node4.img中。
[root@target kvm_node]#qemu-img create -b node.img -f qcow2 node4.img [root@target kvm_node]# qemu-img info node4.img image: node4.img file format: qcow2 virtual size: 20G (21495808000 bytes) disk size: 33M cluster_size: 65536 backing file: node.img (actual path: node.img)
注:该实验只是针对qcow2格式的镜像文件,未测试raw格式的镜像文件是否可行。
[root@target kvm_node]# cp /etc/libvirt/qemu/node.xml /etc/libvirt/qemu/node4.xml [root@target kvm_node]# vim /etc/libvirt/qemu/node4.xml <domain type=’kvm’> <name>node4</name> #node4的虚拟机名,须修改,否则与基本虚拟机冲突 <uuid>4b7e91eb-6521-c2c6-cc64-c1ba72707fe4</uuid> #node4的UUID,必须修改,否则与基本虚拟机冲突 <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu cpuset=’0-1′>2</vcpu> <os> <type arch=’x86_64′ machine=’rhel5.4.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=’qcow2’/> <source file=’/virhost/kvm_node/node4.img’/> #将原指向/virhost/kvm_node/node.img改为node4.img <target dev=’vda’ bus=’virtio’/> <address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x05′ function=’0x0’/> </disk> <interface type=’bridge’> <mac address=’54:52:00:69:d5:f4’/> #修改网卡MAC,防止冲突 <source bridge=’br0’/> <model type=’virtio’/> <address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x03′ function=’0x0’/> </interface> <interface type=’bridge’> <mac address=’54:52:00:69:d5:e4’/> #修改网卡MAC,防止冲突 <source bridge=’br0’/> <model type=’virtio’/> <address type=’pci’ domain=’0x0000′ bus=’0x00′ slot=’0x04′ function=’0x0’/> </interface> <serial type=’pty’> <target port=’0’/> </serial> <console type=’pty’> <target type=’serial’ port=’0’/> </console> <input type=’mouse’ bus=’ps2’/> <graphics type=’vnc’ port=’5904′ autoport=’no’ listen=’0.0.0.0′ passwd=’xiaobai’> <listen type=’address’ address=’0.0.0.0’/> </graphics> <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>
[root@target kvm_node]#virsh define /etc/libvirt/qemu/node4.xml [root@target kvm_node]#virsh start node4
[root@target kvm_node]# du -h node.img
6.3G node.img
[root@target kvm_node]# du -h node4.img
33M node4.img
[root@node4 ~]# dd if=/dev/zero of=test bs=1M count=200 #在虚拟机node4上增量200M大小文件 200+0 records in 200+0 records out 209715200 bytes (210 MB) copied, 1.00361 seconds, 209 MB/s [root@target kvm_node]# du -h node.img #基本镜像文件node.img大小未变
6.3G node.img
[root@target kvm_node]# du -h node.img #增量镜像文件node4.img增加200M了 234M node4.img
和平精英通讯塔是什么 和平精英通讯塔玩法详细解析
跑跑卡丁车手游制霸赛场挑战任务全攻略
神雕侠侣2手游氪金玩家消费指南
王牌战士幽灵实战技巧讲解
王者荣耀王者模拟战即将上线 王者模拟战玩法介绍
王牌战士团战如何切入详细讲解
第五人格先知天赋怎么加点
崩坏3精英工坊新加入了什么武器圣痕 精英工坊新武器圣痕一览
古今江湖童姥牌组搭配使用技巧攻略
坠落星界
其它游戏
炽姬无双
角色扮演
王者荣耀
角色扮演
和平精英
枪战射击
邪恶疯人院
休闲益智
神雕侠侣2
角色扮演
一刀传世
角色扮演
九州天空城3D
角色扮演
斗罗大陆手游
角色扮演