Virtualization2.0 简明教程

Virtualization 2.0 - VirtualBox

在本章中,我们将了解什么是 VirtualBox,并详细讨论其拥有的各个组件。

In this chapter, we will understand what a VirtualBox is and discuss in detail the various components it has.

Installing VirtualBox

首先,我们将下载 VirtualBox 并安装它。我们应该按照以下步骤进行安装。

To start with, we will download VirtualBox and install it. We should follow the steps given below for the installation.

Step 1 - 要下载 VirtualBox,请点击以下链接 https://www.virtualbox.org/wiki/Downloads 现在,根据你的操作系统,选择要安装哪个版本。在我们的例子中,它将是第一个(Windows 主机)。

Step 1 − To download VirtualBox, click on the following link https://www.virtualbox.org/wiki/Downloads Now, depending on your OS, select which version to install. In our case, it will be the first one (Windows host).

virtualbox

Step 2 - 选择选项后,单击“下一步”。

Step 2 − Once the option is selected, click on “Next”.

option

Step 3 - 你可以选择询问在哪里安装应用程序。我们可以保留默认设置,然后单击“下一步”。

Step 3 − You have the option asking where to install the application. We can leave it as default and click on “Next”.

application install

Step 4 - 选择选项后,如图所示,单击下一步。

Step 4 − Once the options are selected as shown in the following screenshot, click on Next.

shortcut

Step 5 - 将出现一个对话框,询问是否继续安装。单击“是”。

Step 5 − A dialog box will come up asking whether to proceed with the installation. Click “Yes”.

proceed

Step 6 - 在下一步中,单击“安装”。

Step 6 − In the next step, click on “Install”.

ready to install

Step 7 - 选中启动 VirtualBox 复选框,然后单击“完成”。

Step 7 − Tick the start VirtualBox check box and click on “Finish”.

checkbox finish

Step 8 - VirtualBox 应用程序现在将打开,如图所示。现在,我们可以准备安装虚拟机了。

Step 8 − VirtualBox application will now open as shown in the following screenshot. Now, we are ready to install the virtual machines.

install virtual machines

Creating a VM with VirtualBox

要使用 Oracle VirtualBox 创建虚拟机,我们应按照以下步骤进行操作。

To create a virtual machine with Oracle VirtualBox, we should follow the steps given below.

Step 1 - 首先,单击桌面上的“Oracle VM VirtualBox”图标,如下面的屏幕截图所示。

Step 1 − To begin with, click on the “Oracle VM VirtualBox” icon on the desktop as shown in the screenshot below.

oral vm

Step 2 - 下一步是单击屏幕左上角的“新建”按钮。

Step 2 − The next step is to click on “New” button, which is in the top left hand side of the screen.

new button

Step 3 - 将弹出一个表,要求你提供虚拟机的参数。这些参数将是 -

Step 3 − A table will pop-up requesting you the parameters for the virtual machine. These will be −

  1. Name − We have to put a friendly name for this Virtual Machine.

  2. Type − Enter the OS that is going to be installed on it.

  3. Version − Enter the specific version for that OS, which we have selected earlier.

填写完所有上述参数后,单击“下一步”。

Once all the above parameters are filled, click on “Next”.

table

Step 4 - 选择你需要在此虚拟机中分配的内存大小 → 单击“下一步”。

Step 4 − Select the amount of memory that you need to allocate in this VM → Click on “Next”.

memory amount

Step 5 - 勾选 HDD 的三个选项之一,然后单击“创建”。

Step 5 − Check one of the three options for the HDD and click on “Create”.

hdd

Step 6 - 为你的虚拟 HDD 选择一个文件扩展名(建议使用大多数管理程序使用的通用文件扩展名,如 VHD)→ 单击“下一步”。

Step 6 − Select a file extension for your virtual HDD (It is recommended to use a common file extension that most of the hypervisors use like VHD) → click on “Next”.

vdi

Step 7 - 选择是将虚拟 HDD 设置为动态的还是固定的。这取决于你的需求 → 单击“下一步”。

Step 7 − Choose whether you want the Virtual HDD as dynamic or fixed. This is based on your needs → Click on “Next”.

dynamic

Step 8 − 为虚拟硬盘文件命名,并为虚拟机选择磁盘大小 → 单击“创建”。

Step 8 − Put a name for your virtual HDD file and select the disk size for your VM → Click on “Create”.

hdd file

通过选择“专家模式”,所有上述步骤均可一次性完成。

All the above steps can be done in one shot by selecting the “Expert mode”.

expert mode

创建的虚拟机将显示在下方的截图中。

The virtual machine created will be as shown in the screenshot below.

virtual machine created

Setting up Networking with VirtualBox

在 VirtualBox 中有两种网络模式,分别是 −

There are two types of networking modes in VirtualBox, which are −

  1. Nat Networks and

  2. Host-only Networks.

这两个将在下方详细说明。

Both of these are explained in detail below.

Nat Networks

要设置 Nat 网络,我们应按照以下步骤进行操作。

For setting up Nat Networks, we should follow the steps given below.

Step 1 − 转到 Oracle VM VirtualBox Manager → 单击“首选项…”

Step 1 − Go to Oracle VM VirtualBox Manager → Click on “Preferences…”

preferences

Step 2 − 单击“网络”,然后在左面板中单击“NAT 网络”选项卡。

Step 2 − Click on “Network” and then on the left panel click on the “NAT Networks” tab.

nat networks

Step 3 − 单击“+”按钮,该按钮在下方截图中高亮显示。

Step 3 − Click on the “+” button, which is highlighted in the screenshot below.

plus

Step 4 − 在这里,我们必须输入“网络名称”和将被 NAT 的此网络的 IP 范围,以便访问互联网和其他网络。

Step 4 − Here, we have to put the “Network Name” and the IP range for this network that will be NAT-ed, in order to have access to internet and to other networks.

network name

Host-only Networks

要设置仅主机网络,我们应按照以下步骤进行操作。

For setting up Host-only Networks, we should follow the steps given below.

Step 1 − 如果单击“仅主机网络”选项卡,则可以创建与其他网络隔离的网络。但是,虚拟机主机彼此通信并与管理程序计算机通信。单击“+”号。

Step 1 − If you click on the “Host-only Networks” tab, you can create networks that are isolated from the other networks. However, VM hosts communicate with each other and the Hypervisor machine. Click on the “+” sign.

vm hosts

Step 2 − 主机接口将继续创建,如下图所示。

Step 2 − The host interface will continue to be created as shown in the screenshot below.

host interface

Step 3 − 如果单击按钮,则可以编辑设置。

Step 3 − If you click on button, you can edit the settings.

edit settings

Step 4 − 如果希望主机使用“DHCP IP”,请单击“DHCP 服务器”选项卡,并选中“启用服务器”复选框 → 单击“确定”。

Step 4 − If you want your host machines to take “DHCP IP”, click on the “DHCP Server” tab and check the box “Enable Server” → Click “OK”.

dhcp

Step 5 − 在“适配器”选项卡中,输入管理程序的 IP。

Step 5 − In the “Adapter” tab, put the IP of the hypervisor.

adapter

在完成所有这些网络模式设置准备后。现在是时候为我们的虚拟机分配网络了。

After all these preparations for setting up the network modes is complete. It is now time to assign a network to our VMs.

要做到这一点,请单击面板左侧的虚拟机,然后右键单击“网络”选项,一张表格将会打开。

To do this, Click on the VMs on the left side of the panel, then right click on the “Network” option and a table will be open.

natnetwork

每台计算机最多可以有四个以太网适配器。下图突出显示了四个部分,它们在下面进行了说明。

You can have up to four Ethernet adaptors per machine. The following image has four sections highlighted, which are explained below.

  1. Check the box “Enable Network Adapter” to enable the vNIC on the VM and attach it to one network.

  2. You can have many networks created, so we have to select one of them in the “Name” dropdown box.

  3. In the adapter type dropdown-box, we have to select a physical NIC that the hypervisor has.

  4. Promiscuous Mode: Here, we can select “Deny”, if we do not want the VMs to communicate with each other.

完成以上所有参数后。单击“确定”。

Once all the above parameters are completed. Click on “OK”.

parameters

Allocating Processors & Memory to a VM

要使用 VirtualBox 为虚拟机分配处理器和内存,我们应执行以下步骤。

To allocate processors and memory to a virtual machine using VirtualBox, we should follow the steps given below.

Step 1 − 要分配处理器和内存,您必须在选择 VM 后单击“设置”。

Step 1 − To allocate a processor and memory, you have to click on “Settings” after you have selected the VM.

click settings

Step 2 − 单击左侧标签中的“系统”,然后单击“主板”标签。如下图所示,左右移动箭头以分配内存。

Step 2 − Click on “System” on the left side tab, then click on the “Motherboard” tab. Move the arrow left or right to allocate the memory as shown in the screenshot below.

system

Step 3 − 要分配处理器,请单击“处理器”选项卡。如下图所示,左右移动箭头以分配处理器数量。

Step 3 − To allocate processors, click on the “Processor” tab. Move the arrow left or right to allocate the number of processors as shown in the screenshot below.

processor tab

Step 4 − 完成所有这些更改后 → 单击“确定”。

Step 4 − After all those changes are done → click on “OK”.

click ok

Duplicating a VM Using VirtualBox

要使用 VirtualBox 复制虚拟机,我们应执行以下步骤。

To duplicate a virtual machine using VirtualBox, we should follow the steps given below.

Step 1 − 要复制我们之前创建的 VM,请右键单击 VM,然后选择“克隆”。一个向导将打开。

Step 1 − To duplicate a VM that we created before, right click on the VM and select “Clone”. A wizard will open.

clone wizard

Step 2 − 填写克隆计算机的名称,然后单击“下一步”。

Step 2 − Write the name of the cloning machine and click on “Next”.

cloning machine

Step 3 − 选择其中一个选项,然后单击“克隆”。

Step 3 − Select one of the options and Click on “Clone”.

click on clone

Step 4 − 新创建的 VM 将如下图所示。

Step 4 − The newly created VM will be as shown in the following screenshot.

newly created vm

Deleting a VM on VirtualBox

要删除 VirtualBox 上的虚拟机,我们应执行以下步骤。

To delete a virtual machine on VirtualBox, we should follow the steps given below.

Step 1 − 首先,我们要右键单击要删除的 VM,然后单击“删除”。

Step 1 − To start with, we have to right click on the VM that we want to delete and then click on “Remove”.

remove

Step 2 − 要彻底删除虚拟机,请选择“删除所有文件”。

Step 2 − To delete a virtual machine completely, select “Delete all files”.

delete