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 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
Once installed, the base has an integrated graphical interface which allows to manage databases, users and explore your data without needing an additional tool :
You will find all the information on the page describing InfluxDB.
- Define the local system with raspi-config for example.
- 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
- Install GVM
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
- Initialize the GVM environments variables
source /root/.gvm/scripts/gvm
- Install Go 1.3
gvm install go1.3
- Set default version 1.3 GB
gvm use go1.3 --default
- Installer les plugins suivants
go get code.google.com/p/goprotobuf/{proto,protoc-gen-go}
- Installer GCC 4.9:
- 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
- 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
- Update the packages
apt-get update
- 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/
- Edit the file/etc/apt/sources.list by adding following content
- 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 - Restart
reboot
- 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
- Download the latest version of the sources
wget http://S3.amazonaws.com/influxdb/influxdb-latest.src.tar.gz
- 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
- Start the configuration
./configure
- Edit the file Makefile to make architecture arm. This is the line 16 file. Replace :
arch = amd64
by
arch = arm
- Edit the file Makefile to disable RocksDB on line 112. Replace :
rocksdb = yes
by
rocksdb = no - 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 - Start the compilation
make build
- 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 :
- Install Ruby
apt-get install -t jessie ruby ruby-dev
- Installer FPM
gem install fpm
- Install the Ruby package manager RVM
curl -L get.rvm.io | bash -s stable --rails
- 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
- 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
- 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
- Add root in group rvm
usermod -a -G rvm root
- Disconnect and then reconnect
- Initialize GOPATH
export GOPATH=$HOME/gocodez cd $GOPATH/src/github.com/influxdb
- Initiate the creation of the package
make package
- The package will be in the packages directory (or out_rpm if the move failed). You have a beautiful .deb to install