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...

  • Bo

    Thank you very much for your work!! I just downloaded the binary for my Olinuxino Ato and it seems to work perfectly (as far as I can tell for now).

  • Dirk

    Hi, I’m getting the following error when running ./configure

    checking sed -i… using sed -i
    checking for protoc… notfound
    configure: error: Please install protobuf before trying to build InfluxDB

    What should I do?

    Regards Dirk

    • Dirk

      OK, in the first attempt I forgot step 7, but even after doing that I still get the same error (even after reboot)

      • Hi,
        Seems that step 2 has not been executed or that some packages were missing. Can you please run it again ? The error comes from a missing package (protobuf-compiler)

        • Dirk

          Hi,
          On step 2 I'm getting a bunch of other errors:

          Note, selecting ' zlib1g-dev’ instead of ' libz-dev’
          Package valgrind is not available, but is referred to by another package.
          This may mean that the package is missing, has been obsoleted, or
          is only available from another source

          Package gawk is not available, but is referred to by another package.
          This may mean that the package is missing, has been obsoleted, or
          is only available from another source

          Package bzr is not available, but is referred to by another package.
          This may mean that the package is missing, has been obsoleted, or
          is only available from another source
          However the following packages replace it:
          python-bzrlib bzr-doc

          Package protobuf-compiler is not available, but is referred to by another package.
          This may mean that the package is missing, has been obsoleted, or
          is only available from another source

          Package flex is not available, but is referred to by another package.
          This may mean that the package is missing, has been obsoleted, or
          is only available from another source
          However the following packages replace it:
          libfl-dev

          E: Package ' gawk’ has no installation candidate
          E: Package ' bzr’ has no installation candidate
          E: Package ' protobuf-compiler’ has no installation candidate
          E: Package ' flex’ has no installation candidate
          E: Package ' valgrind’ has no installation candidate

          Either I've overlooked these messages yesterday, or they didn't appear…

          • Ouch ! Did you use Raspbian ? Did you execute an update of packages ? Thats really strange. Last solution : download the pre compiled deb package and install it …

  • chrysaor94

    Chris,
    J'ai une erreur au niveau de la compilation :

    make[1]: Leaving directory '/tmp/leveldb.influxdb.arm’
    /root/. gvm/gos/goal. 3/bin/go get-tags ' hyperleveldb’ -d-t github.com/influxdb/influxd b/…
    # cd/root/gocodez/src/github.com/influxdb/influxdb; git checkout master
    error: Your local changes to the following files would be overwritten by checkout:
    Makefile.in
    release.sh
    scripts/post_install.sh
    Please, commit your changes or stash them before you can switch branches.
    Aborting
    package launchpad.net/gocheck
    imports code.google.com/p/go.crypto/bcrypt
    imports golang.org/x/crypto/blowfish
    imports code.google.com/p/goprotobuf/proto
    imports code.google.com/p/log4go
    imports code.google.com/p/gogoprotobuf/proto
    imports github.com/influxdb/influxdb/testdata: exit status 1
    package launchpad.net/gocheck
    imports code.google.com/p/go.crypto/bcrypt
    imports golang.org/x/crypto/blowfish
    imports code.google.com/p/goprotobuf/proto
    imports code.google.com/p/log4go
    imports code.google.com/p/gogoprotobuf/proto
    imports github.com/bmizerany/assert
    imports github.com/kr/pretty
    imports github.com/kr/text
    imports github.com/stretchr/testify/assert
    imports github.com/rakyll/statik/example/statik
    imports github.com/rakyll/statik/example/statik
    imports github.com/rakyll/statik/example/statik: cannot find package “github.c om/rakyll/statik/example/statik” in any of:
    /root/.GVM/GOS/GO1.3/src/pkg/github.com/rakyll/Statik/example/Statik (from $GO ROOT)
    /root/gocodez/src/github.com/rakyll/Statik/example/Statik (from $GOPATH)
    Makefile:221: recipe for target ' dependencies’ failed
    make: *** [dependencies] Error 1
    root@raspberrypi:~/gocodez/src/github.com/influxdb/influxdb#

    When I do a search on the error-> cannot find package “github.c om/rakyll/statik/example/statik”
    I fall on it https://github.com/rakyll/statik/issues/9. But it speaks to me more than ca.
    I do not know if you already ran into this problem ? I have the impression that the Makefile has somewhat evolved from the version that you have compiled ? In your point 5 the construction of the package you refer to the line 265, off in the makefile outstanding, CA seems to correspond to the 259.

    I don't know if you have an idea ?
    Thank you in advance.

    • Hello
      Exact, the current version is the 0.8.8 while I have compiled the 0.8.6. I expect the 0.9 who uses another storage system.

      Have you tried to rename the directory example/statik in example/_statik ?

      • chrysaor94

        Hello,
        The problem is that there is no directory “Statik” Sub “github.com/rakyll/Statik/example/”. In fact, I have the impression that the script “main.go” must be run to generate the Static package. This is what I understand by looking at the description on Github (https://github.com/rakyll/statik/tree/master/example).

        • In my opinion it will be necessary to tweak the script to avoid the error. If you find the solution can you share it here ? Merci ­čśë

  • Nicolae Surdu

    Hello,

    I’ve installed your compiled binaries on a raspberry pi, but when I try to run “influx” it sais the command is not found. Any ideas? Thank you very much for your time!

    • Hi. Did you search for the binary in the subfolders where you compiled influxdb ?
      By the way, please have a look at this page where you have information about the latest InfluxDB version and a link to build it on the Raspberry Pi using the Go language which is the official one for next versions of InfluxDB
      Hope it helps !
      Chris

  • Peter Hartmann

    The errors in this documentation make it very hard to reproduce the installation. e.g. In Step 2 the upt-get C++ is missing the plus signs, in Step 8 the /etc/apt/sources.list has line breaks missing, and Step 7 is obsolete, because things moved to gitub. Please fix!