XAPI on Ubuntu: Difference between revisions

From Xen
Jump to navigationJump to search
No edit summary
 
(22 intermediate revisions by 3 users not shown)
Line 1: Line 1:
#REDIRECT [[XCP_toolstack_on_a_Debian-based_distribution]]
<!-- MoinMoin name: XAPI_on_Ubuntu -->
<!-- MoinMoin name: XAPI_on_Ubuntu -->
<!-- Comment: -->
<!-- Comment: -->
Line 8: Line 9:
= Installing Xapi on Ubuntu Oneiric =
= Installing Xapi on Ubuntu Oneiric =


This is Project Kronos. Follow theses instructions to get xapi, the XenAPI server daemon, installed on an Ubuntu Oneiric box, using the upstream Linux kernel. This will effectively allow you to turn an existing Ubuntu machine into an XCP host. Note that this is *very much* a work-in-progress. Some features will be broken, and there will be a bit of manual configuration required. We appreciate any testing you do for this project, but please don't consider this production ready yet! Please visit the [[Kronos Supported Features]] page for a list of XCP features that are known to work on Kronos.


==1. Install Ubuntu Oneiric==


This is Project Kronos. Follow these instructions to get xapi, the XenAPI server daemon, installed on an Ubuntu Oneiric box, using the upstream Linux kernel. This will effectively allow you to turn an existing Ubuntu machine into an XCP host. Note that this is *very much* a work-in-progress. Some features will be broken, and there will be a bit of manual configuration required. We appreciate any testing you do for this project, but please don't consider this production ready yet! Please visit the [[Kronos Supported Features]] page for a list of XCP features that are known to work on Kronos.
Kronos will work with either Ubuntu Oneiric Server or Desktop, with the default kernel. If you want to use local storage, you will have to reserve an unformatted partition on your hard disk for xapi. In a later step, you will use this partition to create a local storage repository.


__TOC__
==2. Set up the Kronos PPA==


===What's the best environment?===
The best environment is a clean installed modern system with significant amounts of RAM in it and several cores. However, this guide is written in the knowledge that not everyone will be in the lucky position of having such a box to play with. In fact, many of us will be installing it on a moderately-sized box with an existing (upgraded) version of Ubuntu running. One of the authors of this guide (MikeCamel) is in exactly that position, so you are not alone. Hopefully this guide will be relevant to you, and will provide working instructions. If you have a problem, let us know.


==Warnings - README==
<pre><nowiki>
You need to read these warnings. If you don't, you could do serious damage to your system, leave it unbootable, be surprised when things don't work as you expect (or at all), and generally fail to create World Peace[tm]. And that would be a pity.
add-apt-repository ppa:ubuntu-xen-org/xcp
</nowiki></pre>


'''An important note''': don't be tempted to install any kernel (via apt, for instance) which ends in "-virtual" during this process. Such kernels are intended to run as Guests (that is, "VMs"), and are not configured to be used as the Dom0 kernel. You will run into particular problems if you try this on a system which uses an Nvidia card, as the nvidia-current drivers do not currently seem to compile against these kernels, and you will therefore not be able to start X correctly. Given the standard Oneiric start up and splash screens, this isn't a particularly easy problem to fix, so avoid it in the first place!


'''Another important note''': the instructions on this page assume that:
'''Note:''' Our PPA isn't working properly yet, but you can revert to installing a Kronos Debian repository instead.
*you know what you are doing with Linux, and are able to repair any issues that might arise as a result of following (or mis-following...) the instructions;
*you are running as root. If you don't know what this entails, then see 1. above, and seek further help from the community before proceeding.


'''A couple of network-related notes'''
# XAPI expects to run in a clean environment, and listens on ports 80 and 443. If you're running anything else on these ports (typically Apache/Apache2), then you're likely to have problems.
# There is a known bug (which needs to be fixed) which means that in certain circumstances when you are using VPN software (e.g. when you have a tun0 interface listed in ifconfig), xapi will fail. Please ensure that you remove all such software before attempting to run xcp-xapi.


'''And a note about kernels'''
<pre><nowiki>
Kronos is really aimed at Precise Pangolin (Ubuntu 12.04), which will include the 3.2 kernel. There is a nasty bug in the 3.0 series (and probably before) which means that, between them, a couple of the components of Xen are going to reduce the size of Dom0 (and therefore your main operating environment) to something under 1 GiB, which may cause you significant problems. There are work-arounds (TODO: provide work-arounds...), but this is a real issue if you're planning to run Kronos on Oneiric. There is a [[#ballooning-work-around|work-around described below]].
apt-get install curl

echo "deb http://downloads.xen.org/XCP/debian/repo/debian unstable main" > /etc/apt/sources.list.d/kronos.list
==1. Install Ubuntu Oneiric==
echo "deb-src http://downloads.xen.org/XCP/debian/repo/debian unstable main" >> /etc/apt/sources.list.d/kronos.list

wget --quiet -O - http://downloads.xen.org/XCP/debian/xcp.gpg.key | apt-key add -
Kronos will work with either Ubuntu Oneiric Server or Desktop, with the default kernel. If you want to use local storage, you will have to reserve an unformatted partition on your hard disk for xapi. In a later step, you will use this partition to create a local storage repository.
apt-get update
apt-get install xapi
</nowiki></pre>


==2a. Set up the Kronos PPA ...or...==

Add the following to /etc/apt/sources.list

<pre>
deb http://ppa.launchpad.net/ubuntu-xen-org/xcp-unstable/ubuntu oneiric main
deb-src http://ppa.launchpad.net/ubuntu-xen-org/xcp-unstable/ubuntu oneiric main
</pre>

==2b. ... Use a Kronos Debian repository==
<pre>
apt-get install curl echo "deb http://downloads.xen.org/XCP/debian/repo/debian unstable main" > /etc/apt/sources.list.d/kronos.list echo "deb-src http://downloads.xen.org/XCP/debian/repo/debian unstable main" >> /etc/apt/sources.list.d/kronos.list wget --quiet -O - http://downloads.xen.org/XCP/debian/xcp.gpg.key | apt-key add -
</pre>


==3. Install xapi==
==3. Install xapi==
Line 40: Line 57:




<pre><nowiki>
<pre>
apt-get update
apt-get update
apt-get install xapi
apt-get install xcp-xapi
apt-get install xcp-xe
</nowiki></pre>
</pre>




Line 50: Line 68:
==4. Post-install setup==
==4. Post-install setup==


* '''a)''' Optional: Make xen the default grub entry.
'''a)''' Optional: Make xen the default grub entry.


<pre>

<pre><nowiki>
sed -i 's/GRUB_DEFAULT=""/GRUB_DEFAULT="Xen 4.1-amd64"/' /etc/default/grub
sed -i 's/GRUB_DEFAULT=""/GRUB_DEFAULT="Xen 4.1-amd64"/' /etc/default/grub
update-grub
update-grub
</nowiki></pre>
</pre>


'''Note:''' given the default set up for Ubuntu's grub (in /etc/default/grub), you don't get to see the splashscreen with kernel boot options. If you do want to see the list of options, you may need to change some of the settings in this file.


b. Setup the network/interfaces file:
'''b.''' Setup the network/interfaces file:


This is likely to be /etc/network interfaces - ensure that you don't remove any existing settings. Note that if you are running a DHCP server on this machine, then you may need to change the xenbr0 interface to a static or manual IP address, as DHCP may not come up in time to provide an address otherwise.


<pre><nowiki>
<pre>
cat > /etc/network/interfaces <<EOF
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo xenbr0
auto lo xenbr0
iface lo inet loopback

# The primary network interface
iface eth0 inet manual


iface xenbr0 inet dhcp
iface xenbr0 inet dhcp
bridge_ports eth0
bridge_ports eth0
</pre>


'''c.''' Setup the xensource-inventory file:
EOF
</nowiki></pre>


'''Note:''' this assumes that the root partition is on /dev/sda1 - change if required.
'''Note:''' this assumes that your management interface will be xenbr0 - change if required.


<pre>
c. Setup the xensource-inventory file:


<pre><nowiki>
control_domain=`uuidgen`
control_domain=`uuidgen`
installation=`uuidgen`
installation=`uuidgen`


cat > /etc/xensource-inventory << EOF
cat > /etc/xcp/xensource-inventory << EOF
CURRENT_INTERFACES='xenbr0'
CURRENT_INTERFACES='xenbr0'
BUILD_NUMBER='0'
BUILD_NUMBER='0'
CONTROL_DOMAIN_UUID='${control_domain}'
CONTROL_DOMAIN_UUID='${control_domain}'
INSTALLATION_UUID='${installation}'
INSTALLATION_UUID='${installation}'
MANAGEMENT_INTERFACE='xenbr0'
MANAGEMENT_INTERFACE='xenbr0'
PRIMARY_DISK='/dev/sda1'
PRIMARY_DISK='/dev/sda1'
EOF
EOF
</nowiki></pre>
</pre>



==5. Reboot.==
==5. Reboot.==


= Using XCP =
= Using XCP =

Ensure that xapi is running with "service xapi status". If you don't get the response "* xapi is running", you will need to run "service xapi start".


Set up your path:
Set up your path:


<pre><nowiki>
<pre>
export PATH=$PATH:/usr/lib/xen-common/xapi/bin
export PATH=$PATH:/usr/lib/xen-common/xapi/bin
</nowiki></pre>
</pre>


Edit the /etc/xensource-inventory file to add your main interface as the management interface, and to tell the storage plugins where your main filesystem is located. It should have lines in approximating the following:

<pre><nowiki>
MANAGEMENT_INTERFACE='eth0'
PRIMARY_DISK='/dev/sda1'
</nowiki></pre>




Set up a storage repository. For now, I recommend NFS, or EXT if you have an unused block device. For example:
Set up a storage repository. For now, we recommend NFS, or EXT if you have an unused block device. For example:


<pre><nowiki>
<pre>
SR=`xe sr-create type=nfs name-label=nfs device-config:server=<nfs server> device-config:serverpath=<path on server>`
SR=`xe sr-create type=nfs name-label=nfs device-config:server=<nfs server> device-config:serverpath=<path on server>`
</nowiki></pre>
</pre>


or
or


'''Note: DANGER!!!''' The partition selected will be formatted, and all data on it wiped. Ensure that you select the device correctly and that you have backed up any existing information on this partition.
<pre><nowiki>
SR=`xe sr-create type=ext device-config:device=/dev/sda3 name-label=ext`
</nowiki></pre>


<pre>
SR=`xe sr-create type=ext device-config:device=/dev/sda3 name-label=ext`
</pre>


Set this as pool default SR:
Set this as pool default SR:


<pre><nowiki>
<pre>
POOL=`xe pool-list --minimal`
POOL=`xe pool-list --minimal`
xe pool-param-set uuid=$POOL default-SR=$SR
xe pool-param-set uuid=$POOL default-SR=$SR
</nowiki></pre>
</pre>


==<div id="ballooning-work-around">Memory and Dom0</div>==
There is a bug within the 3.0 series kernel that is shipped with Oneiric, but is fixed in the 3.2 kernel which should be shipped with Precious, where mis-reporting of memory leads xapi and squeezed to reduce (sometimes significantly!) the amount of memory available to Dom0.


''Note'': certain versions of the package which installed squeezed failed to set the relevant scripts to start it at boot. Ensure that you have the latest release, and that you have checked that squeezed is running -
To install windows, you'll need an iso. These can be served by an NFS server. Try this:
<pre>ps ax | grep sqeezed</pre>
- before completing the steps below.


Your Dom0 should never be set to consume all of your physical memory (otherwise - where would guest VMs run?), but if, on initially running xapi, you notice that performance has suddenly dropped significantly, check the amount of memory available via <pre>cat /proc/meminfo</pre> (MemTotal, quoted in bytes). If this seems ridiculously low, then you will need to set hard parameters for the amount of memory assigned to Dom0. First you need to find the uuid of Dom0 thus:
<pre><nowiki>
xe-mount-iso-sr nfs-server:/path/to/isos
</nowiki></pre>


<pre>
xe vm-list
</pre>


The first entry should look at little like this:
Then create a windows VM:
<pre>
uuid ( RO) : f5d0039b-1138-4635-c153-6203bfdc330f
name-label ( RW): Control domain on host: piggy
power-state ( RO): running
</pre>
We will use this as an example.


Next, you need to decide how much memory to give Dom0. In our example, we are going to give it 2 GiB. Run the following commands, substituting the correct uuid and memory parameters:
<pre><nowiki>
<pre>
xe vm-install template=Windows\ 7\ \(32-bit\) new-name-label=windows
xe vm-param-set uuid=f5d0039b-1138-4635-c153-6203bfdc330f memory-dynamic-max=2GiB
xe vm-cd-add vm=windows cd-name=win7.iso device=3
xe vm-param-set uuid=f5d0039b-1138-4635-c153-6203bfdc330f memory-dynamic-min=2GiB
xe vm-start vm=windows
</nowiki></pre>
</pre>
Note that this will work around the problem, but will not allow Xen to adjust the amount of memory available to Dom0 automatically. Reboot your machine (start squeezed manually if required), and check meminfo again. Note that you will not see the entire amount of memory assigned - some will be used - but you can now balance this correctly.




==Install a Guest==
To get networking working, you'll need to manually set up the bridge:


Now that you have XCP set up, you probably want to install some guests. We provide examples of how to set up a Windows guest or a Linux guest. You can, of course, mix and match.
<pre><nowiki>
* [[Installing Linux on Kronos]]
brctl addbr xenbr0
* [[Installing Windows on Kronos]]
brctl addif xenbr0 eth0
</nowiki></pre>



You may need to move the IP address to the bridge rather than the physical interface. Having done this, try a pif-scan:


<pre><nowiki>
xe pif-scan
</nowiki></pre>


This might create the network for your interface.

== PV drivers for Windows ==


<pre><nowiki>
wget http://downloads.xen.org/XCP/debian/xs-tools-5.9.960.iso
mv xs-tools-5.9.960.iso /usr/lib/xen-common/xapi/packages/iso
</nowiki></pre>


After doing this, rescan the SR to pick up the new ISO.


= Compiling from source =
= Compiling from source =
Line 191: Line 184:




<pre><nowiki>
<pre>
apt-get install pbuilder debhelper dh-ocaml dh-autoreconf cdebootstrap python-debian mercurial git
apt-get install pbuilder debhelper dh-ocaml dh-autoreconf cdebootstrap python-debian mercurial git
wget http://downloads.xen.org/XCP/debian/blktap-dkms_0.1_all.deb
wget http://downloads.xen.org/XCP/debian/blktap-dkms_0.1_all.deb
dpkg -i blktap-dkms_0.1_all.deb
dpkg -i blktap-dkms_0.1_all.deb
</nowiki></pre>
</pre>




Line 201: Line 194:




<pre><nowiki>
<pre>
git clone https://github.com/jonludlam/xapi-autobuilder.git
git clone https://github.com/jonludlam/xapi-autobuilder.git
cd xapi-autobuilder
cd xapi-autobuilder
make clean ; make
make clean ; make
</nowiki></pre>
</pre>




Line 213: Line 206:




<pre><nowiki>
<pre>
wget -r -l1 --no-parent -nd http://downloads.xen.org/XCP/debian/latest/
wget -r -l1 --no-parent -nd http://downloads.xen.org/XCP/debian/latest/
rm index.html*
rm index.html*
</nowiki></pre>
</pre>

[[Category:XCP]]
[[Category:HowTo]]
[[Category:Design Document]]
[[Category:Developers]]
[{Category:Users]]

Latest revision as of 16:55, 23 December 2011


Installing Xapi on Ubuntu Oneiric

This is Project Kronos. Follow these instructions to get xapi, the XenAPI server daemon, installed on an Ubuntu Oneiric box, using the upstream Linux kernel. This will effectively allow you to turn an existing Ubuntu machine into an XCP host. Note that this is *very much* a work-in-progress. Some features will be broken, and there will be a bit of manual configuration required. We appreciate any testing you do for this project, but please don't consider this production ready yet! Please visit the Kronos Supported Features page for a list of XCP features that are known to work on Kronos.

What's the best environment?

The best environment is a clean installed modern system with significant amounts of RAM in it and several cores. However, this guide is written in the knowledge that not everyone will be in the lucky position of having such a box to play with. In fact, many of us will be installing it on a moderately-sized box with an existing (upgraded) version of Ubuntu running. One of the authors of this guide (MikeCamel) is in exactly that position, so you are not alone. Hopefully this guide will be relevant to you, and will provide working instructions. If you have a problem, let us know.

Warnings - README

You need to read these warnings. If you don't, you could do serious damage to your system, leave it unbootable, be surprised when things don't work as you expect (or at all), and generally fail to create World Peace[tm]. And that would be a pity.

An important note: don't be tempted to install any kernel (via apt, for instance) which ends in "-virtual" during this process. Such kernels are intended to run as Guests (that is, "VMs"), and are not configured to be used as the Dom0 kernel. You will run into particular problems if you try this on a system which uses an Nvidia card, as the nvidia-current drivers do not currently seem to compile against these kernels, and you will therefore not be able to start X correctly. Given the standard Oneiric start up and splash screens, this isn't a particularly easy problem to fix, so avoid it in the first place!

Another important note: the instructions on this page assume that:

  • you know what you are doing with Linux, and are able to repair any issues that might arise as a result of following (or mis-following...) the instructions;
  • you are running as root. If you don't know what this entails, then see 1. above, and seek further help from the community before proceeding.

A couple of network-related notes

  1. XAPI expects to run in a clean environment, and listens on ports 80 and 443. If you're running anything else on these ports (typically Apache/Apache2), then you're likely to have problems.
  2. There is a known bug (which needs to be fixed) which means that in certain circumstances when you are using VPN software (e.g. when you have a tun0 interface listed in ifconfig), xapi will fail. Please ensure that you remove all such software before attempting to run xcp-xapi.

And a note about kernels Kronos is really aimed at Precise Pangolin (Ubuntu 12.04), which will include the 3.2 kernel. There is a nasty bug in the 3.0 series (and probably before) which means that, between them, a couple of the components of Xen are going to reduce the size of Dom0 (and therefore your main operating environment) to something under 1 GiB, which may cause you significant problems. There are work-arounds (TODO: provide work-arounds...), but this is a real issue if you're planning to run Kronos on Oneiric. There is a work-around described below.

1. Install Ubuntu Oneiric

Kronos will work with either Ubuntu Oneiric Server or Desktop, with the default kernel. If you want to use local storage, you will have to reserve an unformatted partition on your hard disk for xapi. In a later step, you will use this partition to create a local storage repository.

2a. Set up the Kronos PPA ...or...

Add the following to /etc/apt/sources.list

deb http://ppa.launchpad.net/ubuntu-xen-org/xcp-unstable/ubuntu oneiric main
deb-src http://ppa.launchpad.net/ubuntu-xen-org/xcp-unstable/ubuntu oneiric main

2b. ... Use a Kronos Debian repository

apt-get install curl echo "deb http://downloads.xen.org/XCP/debian/repo/debian unstable main" > /etc/apt/sources.list.d/kronos.list echo "deb-src http://downloads.xen.org/XCP/debian/repo/debian unstable main" >> /etc/apt/sources.list.d/kronos.list wget --quiet -O - http://downloads.xen.org/XCP/debian/xcp.gpg.key | apt-key add - 

3. Install xapi

This step installs XCP's xapi and all its dependencies, including the Xen hypervisor.


apt-get update
apt-get install xcp-xapi
apt-get install xcp-xe


Once you've installed these packages, you can just do an `apt-get update && apt-get upgrade` to keep up with the latest builds.

4. Post-install setup

a) Optional: Make xen the default grub entry.

sed -i 's/GRUB_DEFAULT=""/GRUB_DEFAULT="Xen 4.1-amd64"/' /etc/default/grub
update-grub

Note: given the default set up for Ubuntu's grub (in /etc/default/grub), you don't get to see the splashscreen with kernel boot options. If you do want to see the list of options, you may need to change some of the settings in this file.

b. Setup the network/interfaces file:

This is likely to be /etc/network interfaces - ensure that you don't remove any existing settings. Note that if you are running a DHCP server on this machine, then you may need to change the xenbr0 interface to a static or manual IP address, as DHCP may not come up in time to provide an address otherwise.

auto lo xenbr0

iface xenbr0 inet dhcp
        bridge_ports eth0 

c. Setup the xensource-inventory file:

Note: this assumes that the root partition is on /dev/sda1 - change if required. Note: this assumes that your management interface will be xenbr0 - change if required.

control_domain=`uuidgen`
installation=`uuidgen`

cat > /etc/xcp/xensource-inventory << EOF
CURRENT_INTERFACES='xenbr0'
BUILD_NUMBER='0'
CONTROL_DOMAIN_UUID='${control_domain}' 
INSTALLATION_UUID='${installation}'
MANAGEMENT_INTERFACE='xenbr0'
PRIMARY_DISK='/dev/sda1'
EOF

5. Reboot.

Using XCP

Ensure that xapi is running with "service xapi status". If you don't get the response "* xapi is running", you will need to run "service xapi start".

Set up your path:

export PATH=$PATH:/usr/lib/xen-common/xapi/bin


Set up a storage repository. For now, we recommend NFS, or EXT if you have an unused block device. For example:

SR=`xe sr-create type=nfs name-label=nfs device-config:server=<nfs server> device-config:serverpath=<path on server>`

or

Note: DANGER!!! The partition selected will be formatted, and all data on it wiped. Ensure that you select the device correctly and that you have backed up any existing information on this partition.

SR=`xe sr-create type=ext device-config:device=/dev/sda3 name-label=ext` 

Set this as pool default SR:

POOL=`xe pool-list --minimal`
xe pool-param-set uuid=$POOL default-SR=$SR

Memory and Dom0

There is a bug within the 3.0 series kernel that is shipped with Oneiric, but is fixed in the 3.2 kernel which should be shipped with Precious, where mis-reporting of memory leads xapi and squeezed to reduce (sometimes significantly!) the amount of memory available to Dom0.

Note: certain versions of the package which installed squeezed failed to set the relevant scripts to start it at boot. Ensure that you have the latest release, and that you have checked that squeezed is running -

ps ax | grep sqeezed

- before completing the steps below.

Your Dom0 should never be set to consume all of your physical memory (otherwise - where would guest VMs run?), but if, on initially running xapi, you notice that performance has suddenly dropped significantly, check the amount of memory available via

cat /proc/meminfo

(MemTotal, quoted in bytes). If this seems ridiculously low, then you will need to set hard parameters for the amount of memory assigned to Dom0. First you need to find the uuid of Dom0 thus:

xe vm-list

The first entry should look at little like this:

uuid ( RO)           : f5d0039b-1138-4635-c153-6203bfdc330f
     name-label ( RW): Control domain on host: piggy
    power-state ( RO): running

We will use this as an example.

Next, you need to decide how much memory to give Dom0. In our example, we are going to give it 2 GiB. Run the following commands, substituting the correct uuid and memory parameters:

xe vm-param-set uuid=f5d0039b-1138-4635-c153-6203bfdc330f memory-dynamic-max=2GiB
xe vm-param-set uuid=f5d0039b-1138-4635-c153-6203bfdc330f memory-dynamic-min=2GiB

Note that this will work around the problem, but will not allow Xen to adjust the amount of memory available to Dom0 automatically. Reboot your machine (start squeezed manually if required), and check meminfo again. Note that you will not see the entire amount of memory assigned - some will be used - but you can now balance this correctly.


Install a Guest

Now that you have XCP set up, you probably want to install some guests. We provide examples of how to set up a Windows guest or a Linux guest. You can, of course, mix and match.


Compiling from source

The easiest way to compile the XCP toolstack from source is to use the xapi-autobuilder.

First install the perquisites:


apt-get install pbuilder debhelper dh-ocaml dh-autoreconf cdebootstrap python-debian mercurial git
wget http://downloads.xen.org/XCP/debian/blktap-dkms_0.1_all.deb
dpkg -i blktap-dkms_0.1_all.deb


Then clone xapi-autobuilder and build:


git clone https://github.com/jonludlam/xapi-autobuilder.git
cd xapi-autobuilder
make clean ; make


This will build all of the required Debian packages for Xapi (except for vncterm, which is only available as a binary until we sort out licensing issues). Take a look at xapi-autobuilder/build.sh to see what's going on inside. You can modify the files git-repos and hg-repos to point to your own repositories if you plan on compiling your own code. If you only want to build a subset of the packages, comment out the ones you don't want to build from the build.sh script.

You can manually download all of the latest packages and source packages using:


wget -r -l1 --no-parent -nd http://downloads.xen.org/XCP/debian/latest/
rm index.html*