Distributed Database

This is a trial of distributed database for home automation use.
Status: under development (just my notes here yet)

GaianDB

Base system installation

Download, write, and boot latest Raspbian image: http://www.raspberrypi.org/downloads/
Basic updates:

sudo raspi-config
sudo apt-get update
sudo apt-get upgrade

Install mosquitto:

sudo apt-get install mosquitto

Download gaiandb from IBM: https://www.ibm.com/developerworks/community/groups/service/html/communityview?communityUuid=f6ce657b-f385-43b2-8350-458e6e4a344f.
At the time of writing the latest version is 1.5.

Unzip to target folder. In this example /home/pi/gaiandb is assumed.

Follow installation instructions from the package. Download ia92.zip, extract and copy J2SE/wmqtt.jar to gaiandb/lib/

Enable broker in gaian_config.properties:

MSGBROKER_HOST=127.0.0.1
MSGBROKER_PORT=1883
MSGBROKER_TOPIC=gdb/sensor/#
MSGSTORER_ROWEXPIRY_HOURS=24
MSGSTORER_MSGCOLS=VALUE REAL
BROKER_DS0_CONNECTION=LOCALDERBY BROKER_MSGS

Add $GDBL/wmqtt.jar to $CLASSPATH in launchGaianServer.sh.

Create boot script in /etc/init.d.

RethinkDB

Since version 1.12, RethinkDB has had experimental ARM support. As of now with version 1.13, the support is still experimental.

http://www.rethinkdb.com/

BeagleBone Black

Installation

Platform

Rev B has only 2GB internal eMMC flash. Debian takes it all, thus must boot from SD card. Revision C has 4GB internal Flash.

Latest Debian SD-card image: http://beagleboard.org/latest-images (as of now Debian 7.5 2014-05-14).

Write SD card and boot BBB. Default login: debian/temppwd.

Resize file system partition in case of boot from SD: http://elinux.org/Beagleboard:Expanding_File_System_Partition_On_A_microSD.

sudo fdisk /dev/mmcblk0
d - 2 - n - p - 2 - w
sudo reboot
sudo resize2fs /dev/mmcblk0p2

Make it up to date:

sudo apt-get update
sudo apt-get upgrade

By default, there is no swap partition. The 512M of RAM memory is not enough for compilation, thus a 1GB swap is needed. Create a swap file http://elinux.org/BeagleBoardUbuntu#Using_a_File_for_Swap_Instead_of_a_Partition Using integrated eMMC flash would be faster, but in order to avoid wearing the integrated flash within this trial, let's create the swap file on SD card. That definitely slows down the build.

sudo su
mkdir -p /var/cache/swap/
dd if=/dev/zero of=/var/cache/swap/swapfile bs=1M count=1024
chmod 0600 /var/cache/swap/swapfile 
mkswap /var/cache/swap/swapfile
swapon /var/cache/swap/swapfile
echo "/var/cache/swap/swapfile    none    swap    sw    0   0" >> /etc/fstab

Application

At the moment, RethinkDB is not available as Debian package for the ARM architecture of BBB. Thus must compile from sources. RethinkDB version 1.12 has experimental ARM support included.

http://rethinkdb.com/docs/install/debian/

Debian for BBB is missing some dependences. A few changes are needed in build commands. Some dependencies are better to manually take care first, otherwise the build may crash.

sudo apt-get install git g++ protobuf-compiler libprotobuf-dev libv8-dev libncurses5-dev libboost-dev curl npm
sudo npm install -g coffee-script
git clone --depth 1 -b v1.13.x https://github.com/rethinkdb/rethinkdb.git
cd rethinkdb
./configure --allow-fetch
make
sudo make install

Rapsberry Pi

Installation

Platform

Download latest Raspbian (Debian for RPi) image: http://www.raspberrypi.org/downloads/. Write to (micro)SD card and boot.

Resize SD card partition and do other configurations:

sudo raspi-config

Make it up to date:

sudo apt-get update
sudo apt-get upgrade

Create 1GB swap partition:

sudo su
mkdir -p /var/cache/swap/
dd if=/dev/zero of=/var/cache/swap/swapfile bs=1M count=1024
chmod 0600 /var/cache/swap/swapfile 
mkswap /var/cache/swap/swapfile
swapon /var/cache/swap/swapfile
echo "/var/cache/swap/swapfile    none    swap    sw    0   0" >> /etc/fstab

Application

Follow instructions from http://rethinkdb.com/docs/install/raspbian/
NB! Better to run this under screen, in case of network interrupts.

sudo apt-get install screen
screen bash

There are some changes in the list of dependency packages to be installed prior build. Note, the build takes looong time. Better let make to run overnight.

sudo su
apt-get install git g++ protobuf-compiler libprotobuf-dev libv8-dev libboost-dev curl m4
git clone --depth 1 -b v1.13.x https://github.com/rethinkdb/rethinkdb.git
cd rethinkdb
./configure --without-tcmalloc --allow-fetch
make
distributed_database.txt · Last modified: 2014/08/22 23:42 by jap
Recent changes RSS feed CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki