Installing Influx DB on Raspberry Pi 2 (2015-10-18)

InfluxDB is a simple time series database written entirely in Go without external dependencies. This makes it attractive to have it running on a Raspberry 24/7 to collect home automation or stock market data or anything else which is waiting for being stored locally when the laptop is closed. I installed it a while ago and it is running well. Below my notes probably useful also for others (and also for me later on). I hope it is complete.

For Influx exists pre-built packages but unfortunately none for the ARM architecture required for the Raspberry.

Since it is written in Go and the Go compiler supports ARM it can be compiled from scratch.

First we need the latest and greatest Go compiler on the Raspi (currently 1.5.1) which needs to be compiled first itself. You can cross-compile it but having a recent Go compiler on the Pi is certainly useful. Since Go is now entirely written in Go (1.5) we need to bootstrap the compilation of Go.

Over in Dave Chaneys blog there is a recipe which works well also for 1.5.1. It takes an hour for compilation, but on the old Raspberry it took the whole night.

Having the current go version and the Go paths setup you should see something like that:

$ go version
go version go1.5.1 linux/arm

The next step is cloning the repository of InfluxDB and changing to its directory:

$ go get github.com/influxdb/influxdb
$ cd go/src/github.com/influxdb/influxdb

Changing to a stable tag of the latest version (git tag --list) can also not harm because we want to have a stable system.

$ git checkout v0.9.4.1

Finally the dependencies have to be resolved and then it can be build (being in the influxdb source directory.

$ go get -u -f -t ./...
$ go build ./...
$ go install ./...

For creating a complete package the gvm tool needs to be installed. That handles Go versions on the command line. Then the package.sh script could be used. But for my purposes I skip that.

For running InfluxDB we are going to use a user named influxdb and giving it a password:

$ sudo adduser influxdb

Now we let's install the InfluxDB binary to a global location.

$ sudo mkdir /opt/influxdb
$ sudo cp /home/daniel/go/bin/influxd /opt/influxdb/
$ sudo cp /home/daniel/go/bin/influx /opt/influxdb/
$ sudo chown -R influxdb /opt/influxdb
$ sudo chgrp -R influxdb /opt/influxdb

Also other directories needs to have the rights for influxdb user.

$ sudo mkdir -p /etc/opt/influxdb
$ sudo chown -R influxdb /etc/opt/influxdb
$ sudo chgrp -R influxdb /etc/opt/influxdb

$ sudo mkdir -p /var/run/influxdb
$ sudo chown -R influxdb /var/run/influxdb
$ sudo chgrp -R influxdb /var/run/influxdb

$ sudo touch /etc/default/influxdb
$ sudo chown -R influxdb /etc/default/influxdb
$ sudo chgrp -R influxdb /etc/default/influxdb

As influxdb user the config needs to be created:

$ su influxdb
$ /opt/influxdb/influxd config > /etc/default/influxdb

For getting the daemon booted automatically we need to install the rc script as root.

# cp <...>/src/github.com/influxdb/influxdb/scripts/init.sh /etc/initd/influx

Then we add it to the runlevels (in /etc/initd).

# insserv influx

Starting the service...

# service influx start
Starting the process influxdb [ OK ]
influxdb process was started [ OK ]

Now it is time to test if it is running:

# service influx status
influxdb Process is running [ OK ]

You can also connect now with your browser to port 8083.