Xen, XCP, XAPI and Openstack Setup on Ubuntu 12.04

Installation of Xen, XAPI (XenAPI) and Openstack on Ubuntu 12.04

XCP ( Xen Cloud Platform ) is the open source version similar to Citrix XenServer that uses the Xen Hypervisor. XCP uses XAPI or XenAPI to manage Xen hosts. XCP is based on CentOS 5.5 . Project Kronos is an initiative to port the XAPI tool stack to Debian and Ubuntu. It is a management stack implemented in OCaml that configures and controls Xen hosts, attached storage, networking and virtual machine life cycle. It exposes a command line interface (xe) for management.

Requirements:

Ubuntu 12.04 server

Small root file system partition and have a large space dedicated for a LVM volume.

Installing and configuring Xen Hypervisor

1. Install the Xen Hypervisor

# apt-get install xen-hypervisor

2. Setup GRUB to boot the Xen Hypervisor

# sed -i ‘s/GRUB_DEFAULT=.*+/GRUB_DEFAULT=”Xen 4.1-amd64?/’ /etc/default/grub

3. Disable apparmor at boot

 # sed -i ‘s/GRUB_CMDLINE_LINUX=.*+/GRUB_CMDLINE_LINUX=”apparmor=0?/’ /etc/default/grub

4. Restrict dom0 to 2GB of memory and 2 vcps

# vi /etc/default/grub

after GRUB_CMDLINE_LINUX=”apparmor=0? add line

GRUB_CMDLINE_XEN=”dom0_mem=2G,max:2G dom0_max_vcpus=2?

5. Update Grub with the config changes we just made

#  update-grub

6. Reboot the server so that Xen boots on the server

# reboot

7. Once the server is back online ensure that Xen is running
cat /proc/xen/capabilities should display “control_d”

Installing and configuring XAPI (XenAPI)

1. Install XCP-XAPI

# apt-get install xcp-xapi

– choose bridge when prompted for network backend

2. Setup the default toolstack

# vi /etc/default/xen

– set ‘TOOLSTACK=xapi’

3. Disable xend from starting at boot

#  sed -i -e ‘s/xend_start$/#xend_start/’ -e ‘s/xend_stop$/#xend_stop/’ /etc/init.d/xend

NOTE: only xend the deamon needs to be disabled from starting, /etc/init.d/xend handles other things like modules and xenfs. Do not disable it from the runlevel

4. Disable service xendomains

#  update-rc.d xendomains disable

5. Fix for qemu which emulates the console does not have the keymaps in the correct location

#  mkdir /usr/share/qemu
#  ln -s /usr/share/qemu-linaro/keymaps /usr/share/qemu/keymaps

6. Setup bridge networking

# vi /etc/network/interfaces
# 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
iface lo inet loopback# The primary network interface
auto xenbr0
iface xenbr0 inet static
address
netmask
network
broadcast
gateway
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 4.2.2.2
bridge_ports eth0
iface eth0 inet manual

7. Configure xcp to use bridge networking instead of openswitch

# vi /etc/xcp/network.conf

replace “openswitch” with “bridge”

8. All set – ready to reboot and let xcp-xapi toolstack take over

# reboot

9. On restart – confirm that xcp is working

# xe vm-list
uuid ( RO) : 92ddb581-e6a8-2e6d-045e-d35b22f01668
name-label ( RW): Control domain on host: ramanujan
power-state ( RO): running

If your output looks similar – xapi is running on the server, if you get “Connection refused” then xapi is not setup correctly

Setting up the LVM storage volume for creating storage repository:

1) You need one partition to create storage repository, it can be LVM,

# fdisk -l
This should list a partition of type “Linux LVM”.

If you dont have partition but have free space to create it then follow steps.

2. create a physical volumes

# pvcreate /dev/my-physical-volume
# pvdisplay

You should see similar output

“/dev/my-physical-volume? is a new physical volume of “947.60 GiB”
— NEW Physical volume —
PV Name /dev/my-physical-volume
VG Name
PV Size 947.60 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID rNeGnf-TbJS-vfSm-t7la-wNCv-Lpc3-vjn33c

3. create a volume group
# vgcreate VolumeGroup /dev/my-physical-volume
# pvdisplay – this should display the volume group we created on the physical volume
— Physical volume —
PV Name /dev/my-physical-volume
VG Name VolumeGroup
PV Size 947.60 GiB / not usable 2.90 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 242584
Free PE 242584
Allocated PE 0
PV UUID rNeGnf-TbJS-vfSm-t7la-wNCv-Lpc3-vjn33c

4. create a logical volume on “VolumeGroup”
# lvcreate –size 947G -n LocalStorage VolumeGroup
# lvdisplay

– this should display the logical volume we created on the volume group

— Logical volume —
LV Name /dev/VolumeGroup/LocalStorage
VG Name VolumeGroup
LV UUID pCWgAs-cpfh-IAdU-uVMi-EJbo-iy2x-TlMzar
LV Write Access read/write
LV Status available
# open 0
LV Size 947.00 GiB
Current LE 242432
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 252:0

5. Register the logical volume for use with XAPI
xe sr-create type=ext name-label=Local Storage device-config:device=/dev/mapper/VolumeGroup-LocalStorage

– this will take a while if the volume is large

# xe sr-list name-label=Local Storage
– this should display the storage repository

uuid ( RO) : 7dea0028-ee94-6c16-2f61-c699ed4a1d18
name-label ( RW): Local Storage
name-description ( RW):
host ( RO): ubuntu-xenserver-1
type ( RO): ext
content-type ( RO):

Setup openstack
Step 1 : Download devstack on dom0
# git clone git://github.com/openstack-dev/devstack.git
# cd devstack
Step 2: Configure your localrc inside the devstack directory
Devstack uses a localrc for user-specific configuration. Note that the XENAPI_PASSWORD must be your dom0 root password. Of course, use real passwords if this machine is exposed.
cat > ./localrc <<EOF
# Passwords
# NOTE: these need to be specified, otherwise devstack will try
# to prompt for these passwords, blocking the install process.

MYSQL_PASSWORD=my_super_secret
SERVICE_TOKEN=my_super_secret
ADMIN_PASSWORD=my_super_secret
SERVICE_PASSWORD=my_super_secret
RABBIT_PASSWORD=my_super_secret
SWIFT_HASH=”66a3d6b56c1f479c8b4e70ab5c2000f5″
# This will be the password for the OpenStack VM (both stack and root users)
GUEST_PASSWORD=my_super_secret

# XenAPI parameters
# NOTE: The following must be set to your XenServer root password!

XENAPI_PASSWORD=my_dom0_root_password
XENAPI_CONNECTION_URL=”http://address_of_your_dom0&#8243;
VNCSERVER_PROXYCLIENT_ADDRESS=address_of_your_dom0

# Download a vhd and a uec image
IMAGE_URLS=”\
https://github.com/downloads/citrix-openstack/warehouse/cirros-0.3.0-x86_64-disk.vhd.tgz,
http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gz&#8221;

# Explicitly set virt driver
VIRT_DRIVER=xenserver

# Explicitly enable multi-host for nova-network HA
MULTI_HOST=1

# Give extra time for boot
ACTIVE_TIMEOUT=45

EOF

Step 3: Run ./install_os_domU.sh from the tools/xen directory
# cd tools/xen
# ./install_os_domU.sh
Once this script finishes executing, log into the VM (openstack domU) that it installed and tail the run.sh.log file. You will need to wait until it run.sh has finished executing.

Create a directory in dom0
# mkdir -p /usr/etc/
Step 4: To access openstack dashboard
http://IP-of-new-openstack-domu

Step 5: To create new VM from openstack
1) Login
Username : stack
Password : get password from file : /root/devstack/localrc on dom0 , search for GUEST_PASSWORD=my_super_secret

2) Download ubuntu-server-cloud image
# cd /opt/stack/devstack/files
# wget https://cloud-images.ubuntu.com/releases/precise/release/ubuntu-12.04-server-cloudimg-amd64.tar.gz

3) Extract image
# cd /opt/stack/devstack/files/images
# mkdir ubuntu-precise
# cd ubuntu-precise
# tar -xzvf /opt/stack/devstack/files/precise-server-cloudimg-amd64.tar.gz
# source /opt/stack/devstack/openrc

4) Add the image to glance:
# glance image-create –name=ubuntu-precise-image –is-public=true –container-format=ami –disk-format=ami precise.pem
# chmod 600 precise.pem
6) Run (boot) a test instance:

# nova boot –image ubuntu-precise-image –flavor m1.tiny –key_name precise my-ubuntu-server

Here’s a description of the parameters used above:

–image: the name or ID of the image we want to launch, as shown in the output of nova image-list

–flavor: the name or ID of the size of the instance to create (number of vcpus, available RAM, available storage). View the list of available flavors by running nova flavor-list

-key_name: the name of the key to inject into the instance at launch.

7) Check the status of the instance you launched:

# nova list
After instance become ACTIVE, connect to it using :

ipaddress=… # Get IP address from “nova list”
ssh -i precise.pem -l ubuntu #ipaddress

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s