Running the TICK Stack on a Raspberry Pi
By Noah Crowley / Jul 03, 2018 / InfluxDB, Community, Developer
<figcaption> The Raspberry Pi is a great platform for the TICK Stack!</figcaption>
Since its introduction in 2013, the Raspberry Pi platform has grown by leaps and bounds, gaining popularity and showing up in projects all over world, from quick hacks to fully commercialized products. It’s an inexpensive, low power, open-source, single-board computer with a variety of interfaces for connecting with sensors and actuators that can be used to interact with the physical world.
It’s also a solid choice when you need an always-on device for collecting data, and it’s powerful enough to run the complete TICK Stack. In fact, one of the most popular posts on our community site is about running the TICK Stack on a Raspberry Pi, so we wanted to provide some update instructions for installing and things to consider while operating the stack.
Your Choice of Pi
The first thing you’ll need to do is decide which Pi you’re going to use. The Raspberry Pi platform has gone through a few iterations since it was first released in 2013:
|Zero||1, 32-bit||1000 MHz||512 MB|
|A/B/+||1, 32-bit||500 MHz||256 MB|
|2B||4, 32-bit||900 MHz||1024 MB|
|3B||4, 64-bit||1200 MHz||1024 MB|
|3B+||4, 64-bit||1400 MHz||1024 MB|
There have been some significant architectural improvements over the years, and your best bet is to go with one of the model 3 boards, with quad-core, 64-bit CPUs for the database itself, although I’ve tested running the complete TICK Stack on the model 2 B, 3 B, and 3 B+. In addition, the single-core Zero makes a great platform for collecting sensor data with Telegraf.
The storage system on the Raspberry Pi, which uses an SD or microSD card, is the slowest by far relative to the systems on a laptop or desktop computer, so it’s important to keep in mind storage performance when you’re considering a Raspberry Pi for your application. Which SD card you choose will have a major impact on the performance of your Raspberry Pi, especially if you’re planning on running a database like InfluxDB.
Get at least a Class 10 Cardthe faster, the better. But understand that even with the fastest SD card, performance won’t come close to what you would get with an SSD, and this can often be the bottleneck for your applications.
Some manufacturers are also releasing “High Endurance” SD cards; I haven’t had a chance to do much research about them, but if you plan on writing large volumes of data, it might be worth investigating.
The Raspberry Pi 3 B and B+ also have the ability to enable a USB boot mode, although this is a permanent change for your device. While you’ll still be constrained by the speed of a USB 2.0 port, this would enable you to run a large-capacity SSD with better speed and performance.
The most common way to use a Pi is with the Raspbian operating system provided by the Raspberry Pi foundation, so that’s what we’ll be using in this blog post. Raspbian is based off the Debian distribution of Linux, with some modifications and utilities like raspi-config that contain functionality specific to the hardware. The latest version of Raspbian is April release based on Debian Stretch.
Recommended: Install from the Official InfluxData Repository
The easiest way to install the TICK Stack is to set up the InfluxData package repository (repo) and use your platform’s package manager, which on Raspbian is
apt. Packages contain the application binaries themselves, as well as some information about where and how to install and configure the application on your system. That means you can get everything up and running with just a few commands, and InfluxData regularly publishes the latest versions of the TICK Stack to its repository, so applying updates is easy as well.
The first step is to set up the InfluxData repo. You’ll need to identify which version of Raspbian you’re running, which you can do by taking a look at the
/etc/os-release file. Run the following command:
$ cat /etc/os-releases PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)" NAME="Raspbian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" ID=raspbian ID_LIKE=debian HOME_URL="http://www.raspbian.org" SUPPORT_URL="http://www.raspbian.org/RaspbianForums" BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
We need the version codename, which you can find in the
VERSION field, in parentheses. For the version I’m running, 9, the code name is
stretch. We’ll use that when we set up our repo so that we can get the correct versions for our OS.
Next, add the repo’s GPG key and add the repo itself:
$ curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
and then add the repository:
$ echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update to refresh the package list with data from the new repository, and install the TICK Stack using
sudo apt-get install telegraf influxdb chronograf kapacitor. If you want to only install some components of the stack, you can exclude the applications you don’t want from that command.
It’s also possible to download packages and install them yourself, without setting up the InfluxData repository. You probably don’t have a good reason for doing this, but for those who do, head over to our downloads page.
Docker is another great option for running the TICK Stack on a Raspberry Pi, and is what I use at home. Docker is an OS-level virtualization technology, which means that it isolates various applications by making it appear as though they each have their own Linux kernel and environment to run in. This provides isolation for your applications, while the Docker runtime provides easy-to-use tooling for creating and managing containers.
Manual Options: Binaries and Building from Source
A few other options exist which provide additional level of manual control over how you want to build and install your applications. You can download a Linux binary from influxdata.com/downloads, or you can visit the respective Git repositories (Telegraf, InfluxDB, Chronograf, and Kapacitor), check out the code, and build the applications yourself.
Since the Pi is a relatively constrained computing environment, you might have to make some tradeoffs in terms of how much software you can run and how much data you can process and store.
One thing to consider is that you don’t have to run Chronograf on the Pi; you can run a local copy on your primary computer, and set it up to talk to the InfluxDB instance on your Raspberry Pi over the network. This is the setup I’m currently running at home, and I find that it gives a nice performance bump over running everything on the Pi.
Another thing to keep in mind is the amount of storage space you have on your SD card. While InfluxDB is quite efficient at storing data, depending on the size of your card, the other software you have installed, and how much data you’re writing, it is possible to run out of space. You should definitely set up some kind of monitoring and alerting so that you can be informed when you run out of space. Telegraf’s disk plugin and Kapacitor’s alerts functionality would be a good fit for this!
You also might not need to keep your data around forever; a few weeks or months might be good enough for your use case. We often see users taking advantage of into InfluxData’s downsampling and retention policy functionality to reduce the resolution of their data and automatically delete it when it has reached a certain age. For more information on why you might want to do this, check out our recent training webinar, Downsampling Your Data.
Hopefully this post got you up and running, but if you have any questions or comments please feel free to reach out to me directly on Twitter @noahcrowley or feel free to post your comments on our community site at community.influxdata.com. And if you build something great with Influx, don’t hesitate to let us know, there might be a hoodie in it for you!