xen母机创建虚拟机n_在Xen上创建和管理虚拟机

xen母机创建虚拟机n

In this post, these content are introduced:

在这篇文章中,介绍了这些内容:

  • Create and manage file-backed virtual block device (VBD) for virtual machines on xen.

    在xen上为虚拟机创建和管理文件支持的虚拟块设备(VBD)。
  • Install Fedora 11 via internet as DomU on top of xen.

    通过Internet作为Xen顶部的DomU安装Fedora 11。
  • Manage virtual machines using xm.

    使用xm管理虚拟机。

Create file-backed VBD:

创建文件支持的VBD:

The actual space of VBD will be the amount of disk the virtual machine used. And it will be convenient if the virtual machine will be duplicated since the work is just copying the VBD file and changing some configurations.

VBD的实际空间将是虚拟机使用的磁盘量。 如果要复制虚拟机,将很方便,因为工作只是复制VBD文件并更改某些配置。

Create a 20GB sparse file-backed VBD:

创建一个20GB的稀疏文件支持的VBD:

# dd if=/dev/zero of=vmdisk0 bs=1k seek=20480k count=1

Make a ext3 file system in the disk file:

在磁盘文件中创建一个ext3文件系统:

# mkfs -t ext3 vmdisk0

Install Fedora 11 Linux via Internet:

通过Internet安装Fedora 11 Linux

First download the pxeboot kernel of Fedora 11 for installation via Internet. Download vmlinuz and initrd.img from here:

首先下载Fedora 11的pxeboot内核以通过Internet安装。 从此处下载vmlinuz和initrd.img:

Download.

下载

Create an installation profile f11.install:

创建一个安装配置文件f11.install:

name="F11INSTALL"
memory=1536
disk = ['tap:aio:/home/xen/vmdisk0,xvda,w' ]
vif = [ 'bridge=eth0' ]
kernel = "/home/xen/fedora/vmlinuz"
ramdisk = "/home/xen/fedora/initrd.img"
vcpus=2
on_reboot = 'restart'
on_crash = 'restart'

Here the blktap2 VBD driver is used. If the loopback backed driver is used, the disk like should be changed to:

这里使用blktap2 VBD驱动程序。 如果使用回送驱动程序,则应将如下磁盘更改为:

disk = ['file:/home/xen/vmdisk0,xvda,w' ]

The virtual machine’s name is “F11INSTALL”, memory is 1.5G, CPU number is 2, disk, kernel and ramdisk is prepared in the above steps.

在上述步骤中,准备了虚拟机的名称为“ F11INSTALL”,内存为1.5G,CPU编号为2,磁盘,内核和虚拟磁盘。

Start this virtual machine:

启动此虚拟机:

# xm create f11.install

Connect to this virtual machine’s console and complete the installation:

连接到该虚拟机的控制台并完成安装:

# xm console F11INSTALL

The installation of Fedora 11 will start. The URL of installation source I used during installation is:

Fedora 11的安装将开始。 我在安装过程中使用的安装源的URL是:

http://download.fedora.redhat.com/pub/fedora/linux/releases/11/Fedora/x86_64/os/

Load DomU:

加载DomU:

Create a profile vm1.run for loading the virtual machine:

创建一个配置文件vm1.run来加载虚拟机:

name="vm1"
memory=1536
disk = ['tap:aio:/home/xen/vm1/vmdisk1,xvda,w' ]
vif = [ 'bridge=eth0' ]
bootloader = "/usr/bin/pygrub"
vcpus=2
on_reboot = 'restart'
on_crash = 'restart'

Here we use the PyGrub (“/usr/bin/pygrub”) as the bootloader. PyGrub starts Linux DomUs with the kernels that lie in the filesystem of the DomU instead of the kernels that lie in the filesystem of the Dom0. That makes the kernel update and management easier.

在这里,我们使用PyGrub(“ / usr / bin / pygrub”)作为引导程序。 PyGrub使用位于DomU文件系统中的内核而不是位于Dom0文件系统中的内核来启动Linux DomU。 这使内核的更新和管理更加容易。

Then the DomU can be started using this profile:

然后,可以使用以下配置文件启动DomU:

# xm create vm1.run

The console of this DomU can be connected to:

该DomU的控制台可以连接到:

# xm console vm1

Manage DomUs:

管理DomU:

Start Domu:

开始Domu:

# xm create DomU_profile

List running DomUs:

列出正在运行的DomU:

 # xm list

Shutdown DomU:

关闭DomU:

 # xm shutdown DomU_name

Console of DomU:

DomU的控制台:

 # xm console DomU_name

Top of DomUs:

DomUs的顶部:

 # xm top

Reset a DomU:

重置DomU:

 # xm reset DomU_name

And others more which can be find in the xm manuals.

其他更多信息可以在xm手册中找到。

After configured a DomU, duplication of the DomU is easy: Just make a copy of the VBD file and the profile, and then change the profile.

配置DomU之后,复制DomU很容易:只需复制VBD文件和配置文件,然后更改配置文件。

I have set up 8 DomUs on the server. There are total 9 machines on top of xen and a lot of interesting things can be done with these “machines” ;)

我在服务器上设置了8个DomU。 xen上总共有9台机器,这些“机器”可以完成很多有趣的事情;

# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  1826    16     r-----    244.8
vm1                                         25  1536     2     -b----      4.9
vm2                                         24  1536     2     -b----      5.4
vm3                                         23  1536     2     -b----      5.4
vm4                                         22  1536     2     -b----      5.8
vm5                                         27  1536     2     -b----      5.4
vm6                                         20  1536     2     -b----      6.0
vm7                                         19  1536     2     -b----      6.3
vm8                                         18  1536     2     -b----     18.8

References:

参考文献:

翻译自: https://www.systutorials.com/create-and-manage-virtual-machines-on-xen/

xen母机创建虚拟机n

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值