Climbing into the cloud with Apache CloudStack

Setting Up an Initial Cluster

The best way to get started with CloudStack is to set up a small cluster. The host I used for this example is a fairly powerful workstation running Ubuntu 14.04. In addition to having sufficient RAM and hard disk space, the system also supports hardware-accelerated virtualization. In this article, I describe how to set up the management server. Once you get the management server running, you will find it is easy to set up the virtual machines.

As a first step, download the Network Time Protocol application OpenNTP. CloudStack assumes the clocks on all of the computers are in sync:

sudo apt-get install openntpd

Fortunately, you don't need to build CloudStack from scratch because Apache has a repository with prebuilt packages for Debian. Create an /etc/apt/sources.list.d/cloudstack.list file with the following content:

deb precise 4.4

You need a full-fledged root shell to add the repository key. In the case of Ubuntu, you can use sudo su:

# wget -O -|apt-key add
# apt-get update
# apt-get install cloudstack-management cloudstack-agent

Note that both cloudstack-management and cloudstack-agent come with a large number of dependencies. If your Internet connection is slow, you can expect an interruption of several minutes. The next step is to download the MySQL service for your storage database:

apt-get install mysql-server

Apt-get will prompt you during deployment for a root password – in the following steps, I have used dbpw. Now open the configuration file, /etc/mysql/my.cnf, in your choice of editor. Go to the [mysqld] section, and set the following parameter. The snippet here assumes that the database only needs to support one management server – each server can cause up to 350 simultaneous connections:

binlog-format = 'ROW'

After saving the entries, you need to restart the database (service mysql restart) in order to apply the new settings. The actual deployment of the schema is then handled using a tool provided by CloudStack:

cloudstack-setup-databases cloud:dbpw@localhost -deploy-as=root:dbpw -i <Server-IP-Address>

Some recent MySQL versions suffer from a bug that rears its ugly head on processing the installation command. But unfortunately, a fix is not on the roadmap until CloudStack 4.6. To fix the bug, open the file /usr/share/cloudstack-management/setup/create-schema-premium.sql in an editor. Then change the lines shown in Listing 1 (`cloud`. prefix added) and restart the command. You should then see:

Applying /usr/share/cloudstack-management/setup/templates.sql [ OK ]
Processing encryption ... [ OK ]
Finalizing setup ... [ OK ]
CloudStack has successfully initialized database, check your database configuration in /etc/cloudstack/management/

The configuration shown here ignores the security functions implemented in CloudStack. You can encrypt the database if needed to hide the passwords and other information in its stores – see the Installation Guide for more details.

Listing 1

MySQL Bug Fix


Working Without a Host

If you do not want to create a host in the Wizard-supported setup, just enter meaningless information in the host window. The wizard will create a zone, a pod, and all the rest but stop before setting up the host. Wait until the session times out – the next time you log in, you will be taken to the management window. Note that you cannot set up your primary and secondary storage until you have registered a host.

Adding Storage

Before you can use the CloudStack management server, you need to set up the storage infrastructure. To do so, create the two folders for primary and secondary export and then download the NFS server package:

mkdir -p /export/primary /export/secondary
apt-get install nfs-kernel-server

Open the /etc/exports file and add the following:

/export *(rw,async,no_root_squash,no_subtree_check)

Apache CloudStack co-developer Rohit Yadav published the commands in his blog that automate the further configuration of the NFS server on Ubuntu (Listing 2).

Listing 2

Automating the NFS Configuration


The exportfs -a command should run without any problems. In the case of very large images, another couple of changes are required [3]. First, create two mountpoints; then, mount the two NFS directories. This setup is useful for testing the server configuration:

mkdir -p /mnt/primary /mnt/secondary
mount -t nfs Server:/export/primary /mnt/primary
mount -t nfs Server:/export/secondary /mnt/secondary

If the mount process does not complete successfully, the NFS server is not configured correctly.

To launch the management server, you need a system image. CloudStack comes with a script that automatically downloads the 5GB image from the Internet. The following command creates an environment that is suitable for KVM – see the Installation Guide [1] for more details:

/usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
  -m /mnt/secondary \
  -u \
  -h kvm -F

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95