实验四 混合虚拟化_第1页
实验四 混合虚拟化_第2页
实验四 混合虚拟化_第3页
实验四 混合虚拟化_第4页
实验四 混合虚拟化_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实验四混合虚拟机化之KVM一、实验目的掌握混合虚拟化的基本概念;了解KVM的相关概念;掌握基于KVM的虚拟机创建和管理。二、实验内容KVM, Kernel-based Virtual Machine,基于内核的虚拟机,它是面向Linux系统的开源 虚拟化解决方案,KVM需要使用Intel VT或AMD-V等硬件虚拟化扩展提供虚拟化功能。 安装KVM时,通过加载基于Intel的kvm-intel.ko或基于AMD的kvm-amd.ko内核模块将 其转换为Hypervisor。KVM允许我们安装和运行(基于 Windows和Linux的)多个虚拟机,并通过virt-manager图形用户界面或vi

2、rt-install & virsh cli命令创建和管理基于KVM的虚拟机。1,验证Linux系统是否支持硬件虚拟化。egrep -c (vmxlsvm) /proc/cpuinforootgubuntu:/horne/nylff egrep -c (vmx | svn)1 /proc/cpuinf&如果输出大于0,则表示系统支持硬件虚拟化。否则请重启系统,然后转到BIOS设置中启用VT技术;如果是虚拟机,请做以下设置:E:备密Ip与摘要2GB1也耍1晅玺(SCSI)20 GD CD/DVC 彻TA)判如仲网系话国葬NATQusb苴利盖作在中声卡判颔吕打印机仁在匚1显示器件遂.If每个处理黜

3、内核数里g 1 处+里器&核总政:觎化引擎由虚捻化 mtelVT-X/EPT 或 AMD-V/RVK10明虚损化CPU性能计数罟【山由虚抵化】口51(1)内存宜理单元)Q)确定你的服务器是否能够运行硬件加速的KVM虚拟机:切换至root账户:sudo suapt install cpu-checkernylnyl-ubuntul8E)4:sudo apt Install cpu -checker sudo password for nyl:Reading package lists-,. DoneBuilding dependency treeReading state infornatton

4、* * DoneThe fotluutftg adcJtttonal packages wtLl be tristalleci i nsr- toolsThe following new packages will be tnEtalled:cpu-checker nsr-toolsC upgraded, 2 newly installedp 9 to renove and 137 not upgraded,Need to get IS6 kB of archives +After this operation, 62.5 kB of adelttional disk space will t

5、e used*o you want to conttnue? v/n yCet:1 http:/cn archive*ubuntu*con7utunt!J btontc/nain and64 msrtools 钉nd64 1,3-2butld1 9,7通 BCet:2 http:/cn archive*ubuntu*c&n7utuntij btontc/riain and64 cpu-checker dmd64 0.7-0UbUPtU7 6852 BFetched 16*6 kB in 4s (4,441 B/s)Selecting previously unselected package

6、msr-tools,(Reading database -162500 files and directories currently installed*)Preparing to unpack * * /nr-tool_l 3-2tuildl_and6 - deb .unpacking msr-tools (1.3-2butldl)Selecting previously unselected package cpu-checker-Prepartng to unpack . . . /cpu-check&r_9.7-Subjntdeb .Unpacking cpu-checker 70u

7、buntu7).Setting up nsr-tools (1,3-2buildl),.Getting up cpu-checker (e.7-Oubuntu?)-Processing triggers for nan-dt (2*8,3-2jtuntu0* 1).输入:kvm-oknylnyl-Ubuntul8B4ikvm-ok INFO: /dev/kvFi existsnylnyl-uEuntul8D4|KVM acceleration carb be used安装KVM及其所需的软件包apt updateapt install qemu qemu-kvm libvirt-bin bri

8、dge-utils virt-managerKVM安装完成。启动并启用libvirtd服务。在Ubuntu 18.04 LTS中安装qemu和libvirtd软件包时,将会自动启动并启用l ibvirtd服务。如果libvirtd服务没按预期启动或启用,请执行以下命令:sudo service libvirtd startsudo update-rc.d libvirtd enable将libvirtd添加自启动sudo systemctl start libvirtd.servicesudo systemctl enable libvirtd.service使用下面的命令验证libvirtd

9、服务的状态:service libvirtd statusylnyl-UbntulB04:-$ service libvirtd status libvi rtd.serwice - Virtualization daenonLoaded: Loaded (/lit/systend/aysten/libvirtcl.service; enabled; vendor presetActive: active (running) since Hon 2G19-04-&1 11:迎:59 CST; 3h 37nin agoDace: nan:ltbtrtd(8)https:/libvirt* org

10、Main PID; 50502 (libvirtd)Tasks! 19 (ItHtt: 32768;CCroup: /system*slice/libvirtd*service5S50Z /usr/sbln/ttbvtrTd51187 /usr/Ebtn/dnsnaEq -conf-file=/var/lib/libvirt/dnsmasq/defau*51180 /usr/sbin/dnsnasq conf-file=/var/lib/libvirt/dnsndsq/defau月月月月月月月月月月44 4 444444411110 0 0 01111 0 0 0 01111111111111

11、1111133:59 39; 07 39:0739:07 39: 07 39: &739:07 39:07 39:0739:07nyl-UbjntulBEM nyl-UbuntulBB4-Ubuntu 1804 nyl Ut)jntuL304 nyl-ubuntu 18段4 nyl-lJbjntulBB4 nyl-Ubuntul3B4 -Libiintul804nyl-UbuntulBB4 nyl-Ubjntulft4s/stendl: Started Virtualization daemon* dnsndsq511B7: startedversion 2.79 cachesizie dri

12、Eni3qS1187: compite time options: IPv6 CNU-g drisnd3q-dhcp51LB7: DHCP, IP range 192.16S-122* dnsndsq-dhcp5US7: dhcp, sockets bound exclusl dnsniaq511B7 dnsnasq511B7 driEni3q511B7 dnsnasqfSllB?reading /etc/resolv,confusing neneserver 1如*。.0.53书53 read /etc/hosts - 7 addresses read /varlib/libvirt/dns

13、nasqfdednsnasq-dhcp51187; read /varflib/libvirt/dnsma1-22/22 (tMD)4,为KVM虚拟机配置网桥KVM安装完成后,首先需要进行网络设定,KVM支持四种网络模式:桥接模式NAT模式用户网络模式直接分配设备模式这里我们采用交接模式。桥接(Bridge)模式:在桥接模式下,宿主机和虚拟机共享同一个物理网络设备,虚拟机中的网卡和物理机中 的网卡是平行关系,所以虚拟机可以直接接入外部网络,虚拟机和宿主机有平级的IP。原本宿主机是通过网卡eth0连接外部网络的,网桥模式会新创建一个网桥br0,接管eth0来连接外部网络,然后将宿主机和虚拟机的网

14、卡eth0都绑定到网桥上。使用桥接模式需要进行以下操作:编辑/etc/network/interfaces,增加如下内容auto br0iface br0 inet dhcp #网桥使用DHCP模式,从DHCP服务器获取IPbridge_ports ens33 #网卡名称,网桥创建前连接外部的网卡,可通过ifconfig命令查 看,有IP地址的就是那张网卡。nyldnyl-UbuntU1604;ifconfigenE33:,BROADCAST,RUMNIMG,MJLTICAET mtJ 15海inet 1921(58-201.132 netnask 255+255+255+0 broadcas

15、t 19Z+168+201+255 inet6 fe8&:7952:9589:a409:f72d preflxlen 64 scopeid ex20 ether OS;19:3f:e7 txqueuelen 100S (Ethernet PX packets 19S&738 bytes 2813116&9 (2.8 GB) RK errors 0 d叩ped 0 overruns 0 frane 0 TK packets 320966 bytes 26S03612 (26,0 MB)TK errors 0 dropped 9 overruns 0 carrier G collisions 0l

16、o; fLags73 ntu 65536tnet 127.O.0.1 netmask inet6 :1 prefixlen 128 scopeid 0 xlOloop txqueuelen 1909 (Local Loopback) RX packets 613 bytes 54821 (54.8 KB) RK errors 0 dropped 3 overruns a frame 0 TK packets 613 bytes 54821 (54.8 KB) tk errors Q dropped a overruns a carrier 0 colLtstons avtrbra: flags

17、=4099 ntu isaeinet netnask 2552552550 broadcast 192,168.122.55 ether 52:541 oo:ac:4a14c txqueueleri looe (Ethernet)FtX packets 6 bytes 0 (0 r 9 B)RK errors 0 dropped B overruns B frane QIX packets 0 bytes 0 (S r 9 B) TK errors 0 dropped D overruns 0 carrier e collisions 0bridge_stp on #避免数据链路出现死循环 b

18、ridge_fd 0 #将转发延迟设置为0 toterfdces(5) file used by tfup(8) and tfdawn(8) auto lo iface lo inet loopback auro broiface brO tnet dhcp bridgeports ens33 br tdge_stp or bridgefd 0M/etc/netwark/interfacesr reedonl S lines, 15& characters接下来需要重启networking服务(如果是通过SSH连接到宿主机上的,这一步会导致 网络中断,如果出现问题可能导致连不上宿主机,最好在宿

19、主机上直接操作)systemctl restart networking.service使用ifconfig命令查看IP是否从ens33 (网桥创建前的网卡)变到了 br0上,如果没有 变化则需要重启。(最好重启一下)。nyLny1-Ubuntu1804:ifconfigbrOi Flag写=41S*UP,邸QMCA5T,RUNNING,MULTICASTntu 15能inet 192.163,201.132 netmask 255.255*255.0 broadcast 192*163*201.255 tnetc fe80:23c:29ff:fel9:3fe? prefixlen &4 sc

20、opetd 0 x20 ether &6;0c;29:19:3f:e7 txueuelen 10。 (Ethernet) RX packets 125 bytes 258533 (298*5 KB) RX errors 0 dropped 0 overruns 0 frame & TX packets 199 bytes 芝5848 (25.8 KB)TX errors $ dropped 。 overruns 。 carrier 。 collisions 。ens33: flogs=4163 ntu 1500 ether &eI0c:29:19:3f:e7 txqueuelen 1090 (

21、Ethernet) RX packets 265 bytes 30783 (S07.a KB) RX errors 0 dropped 0 overruns 0 frone 0 TX packets 306 bytes 32852 (32.E KB) TX errors a dropped e overruns 0 carrier e collisions 0如果宿主机ip已经成功变到网桥上,并且宿主机能正常上网而虚拟机获取不到ip,可 能是ufw (Uncomplicated Firewall, Ubuntu防火墙)没有允许ip转发导致的,编辑/etc /default/ufw 允许 ip

22、转发。DEFAULT_FORWARD_POLICY=ACCEPT”l/etc/default/ufw#Set to yes to mppLy rules to support IPv6 (no means only IPv6 on loopbackaccepted)- You will need to 1dtseble1 ard then enable the firewall forthe changes to take affect-iPV6=essetthe defaultInput policy to accept, drop, nr reject.PleasenotethatIfyo

23、uchange thisyou will nostlikely want to adjust yourrules*DEFAUL7_INPUT_P0LICY=DR0P,F。setthe defaultoutput policyto accept, drop, or reject.PleasenatethatIfj/ouchange thisyou will mostlikelj/ want to adjust yourrules*DEFAULT_OUTPin_POLM = ACCEPT”it- Set the default forward policy to ACCEPT, DROP or R

24、EJECT* Plea5e note thatif you change this you will most likely want to adjust your rules DEFAULT_FORNARD_POLICYAC CE P T “L一 - _Set the default application policy to ACCEPT, DROP, REJECT or SKIP* Pleaseff note that setting this to ACCEPT may be a security rtsk. See nan ufw1 fordetailsDEFAULT_APPLICA

25、TION_FQLKY=SKIPu By default, ufw only touches its own chains. set thts to 1 yes to have ufwmanage the built-in chains too, Warning: setting this to 1 yes1 will break /etc/default/urw 45 lines, 1756 characters重启ufw服务让设置生效 systemctl restart ufw.service5,安装虚拟机利用WinSCP等软件将系统镜像文件放到登录用户的家目录中。St backup -H

26、132 - W!h5CPX尊主阳Vf25i欢IR gfg 剑响 法点回 远囹 购世)SB史京间由| 仔 K圜 魏好1 丁福骚斯认 10192,16645.1132 瑙袖手, w,Di Randam- W 回 *,STtU $ ;nyl-严回J :a 0 击 EkWfKrt pJ2rMW-WT-X呷jurors2D17/5/16 1111疝Pdalk2G1/a/25伯打学fWiff-KT-Xtjpu-i_.B7-cnZD19.f7/Zl Z1!0e5EPiaures2ni,a5 laarsczrww-rif-MaDlWZfl Z3X彖如也201,|15 1QJ7:C2rww-rtf-M哪尖治习月

27、刑珂碇杵2D10.!27 21:2:51_l DawrJcBdi扪耕明5 1QJ7:C2rMvr-w-Kw实.翰一月蓟购网2D19i?5_i OocumeFti网HW3 用 5 1ftJ7:C2rwir-wr-xwft E&iduNrtdiskSJJ r?30.217.2O10/V25 9i5m2iCSMktop2&1W35 1&37tO2RW-iflr-K哪狂 GPi:haiu5js-瓦曲曲2D19/1/3 哈:如C漕时纠1,或中47C,762Bi2。姑削25 220231IW-riF-的1rKKSrftup_2.7.52je-xt13 311 .文帷MEZD1 B.H.i25 IQJ7I5

28、1hdlcuUi.gEu wmMUgiE 211213ri-rf-仰1FERVMi_,rtW_WillN_2G45Jl.fl.42叫aaiWEO 跄第3 4AMplM.dMklOp。K:3iw-rf-哪Lagcu_pinyin_03E.BXv43.2S5 .M30:11413的三|3. J.玄她日.圮技:二亍尸引日机区ji侦2UJ6Q.201 %石浏2ftnrarjA4-55&s.ewc-3r276 曲2019./21 20U:成31 KBMaagh Word.ZDlSfl/ZS H任昭壬16.3.2山成路心*.瞄部 103/25 !&37;CMrmcr-r-r 呼AurardStt5?O日曰

29、li;2M9J才巧诵比G2r-MT-s 时CpUZ 1.E7-CrtJ快ZfMI9j/Z5 IOJIFiKgf 叫mdltiQpA M叫斜1日 IDO3H1 31史“目 IaOD6ZDID/Z/ZS Ha37;ft2叫Sffei*H& itrt::口.如够2019/25 lft.J7;Wrmfr-?ir-K 呼一腰 J&BPtt3JttH_2tH9/9;25 IftSZiMrwwr-wr-r 呷fa Oidulldk 572ees217.度巨理序网1 狗25 1Q27:(&2E5” 叫|jGPhdUftfi-3La3.Q.-araQ.43 K:3 文件EME La - 0 4-TGZ. 2Dl

30、Zj75 Z202JIrrt-r-f- 咛irtup 75 您1513 81 立林EXEm河5tahelktar-gE13 E 2019JSJ?5 1;5l5rw-rr- 呼EE性州犯-衲UJWI时-犯西虹炸蛀蜘.,5ttEXE30-7/9/29- ath5i5uQJ ejomplM.EiMklKip9 0;31 KS Misai Word _.值的.女1.B-5 QB / 2.19 GB. 1/14rm gm me. n-/niclrtk亩E FTP-33QC4:C3nylubuntu:*$ pwd/hone/nylnylsubwntu:*5 IsDesktop examples. desk

31、top iiy 5ql,t3r,gz TenplatesDocuments hello nt.irqz Pictures ubuntu - lS*04 + 2 - desktop-andS AsdDsrnl。可姑 MusicPublicnyLubuntut$ |利用图形化工具来部署虚拟机。Virtual Machine Manager 启动命令:virt-managernylnylUbuntul8G4:virt-nanagernylnyl-Ubuntul804:口 VVirtual Machine ManagerFile Edit View Helpit-. Open A H BB Name

32、CPU usageqemWkvmChaose Storage VolumedefaultFil-esystem DirectoryFile破tern DirectorySize:1D.05G 英昌 MM诺MU*Location: Aan/lb/libvirt/image5Volumes $ I Volumes Size Format Used ByBrowse Local Cancel Choose Volume |New VM| Create a new virtual machiieI _ I St&p4&F5S Enable storage for this virtual machin

33、eCreate a disk image for the virtual machineI 15.0 一 + GiB67.5 GiBavailable ir thedeFault hcationSelector create custom storageMmnagE.CartelBackForwardVolumeVolumes.bashrc.cacheSire; 113.57 GiB Free/ L94CiB 加 Use Location: /home/nylVolum值弓 C Format Used ByT 混 defaultFiLe5tem D rect&rFilesystem Di re

34、ctory g Eisvoljupsi建的.也万 我这里选择的是M, 因为它的空间大.profileMax capacii: |=io.ocancel | FinishVolumesba&hhiitory.bashjogout.bashrccache.conrigDesktopDocumentsDojnlaadbexamples, desk top.gnu pg .ICEauthority heal.mozillaMusic.anupqFormat:.ICEauthoril Backing st&reStorage Volume Quota nyls available space: 113.

35、57 GiB Size Forrnat Used By0.00 MiB tw0,00 MiB raw0.00 MiB raw0.00 MiB diro.oo MiB dir0,00 MiB dir0.00 MiB diro oo MiB dir0.01 MiB raw0,00 MiB dir0 00 MiBawo.oo MiB dir0,00 MiB dirchoose valume.local.mozilLaMusicPictures0.00 MiB dird&Fault File system DirectorCreates storage unit to beused directly

36、by a virtual machine.dbUfttUlS.04.q:r)wf2可自己修改名字blame:-conFigDesktop IDocumentsDownloadsexamples.dqtow2 Size:= 13.57 CiBFree /UseLocation, /home/nylcancelChoose Storage VolumeBnylFitesysLem DirectoryAdd a storage VolumeCreate storage volumeNew VM0Create a new virtual machinestep 4 Of 5 Enable storag

37、e Far this virtual machineCr&ate a disk image For thevirtual machine15.0- + GiB67.5 GiB available in the default locationO Select or create custom storageManage./h ome/nyl/KV M-ubuntu 18.04New VMCreate a new virtual machineReady to begin the installation Step 5 of 5自己修改名字Name:NYLKVM-ubuntu18.04Ubuntu 18.04 ITS Local CDROM/ISO 2048 Mi BOS;Install;Memory;CPUS:Storage: /home/nyl/KVM-ubuntul8.04Customize configuration before install Network selectionBridge brO: Host device

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论