Compile and install InfluxDB on Raspberry Pi

When talking about databases, maybe you're like me, you immediately think about SQLite, MySQL or even MariaDB. But there are other tools that might well be useful if you need to save data from probes or sensors. InfluxDB might be one of these databases that will make your life easier !

InfluxDB Raspberry Pi home Server

InfluxDB is a database with a design that is optimized to save data from sensors, metrics or events. Each registered line has a primary key that is the date of the event. The base will be able to manage optimized millions of records without having a performance loss.

Some features included in the base allow to aggregate the data in a very simple way. For example you can calculate directly in the query an average by time window. The example below will give you the average value per window of 30 minutes on the previous 24h :

select mean(value) from cpu_idle 
group by time(30m) where time > now() - 1d

InfluxDB Raspberry Pi home Server

Once installed, the base has an integrated graphical interface which allows to manage databases, users and explore your data without needing an additional tool :

InfluxDB Raspberry Pi home Server

You will find all the information on the page describing InfluxDB.

  1. Define the local system with raspi-config for example.
  2. Install packages needed for compiling
    apt-get install gawk mercurial bzr protobuf-compiler flex bison valgrind g++ make autoconf libtool libz-dev libbz2-dev curl rpm build-essential git wget libgflags-dev
  3. Install GVM
    bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
  4. Initialize the GVM environments variables
    source /root/.gvm/scripts/gvm
  5. Install Go 1.3
    gvm install go1.3
  6. Set default version 1.3 GB
    gvm use go1.3 --default
  7. Installer les plugins suivants
    go get code.google.com/p/goprotobuf/{proto,protoc-gen-go}
  8. Installer GCC 4.9:
    1. Edit the file/etc/apt/sources.list by adding following content

      deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi
      deb http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
      # Source repository to add
      deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
      deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
      deb http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
      # Source repository to add
      deb-src http://archive.raspbian.org/raspbian jessie main contrib non-free rpi
    2. Edit the /etc/apt/preferences file and insert the following content
      Package: *
      Pin: release n=wheezy
      Pin-Priority: 900
      Package: *
      Pin: release n=jessie
      Pin-Priority: 300
      Package: *
      Pin: release o=Raspbian
      Pin-Priority: -10
    3. Update the packages
      apt-get update
    4. Install gcc and g++
      apt-get install -t jessie gcc g++

      Source : http://somewideopenspace.wordpress.com/2014/02/28/gcc-4-8-on-raspberry-pi-wheezy/

  9. Increase the size of the filesystem mounted on /tmp by adding the following line to /etc/fstab
    tmpfs /tmp tmpfs defaults,noatime,nosuid,size=400m 0 0
  10. Restart
    reboot
  11. Prepare the structure for the compilation
    mkdir gocodez export GOPATH=$HOME/gocodez mkdir-p $GOPATH/src/github.com/influxdb cd $GOPATH/src/github.com/influxdb
    
  12. Download the latest version of the sources
    wget http://S3.amazonaws.com/influxdb/influxdb-latest.src.tar.gz
  13. Unpack the archive and move the sources
    mkdir influxdb cd influxdb tar zxvf../influxdb-latest.src.tar.gz cp-R src/github.com/* $GOPATH/src/github.com/cd $GOPATH/src/github.com/influxdb/influxdb
  14. Start the configuration
    ./configure
  15. Edit the file Makefile to make architecture arm. This is the line 16 file. Replace :
    arch   = amd64

    by

    arch   = arm
  16. Edit the file Makefile to disable RocksDB on line 112. Replace :
    rocksdb = yes
    by
    rocksdb = no
  17. Edit the file Makefile to comment the line 233. Replace :
    $(GO) build -o benchmark-storage $(GO_BUILD_OPTIONS) github.com/influxdb/influxdb/tools/benchmark-storage
    by
    #$(GO) build -o benchmark-storage $(GO_BUILD_OPTIONS) github.com/influxdb/influxdb/tools/benchmark-storage
  18. Start the compilation
    make build
  19. You can now install InfluxDB
    make install

You now have your system ready to be started. For this you can find on this page all the information that you can follow to test your new database.

If you want to build the Debian package to then deploy to other Raspberry :

  1. Install Ruby
    apt-get install -t jessie ruby ruby-dev
  2. Installer FPM
    gem install fpm
  3. Install the Ruby package manager RVM
    curl -L get.rvm.io | bash -s stable --rails
  4. You have an error on the GPG key
    gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3

    and then restart the installation

    curl -L get.rvm.io | bash -s stable --rails
  5. Edit the Makefile to define version being compiled. At the time of writing, the version is the 0.8.6. Replace the line 265 :
    version=

    by

    version=0.8.6
  6. Edit the Makefile to set the name of the packages. Replace lines 294 and 295 :
    rpm_package = packages/influxdb-$(package_version)-1.armel.rpm
    debian_package = packages/influxdb_$(version)_armel.deb

    by

    rpm_package = packages/influxdb-$(package_version)-1.armhf.rpm
    debian_package = packages/influxdb_$(version)_armhf.deb
  7. Add root in group rvm
    usermod -a -G rvm root
  8. Disconnect and then reconnect
  9. Initialize GOPATH
    export GOPATH=$HOME/gocodez cd $GOPATH/src/github.com/influxdb
  10. Initiate the creation of the package
    make package
  11. The package will be in the packages directory (or out_rpm if the move failed). You have a beautiful .deb to install

You may also like...