Installing and configuring Cloudstack 4.6 management server on Raspberry Pi 2
This document assumes that you have -at least- basic familiarity with Linux operating systems in general and also some familiarity with Ubuntu distributions, and have the minimum necessary hardware ready: which is two Raspberry Pi model-2, micro USB power adapters, 2 x micro SD cards with minimum 8 GB of space, a 4 port switch, network cables and internet connection.

Installing Cloudstack management server:

 

1. Download Ubutnu 14.04 LTS (Trusty Tahr) image and write to the micro SD card. You need a micro SD card with minimum 8 GB space.
Download the image here:
https://wiki.ubuntu.com/ARM/RaspberryPi

Alternatively you can download the image from claspi.org (mirror):
http://www.claspi.org/downloads/images/2015-04-06-ubuntu-trusty.zip

Extract the zip file and follow the instructions below to write the image on the micro SD card:
Linux
Mac OS
Windows

You need a HDMI cable and keyboard connected to Raspberry Pi at this stage. Login to Raspberry Pi by:
Username: ubuntu
Password: ubuntu

 

2. Configure network with static IP address:
In this document and examples, 192.168.2.120 IP address is used for the Cloudstack management server and 192.168.2.121-122 and so on for Hypervisors, assuming 192.168.2.254 is the gateway. Please change all the IP addresses in the commands if you run the setup with an alternative IP address/gateway. After installation of Cloudstack management server, changing the IP address or gateway is not possible.
Also using “nano” as the text editor is not mandatory and feel free to use any EOTM (editor of the month) for editing your files.

$sudo nano /etc/network/interfaces
[sudo] password for ubuntu: (type "ubuntu" as password)

Edit eth0 interface as follows:

...
# The primary network interface
iface eth0 inet static
address 192.168.2.120
netmask 255.255.255.0
gateway 192.168.2.254
network 192.168.2.0
broadcast 192.168.2.255
dns-nameservers 8.8.8.8 8.8.4.4

Save and close. (in nano: CTRL-x -> y -> Enter)
You can reboot Raspberry now and continue by SSH terminal instead of a direct console (ssh connect to 192.168.2.120)

$sudo reboot

Login to Raspi again and ping a website to check the internet connection and dns resolution:

$ping www.google.com

 

3. Install OpenSSH

$sudo apt-get install openssh-server

This command takes about 2 minutes to complete.
From now on you can connect to 192.168.2.120 using an SSH terminal application (e.g. putty)

 

4. Install OpenNtpd:

$sudo apt-get install openntpd

 

5. Resize the flash partition to the maximum size of the micro SD card:

Determine the storage devices: (we see in the result below that /dev/mmcblk0 is the storage device)

$ll /dev/mm*
brw-rw---- 1 root disk 179, 0 Jan  1 00:00 /dev/mmcblk0
brw-rw---- 1 root disk 179, 1 Jan  1 00:00 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Jan  1 00:00 /dev/mmcblk0p2

Print the partition table:

$ sudo parted /dev/mmcblk0
GNU Parted 2.3
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit chs
(parted) print
Model: SD 00000 (sd/mmc)
Disk /dev/mmcblk0: 1947,203,47
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1947,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start    End         Type     File system  Flags
 1      0,32,32  8,73,0      primary  fat16        boot, lba
 2      8,73,1   228,114,13  primary  ext4

(parted)

The root partition starts at 8, 73,1 and should end at 1947,203,47.
Important: this is just an example, depending on the size of your micro SD cards, these geometry may vary. Do not copy paste command below, you need to modify the geometry in your commands first. Continue by removing partition 2:

(parted) rm 2
Warning: Partition /dev/mmcblk0p2 is being used. Are you sure you want to continue?
Yes/No? Y
Error: Partition(s) 2 on /dev/mmcblk0 have been written, but we have been unable to
inform the kernel of the change, probably because it/they are in use. As a result,
the old partition(s) will remain in use. You should reboot now before making further
changes.
Ignore/Cancel? I
(parted) print
Model: SD 00000 (sd/mmc)
Disk /dev/mmcblk0: 1947,203,47
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1947,255,63. Each cylinder is 8225kB.
Partition Table: msdos

Number Start End Type File system Flags
 1 0,32,32 8,73,0 primary fat16 boot, lba

Now we need to create partition 2 again:

(parted) mkpart primary 8,73,1 1947,203,47 
(do not copy paste this command. 
You need to change the start and end cylinder of the partition based on the info above) 

(parted) print
Model: SD 00000 (sd/mmc)
Disk /dev/mmcblk0: 1947,203,47
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 1947,255,63.  Each cylinder is 8225kB.
Partition Table: msdos

Number  Start    End          Type     File system  Flags
 1      0,32,32  8,73,0       primary  fat16        boot, lba
 2      8,73,1   1947,203,47  primary  ext4

(parted) quit

Reboot:

$sudo reboot

Extend the root partition to the max size:

$sudo resize2fs /dev/mmcblk0p2

Check the patition size:

$df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2   15G  1.5G   13G  11% /
devtmpfs        458M  4.0K  458M   1% /dev
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none             93M  256K   93M   1% /run
none            5.0M  8.0K  5.0M   1% /run/lock
none            462M     0  462M   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/mmcblk0p1   64M   17M   48M  27% /boot/firmware

Now we see that /dev/mmcblk0p2 (root) has the size of 15G (in this example we have a 16GB micro SD card)

 

6. Add a swap file of 1GB:
Follow these commands:

$sudo fallocate -l 1G /swapfile
$sudo chmod 600 /swapfile
$sudo mkswap /swapfile
Setting up swapspace version 1, size = 1048572 KiB 
no label, UUID=...
$sudo swapon /swapfile

Edit fstab:

$sudo nano /etc/fstab

Add the following line to fstab to make the swap file permanent:

/swapfile   none    swap    sw    0   0

Save and close.

7. Configure hostname to fqdn:

$sudo nano /etc/hosts

Change 127.0.0.1 to a fully qualified domain name, it means change “ubuntu” to a name like “ubuntu.mydomain.local” (in this example we will nanocloud.claspi.org as our fqdn name)

127.0.0.1    nanocloud.claspi.org

Edit /etc/hostname file with fqdn name

$sudo nano /etc/hostname

Change hostname from “ubuntu” to “nanocloud.claspi.org”

nanocloud.claspi.org

Save and close, then reboot Raspberry Pi for the change to take effect.

$sudo reboot

After reboot is complete, use hostname command to check the hostname:

$hostname --fqdn
>nanocloud.claspi.org

 

8. Configure your Raspi to use the claspi.org APT repository

Before being able to install cloudstack-management from claspi.org repository you need to add the repo to your source list.

$sudo nano /etc/apt/sources.list.d/cloudstack.list

This file (cloudstack.list) is new and empty. Add the following line to the beginning of the file:

deb http://www.claspi.org/cloudstack/repo/binary ./

Save and close.

Alternatively you can download the edited cloudstack.list file from here, by the following command:

$sudo wget -P /etc/apt/sources.list.d http://www.claspi.org/downloads/files/cloudstack.list

 

9. Update apt sources and upgrade Linux:

It is best practice that before installing cloudstack-management server, update your Ubuntu server:

$sudo apt-get update
$sudo apt-get upgrade
$sudo apt-get dist-upgrade

These commands takes about 10-15 minutes to complete. Reboot after this step:

$sudo reboot

 

10. Install Java Open JDK 7:
Cloudstack management server is a Java tomcat6 servlet engine and needs OpenJDK 7, install it by:

$sudo apt-get install openjdk-7-jdk

The installation takes about 5 minutes to complete.

 

11. Install Mysql server:
In this example we use password “ubuntu” for installing mysql server. If you use another password, you need to modify the database installation command too.

$sudo apt-get install mysql-server

The installation takes about 3 minutes to complete.

 

12. Configure Mysql server:

Edit my.cnf (mysql configuration file)

$sudo nano /etc/mysql/my.cnf

Add the following lines after the line 40 (datadir = /var/lib/mysql)

innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'

Alternatively you can download the edited my.cnf file from here, by the following command:

$sudo wget http://www.claspi.org/downloads/files/my.cnf -O /etc/mysql/my.cnf

Restart mysql server:

$sudo service mysql restart

 

13. Install cloudstack management service:
Now that claspi.org repository of cloudstack 4.6 management server is added to the apt sources, you can install cloudstack-management server by apt-get:

$sudo apt-get install cloudstack-management
 WARNING: The following packages cannot be authenticated
 cloudstack-common cloudstack-management
 Install these packages without verification? [y/N] y

This will take about 3 minutes to complete.
DO NOT START cloudstack-management service after installation.

 

14. Configure tomcat6 to use OpenJDK 7 and set Java memory parameters
We need to define JAVA_HOME variable for tomcat6 and configure Java memory settings:

$sudo nano /etc/cloudstack/management/tomcat6-nonssl.conf

Change JAVA_HOME variable on line 31 to:

JAVA_HOME="/usr/lib/jvm/java-1.7.0-openjdk-armhf"

Change Java Xms memory to 512m and Xmx to 768m, by changing line 44:

JAVA_OPTS="-Djava.awt.headless=true -Dcom.sun.management.jmxremote=false
 -Xmx768m -Xms512m -XX:+HeapDumpOnOutOfMemoryError
 -XX:HeapDumpPath=/var/log/cloudstack/management/
 -XX:PermSize=512M -XX:MaxPermSize=800m
 -Djava.security.properties=/etc/cloudstack/management/java.security.ciphers"

Alternatively you can download the edited tomcat6-nonssl.conf file from here, by the following command:

$sudo wget http://www.claspi.org/downloads/files/tomcat6-nonssl.conf 
-O /etc/cloudstack/management/tomcat6-nonssl.conf

 

15. Prepare mysql database:
Create and configure cloudstack mysql database:
Important: if you changed the IP address or Mysql password you need to modify the below command too.

$sudo cloudstack-setup-databases cloud:ubuntu@localhost 
--deploy-as=root:ubuntu -i 192.168.2.120

This steps takes about 2 minutes to complete. If all ok, you will get the following message:

CloudStack has successfully initialized database, you can check your database
configuration in /etc/cloudstack/management/db.properties

 

16. Setup Cloudstack management server:
Now we are all done, and just need to setup cloudstack-management and start it.

$sudo cloudstack-setup-management

This steps takes about 2 minutes to complete.

Cloudstack management server on Raspberry Pi 2 takes 15 to 20 minutes to start and load all the plugins, so you need to be patient. You can check the startup process by:

$sudo tail -f /var/log/cloudstack/management/management-server.log

Use CTRL-c to exit from tail command.
During the startup, JSVC process tops to 100% cpu and after the startup is complete, goes down to 2 or 3% which is a good indicator when the startup is completed.
Do not start the web client before the management startup is completed.

After startup is complete, you can reach the web interface (api client) on:
http://192.168.2.120:8080/client
Username: admin
Password: password

For more detail on administration of a Cloudstack environment please refer to the following pages:
http://docs.cloudstack.apache.org/projects/cloudstack-administration/en/4.5/

 

17. (optional) Edit cloudstack-management init script

Because the issue #1 mentioned in the KNOWN ISSUES section happens too frequently, you might want to fix it permanently by editing cloudstack-management init script and purge tomcat cache folders upon service startup:

$sudo nano /etc/init.d/cloudstack-management

Edit line 138 and add the following lines:

...
case "$1" in
 start)
 rm -R /usr/share/cloudstack-management/work/*
 rm -R /var/cache/cloudstack/management/work/*
 rm -R /var/lib/tomcat6/work/*

 if [ -z "$JAVA_HOME" ]; then
...

Alternatively you can download the edited cloudstack-management init script from here, by the following command:

$sudo wget http://www.claspi.org/downloads/files/cloudstack-management -O /etc/init.d/cloudstack-management

Restart cloudstack-management server:

$sudo service cloudstack-management restart

 

 


KNOWN ISSUES:*

#1 – After startup is complete, you can’t reach the interface login page.
Tomcat returns exception: “Unable to compile class for JSP”:


Cause: this is caused by outdated or corrupt  .jar files in the tomcat cache folder, you can purge the cache folders and restart cloudstack-management:

$sudo service cloudstack-management stop
$sudo rm -rf /usr/share/cloudstack-management/work/*
$sudo rm -rf /var/cache/cloudstack/management/work/*
$sudo rm -rf /var/lib/tomcat6/work/*
$sudo service cloudstack-management start

 

#2– When connecting to the web interface using Google Chrome; about 30 seconds after clicking on the”login” button, you might receive an error that “page is unresponsive”. Just click on “wait” and after about 10 seconds the management page appears.

#3-  Command “apt-get update” returns the following error:
W: Failed to fetch http://www.claspi.org/cloudstack/repo/binary/./Release.gpg  Error reading from server. Remote end closed connection.
That is because release.gpg and keys are not uploaded to repo yet. You can still use the repo for install the management and agent.
Please ignore this error and move forward for now (until I fix it)

 

* If you have any issues other than mentioned in the KNOWN ISSUES section, please raise them as a comment to this page. I will try to solve and/or answer them as my knowledge permits.


Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>