Hyper-V is a native hardware-assisted virtualization platform provided in Windows 8 Pro and Windows Server 2008 R2 and above. In essence, a Virtual Machine is a PC emulation running on your PC. You install VM software on your physical host machine, then boot up and install any number of guest OSs. Popular VM software includes VMware, VirtualBox and Microsoft Virtual PC (which was used to power XP Mode in Windows 7).
Hyper-V是Windows 8 Pro和Windows Server 2008 R2及更高版本中提供的本地硬件辅助虚拟化平台。 本质上,虚拟机是在您的PC上运行的PC仿真。 您可以在物理主机上安装VM软件,然后启动并安装任意数量的来宾OS。 流行的VM软件包括VMware , VirtualBox和Microsoft Virtual PC(用于在Windows 7中为XP模式提供动力)。
VMs are essential for web developers:
虚拟机对于Web开发人员至关重要:
They allow you to test alternative browsers such as historical versions of IE or Linux installations. 它们使您可以测试其他浏览器,例如IE或Linux安装的历史版本。 You can set up development servers such as Linux with Apache, PHP and MySQL on a Windows development PC. 您可以在Windows开发PC上设置开发服务器,例如具有Apache,PHP和MySQL的Linux。VMs are hard disk images so they can be backed-up, cloned and moved far easier than a real PC. In addition, most VM software allows you to make snapshots so you can test software or configurations and revert back in the event of catastrophic failure.
VM是硬盘映像,因此它们的备份,克隆和移动都比真实PC容易得多。 此外,大多数VM软件都允许您制作快照,以便您可以测试软件或配置并在发生灾难性故障时还原。
Hyper-V has a number of benefits including speed, multi-core processor support and booting to VMs (users can use a guest VM as their daily OS so they can’t trash the host). But the main advantage is that VMs operate in the background. There’s no need to start the software; it’s always running and controlling your booted guest OSs. Similarly, there’s no need to open or connect to the guest OS desktop — if you’re running a development server, you can simply transfer files like you would to any other device on your network.
Hyper-V具有许多优势,包括速度,多核处理器支持以及引导至VM(用户可以将来宾VM用作其日常OS,因此不会浪费主机资源)。 但是主要优点是VM在后台运行。 无需启动软件。 它始终在运行并控制启动的来宾操作系统。 同样,无需打开或连接到来宾OS桌面-如果您正在运行开发服务器,则可以像将文件一样简单地将文件传输到网络上的任何其他设备。
So let’s look at the basics of using Hyper-V. I’m using Windows 8 but Windows Server is similar.
因此,让我们看一下使用Hyper-V的基础知识。 我正在使用Windows 8,但Windows Server与之类似。
From the Windows Control Panel, select Programs and Features followed by Turn Windows features on or off. Check Hyper-V and all platform and tools sub-components. It’ll take a few minutes to install.
在Windows“控制面板”中,选择“ 程序和功能”,然后选择“ 打开或关闭Windows功能” 。 检查Hyper-V以及所有平台和工具子组件。 安装需要几分钟。
From the Start screen (or Win+Q), run the Hyper-V Manager. You can change the default settings in Action > Hyper-V Settings.
在“开始”屏幕(或Win + Q)中,运行Hyper-V管理器 。 您可以在操作 > Hyper-V设置中更改默认设置。
To create a new VM, select Action > New > Virtual Machine…. Enter a name for your VM and select a different file location if necessary:
要创建新的VM,请选择操作 > 新建 > 虚拟机… 。 输入虚拟机的名称,并根据需要选择其他文件位置:
Now enter the amount of memory you want the VM to use — keep it as dynamic unless you want to specify a maximum:
现在,输入您希望VM使用的内存量—除非您要指定最大值,否则将其保持动态:
You can now create or use an existing hard disk image and specify a maximum size (it will grow as the VM requires more space):
现在,您可以创建或使用现有的硬盘映像并指定最大大小(随着VM需要更多空间,该大小将不断增加):
Finally, you can choose to install an operating system from a physical drive or ISO image:
最后,您可以选择从物理驱动器或ISO映像安装操作系统:
Hit Finish to complete the wizard. You can now boot your VM (click Start in the Actions pane) and install a guest OS. Remember this occurs in the background; to view the desktop, click Connect… in the Actions pane.
点击完成以完成向导。 现在,您可以引导您的VM(在“操作”窗格中单击“ 开始 ”)并安装来宾OS。 请记住,这是在后台发生的; 要查看桌面,请在“操作”窗格中单击“ 连接… ”。
Note that the VM will not be able to connect to a network yet — you may wish to configure that first so updates can be downloaded.
请注意,VM尚无法连接到网络-您可能希望先进行配置,以便可以下载更新。
Connecting to the network is slightly unusual compared to other VM software. Hyper-V creates a virtual switch device which is subsequently used for all host and guest connectivity. Under the right-hand Actions pane, click Virtual Switch Manager…. Select External and hit Create Virtual Switch.
与其他VM软件相比,连接到网络有点不寻常。 Hyper-V创建一个虚拟交换设备,随后将其用于所有主机和来宾连接。 在右侧“操作”窗格下,单击“ 虚拟交换机管理器…” 。 选择“ 外部”,然后单击“ 创建虚拟交换机” 。
Assign a name (Virtual Switch is as good as any), select the real network adapter used for networking on your host OS, and hit Apply. The dialog can then be closed.
分配一个名称( Virtual Switch与其他名称一样好),选择用于在主机OS上联网的实际网络适配器,然后单击Apply 。 然后可以关闭对话框。
Now, right-click your VM and choose Settings… (or click Settings… under your VM in the Action pane). Select the Network Adapter tab and ensure Virtual Switch (or whatever you named it) is selected.
现在,右键单击您的VM,然后选择“设置...” (或在“操作”窗格中的VM下单击“设置...”)。 选择“ 网络适配器”选项卡,并确保选择了“ 虚拟交换机” (或您命名的任何名称)。
Reboot your VM and, with luck, you should have network connectivity.
重新启动您的虚拟机,幸运的是,您应该具有网络连接性。
Network Troubles? Many people experience networking problems with Hyper-V guests — I did. A separate hardware NIC adapter is recommended, but this is impractical for most desktop and laptop PCs. If you can’t connect or connectivity randomly drops, try the following remedies:
网络问题? 许多人都遇到过Hyper-V来宾的网络问题-我做到了。 建议使用单独的硬件NIC适配器,但是对于大多数台式机和笔记本电脑来说,这是不切实际的。 如果您无法连接或随机断开连接,请尝试以下补救措施:
Configure the guest OS to use a fixed IP address. 配置来宾操作系统以使用固定IP地址。If it continues to fail, disable TCP Checksum Offload and UDP Checksum Offload in your physical NIC adapter settings (they may have slightly different names).
如果继续失败,请在物理NIC适配器设置中禁用TCP Checksum Offload和UDP Checksum Offload (它们的名称可能略有不同)。
As mentioned, you can click Connect… in the VM’s Action pane to view the desktop. Alternatively, you can use Microsoft’s Remote Desktop Connection tool much like you would with any networked Windows device.
如前所述,您可以在VM的“操作”窗格中单击“ 连接… ”以查看桌面。 另外,您可以像使用任何联网的Windows设备一样使用Microsoft的远程桌面连接工具。
Hyper-V offers some great features which will benefit web developers. Do you have any interesting uses for the platform?
Hyper-V提供了一些很棒的功能,这些功能将使Web开发人员受益。 您对该平台有什么有趣的用途?
翻译自: https://www.sitepoint.com/hyper-v-virtual-machine-tutorial/
相关资源:hyper-v虚拟机常用命令