Running Apache Mesos on a Raspberry Pi 2

In this blog post I want to go through the steps which are needed to build and setup Apache Mesos on a Raspberry Pi 2. Why? You might ask - Because we can! Also there might be some interesting scenarios which you could realize with an ARM based Mesos cluster at home (e.g. home automation, media center app, your own HA web app, etc.)

Prerequisites & Preparation

From a hardware perspective I've been using a

  • Raspberry Pi 2 running Raspbian

In theory this might also work on a Pi 1, but I haven't tried it out yet.

Before we start, we need to do some house keeping. First of all we need some development libraries.

sudo apt-get install dh-autoreconf gcc-4.8 g++-4.8 cpp-4.8 \  
  libapr1-dev libsvn-dev python-dev

Next, we need to update the alternatives to the new gcc/g++ compiler.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20  
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20  
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30  
sudo update-alternatives --set cc /usr/bin/gcc  
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30  
sudo update-alternatives --set c++ /usr/bin/g++  

Since the we are building Mesos from source code, we will need a lot of RAM (in Raspberry terms). Therefore you should increase the swapfile up to 1GB to avoid running out of memory.

sudo su -c 'echo "CONF_SWAPSIZE=1024" > /etc/dphys-swapfile'  
sudo dphys-swapfile setup  
sudo dphys-swapfile swapon  

Set JAVA_HOME to the correct JVM

export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/  

Building Apache Mesos on a Raspberry Pi

Now it's time to build Mesos. First of all you need to clone the patched fork of the Mesos repository.

git clone https://github.com/rpi-cloud/mesos-on-arm.git  

The comparator_fix branch in this repository contains all the magic which is needed to build a runnable version of Mesos for ARM.

# Change working directory
cd mesos-on-arm

# Checkout the comperator fix branch
git fetch  
git checkout comparator_fix

# Run the bootstrap script
./bootstrap

# Configure and build
mkdir build  
cd build  
../configure
make  

Since the build will take a while (> 4 hours), run the make command in a screen/tmux session. Detach & and enjoy life! You can speed up the build process by using make -jX with 1 < X <= 4 but you might run into an out of memory situation that way.

Configuring & Running

Once the build is finished, it is time to validate the results. We will now spin up one master and one slave process to see if everything is working fine.

# Change into build directory
cd build

# Start mesos master (Ensure work directory exists and has proper permissions)
./bin/mesos-master.sh --ip=127.0.0.1 --work_dir=/var/lib/mesos

# Start mesos slave
./bin/mesos-slave.sh --master=127.0.0.1:5050

# Visit the mesos web page
curl http://127.0.0.1:5050  

You can also visit the master web UI (http://IP-OF-YOUR-RASPBERRY:5050) via a browser of your choice.

Voila!

Conclusion and Outlook

Ok, I've build Mesos on ARM and I can start it - somehow. What's next? Now comes the tricky part of configuring the setup in a distributed fashion and validating some of the Mesos frameworks.

Here are a few things which I (partially) tried out and which I want to cover in one of the next blog posts.

  • What about Zookeeper? Yes, you will need that if you want to do serious business on your Mesos cluster.
  • Fiddeling around with the containerizer (cgroup isolation vs POSIX vs etc.) to schedule at task
  • Installing and running Marathon
  • Scheduling a simple application on your Mesos cluster
  • Rebasing the code to the master (version 0.26 is out now)

References

Andreas Fritzler

Data Jedi | Cloud and Big Data Expert | Machine Learning Enthusiast | Deep Learning Fanatic @SAP Opinions are my own