在Fedora上将Xen作为Domain-0安装(Fedora 17)

The new development of Xen and Linux kernel make it easy to install Xen on Fedora as the Domain-0 now. This post uses Fedora 17 as an example platform to introduce how to set up Domain-0 on Fedora Linux. Compared to our old method (Setting up Stable Xen Dom0 with Fedora: Xen 3.4.3 with Xenified Linux Kernel 2.6.32.13 in Fedora 12) which requires manually compiled Xen and patched kernel, the current packages and support to Xen in Fedora and Linux kernel make the system administrators life much easier.

Xen和Linux内核的新开发使现在可以轻松将Xen作为Domain-0安装在Fedora上。 本文以Fedora 17为例,介绍如何在Fedora Linux上设置Domain-0。 与我们以前的方法( 使用Fedora设置稳定的Xen Dom0:在Fedora 12中使用Xenified Linux内核2.6.32.13使用Xen 3.4.3 )相比,该方法需要手动编译Xen和修补的内核,当前的软件包以及对Fedora和Linux内核中对Xen的支持。使系统管理员的工作更加轻松。

On the other hand, Xen has changed its tool stack from xm/xend to xl and the network configuration should be done manually on different platforms.

另一方面,Xen已将其工具堆栈从xm / xend更改为xl,并且网络配置应在不同平台上手动完成。

安装Xen (Installing Xen)

First, install the xen pacakges:

首先,安装xen pacakges:

# yum install xen

The Linux kernel is already ready to run in Domain-0 with the pv_ops technology enabled. The xen and kernel versions I used is listed as follows.

Linux内核已经准备好在启用pv_ops技术的情况下在Domain-0中运行。 我使用的xen和内核版本如下所示。

xen-4.1.3-5.fc17.x86_64
kernel-3.6.6-1.fc17.x86_64

Run grub2-mkconfig

运行grub2-mkconfig

Run this command to make config for grub2 again:

运行以下命令再次为grub2进行配置:

# grub2-mkconfig -o /boot/grub2/grub.cfg

Otherwise, the kernel will fail to boot and print messages like “swap not trainted…”.

否则,内核将无法启动并打印诸如“交换未训练……”之类的消息。

Then, we can boot the Fedora to run on Xen as Domain-0 by selecting the Fedora, with Xen hypervisor in Grub2 during booting the system. We can also Setting Default Entry in Grub2 and Grub.

然后,我们可以通过选择Fedora来启动Fedora,使其在Xen上以Domain-0的身份在Xen上运行,并在系统启动过程中在Grub2中使用Xen虚拟机管理程序 。 我们还可以在Grub2和Grub中设置默认条目

After booting Linux on Xen as Domain-0, we can list the information by ‘xl info’ as follow.

在Xen上将Linux作为Domain-0启动Xen之后,我们可以按“ xl info”列出信息,如下所示。


# xl info
host                   : office.zhiqiangma.com
release                : 3.6.6-1.fc17.x86_64
version                : #1 SMP Mon Nov 5 21:59:35 UTC 2012
machine                : x86_64
nr_cpus                : 4
nr_nodes               : 1
cores_per_socket       : 4
threads_per_core       : 1
cpu_mhz                : 2809
hw_caps                : bfebfbff:28100800:00000000:00003b40:0098e3fd:00000000:00000001:00000000
virt_caps              : hvm
total_memory           : 2039
free_memory            : 126
free_cpus              : 0
xen_major              : 4
xen_minor              : 1
xen_extra              : .3
xen_caps               : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64 
xen_scheduler          : credit
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : unavailable
xen_commandline        : placeholder
cc_compiler            : gcc version 4.7.2 20120921 (Red Hat 4.7.2-2) (GCC) 
cc_compile_by          : mockbuild
cc_compile_domain      : [unknown]
cc_compile_date        : Sun Oct 28 23:08:22 UTC 2012
xend_config_format     : 4

配置网络 (Configuring the network)

方法1:VM和主机形成专用网络 (Method 1: The VMs and the host form a private network)

If the computer has no wired NIC, such as a laptop that only has wireless network, a dummy device may be helpful. I also show the script I used on my laptop here.

如果计算机没有有线NIC(例如仅具有无线网络的笔记本电脑),则虚拟设备可能会有所帮助。 我还在这里显示了我在笔记本电脑上使用的脚本。


#!/bin/bash

# set up a bridge as the backed device for xen
brctl addbr xenbr0

# set up a dummy device
modprobe dummy
ip link set name xendummy0 dev dummy0
brctl addif xenbr0 xendummy0

# give the bridge an IP
ifconfig xenbr0 10.0.0.2

# set its netmask
ifconfig xenbr0 netmask 255.255.0.0

# set up NAT and make the Domain-0 acts as a gateway
#    You may change this rule for better security
iptables -I FORWARD -j ACCEPT
iptables -t nat -I POSTROUTING --out-interface wlan0 -j MASQUERADE
echo 1 > /proc/sys/net/ipv4/ip_forward

方法2:桥接网络 (Method 2: bridged networking)

NetworkManager does not work with bridge currently. To use bridge-based network for Xen. We should change the network management service from NetworkManager to network. The networking configuration is stored in ‘/etc/sysconfig/network-scripts/’.

NetworkManager当前不适用于网桥。 为Xen使用基于桥接的网络。 我们应该将网络管理服务从NetworkManager更改为网络。 网络配置存储在“ / etc / sysconfig / network-scripts /”中。

To disable NetworkManager and start network, do the following:

要禁用NetworkManager并启动网络,请执行以下操作:

# systemctl disable NetworkManager.service
# systemctl restart network.service

Make sure that the network service is automatically started by:

确保通过以下方式自动启动网络服务:

# chkconfig network on

Then, we can create the configuration file for the bridge. Let’s call the bridge ‘xenbr0’.

然后,我们可以为网桥创建配置文件。 我们将桥称为“ xenbr0”。

Edit ‘/etc/sysconfig/network-scripts/ifcfg-xenbr0’ (we assume dhcp here. You can also give the bridge a static IP as for the other network devices.):

编辑“ / etc / sysconfig / network-scripts / ifcfg-xenbr0”(此处假设为dhcp。您也可以像其他网络设备一样为网桥提供静态IP。):


DEVICE=xenbr0
TYPE=Bridge
ONBOOT=yes
DELAY=0
NM_CONTROLLED=no
BOOTPROTO=dhcp

Then find the configuration file for your existing network adaptor (e.g. ifcfg-em1) and edit it as follows.

然后找到现有网络适配器的配置文件(例如ifcfg-em1)并按如下方式进行编辑。

NM_CONTROLLED=no
BRIDGE=xenbr0

Finally, make the network configuration take effect by:

最后,通过以下方法使网络配置生效:

# systemctl restart network.service

As I have stated, the network configuration should be done by the administrator according to the Linux distro’s method. On Fedora, we use NetworkManager as it is. In this tutorial, we set up bridge-based network for xen. This method works well not only for wired network but also wireless network.

如前所述,网络配置应由管理员根据Linux发行版的方法进行。 在Fedora上,我们按原样使用NetworkManager。 在本教程中 ,我们为xen建立了基于桥接的网络。 此方法不仅适用于有线网络,而且适用于无线网络。

I make all the steps together into one script as follows:

我将所有步骤汇总为一个脚本,如下所示:

#!/bin/bash

# set up a bridge as the backed device for xen
brctl addbr xenbr0

# bridge to eth0
brctl addif xenbr0 eth0

# bring up the bridge
ifconfig xenbr0 up

In this script, we first set up the bridge xenbr0 for xen and bridge it to eth0 which is the real NIC device. Then, we can set up Domain-U to use this bridge as the backed to set up its network.

在此脚本中,我们首先为xen设置网桥xenbr0并将其桥接到作为实际NIC设备的eth0。 然后,我们可以将Domain-U设置为使用此网桥作为支持以建立其网络。


You can make Linux run this this script each time the system is booted by adding ‘@reboot /path/to/the/script.sh’ to cron jobs through ‘crontab -e’ or setting up a new service to invoke this script.


您可以使Linux在每次启动系统时都运行此脚本,方法是通过'crontab -e'将'@reboot /path/to/the/script.sh'添加到cron作业中,或者设置新服务来调用此脚本。

一个示例Dom-U配置文件 (One example Dom-U configuration file)

I give one example Domain-U configuration file here as follows.

我在下面给出一个示例Domain-U配置文件。


name="10.1.0.114"
vcpus=2
memory=2048
disk=['phy:/dev/vg_xen/vm-10.1.0.114,xvda,w']
vif=['bridge=xenbr0']
bootloader="/usr/bin/pygrub"
on_reboot="restart"
on_crash="restart"
# extra="single"

Most of the old ‘xm’ commands for Domain-U management work under ‘xl’ by just simply replacing ‘xm’ with ‘xl’.

只需将“ xm”替换为“ xl”,大多数用于Domain-U管理的“ xm”命令就可以在“ xl”下运行。

翻译自: https://www.systutorials.com/installing-xen-domain-0-on-fedora-17/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值