DIY Projects

Install InfluxDB on Raspberry Pi, Windows, macOS. Discovery of the Shell. Create a database, retention [Update]


InfluxDB is an open source time series database developed by InfluxData that runs on 64-bit Windows, macOS or the Raspberry Pi Raspbian distribution. In this tutorial we will learn how to install InfluxDB on these three systems. InfluxDB is optimized for recording events or metrics. Originally developed to monitor server activity, it is very well suited for recording events or measurements from connected objects. InfluxDB is used in industry (IBM, ebay, Cisco, Citrix …) or research centers. For example, Geneva CERN uses InfluxDB to record the data generated during the LHC experiments. It’s an excellent solution combined with Node-RED to record the measurements of your connected objects and plot fantastic graphics with Grafana.


It is also possible to install InfluxDB on most Linux distributions. InfluxDB is available for 64-bit Windows only. If you have a 32-bit version, you will have to install Docker (docker pull influxdb) or use a virtual machine. For Linux Debian or Ubuntu 16.x distributions, read this specific tutorial.

Benefits of InfluxDB for (DIY) connected objects projects

Traditional databases (MariaDB, MySQL for example) are designed to store and link the data in them. They are very well suited to manage customer accounts and record orders from a merchant site. There is nothing to prevent the recording of time-dependent data, but in this case you will have to manually delete the old data. Other database architectures have been devised. InfluxDB answers three objectives:

Install InfluxDB on Raspbian Stretch for Raspberry Pi

Before you can install InfluxDB on Raspbian, you need to tell the system where the keys for the InfluxDB project repository are.

curl -sL | sudo apt-key add -

There are two versions of InfluxDB. The first is suitable for Debian 8.0 or higher (Raspbian Jessie or Stretch), the other for Debian 7.0 (Raspbian Wheezy)

To know the version of your system, run the command lsb_release -a

pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 9.1 (stretch)
Release:	9.1
Codename:	stretch

I advise you to update your system (upgrade) in order to have the latest versions by executing these two commands

sudo apt-get update && apt-get upgrade

Then run these commands which will add the apt-transport-https package, add the link to the source of InfluxDB, update the system and finally install InfluxDB.

sudo apt install apt-transport-https
echo "deb jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update
sudo apt-get install influxdb

InfluxDB is now installed. InfluxDB is already pre-configured. If you want to be able to save data from a connected object using an HTTP request or from Node-RED, you will have to allow connections from the HTTP port. To do this, simply modify the configuration file in the directory /etc/influxdb/influxdb.conf

sudo nano /etc/influxdb/influxdb.conf

We uncomment the following lines

  # Determines whether HTTP endpoint is enabled.
  enabled = true

  # The bind address used by the HTTP service.
  bind-address = ":8086"

  # Determines whether user authentication is enabled over HTTP/HTTPS.
  auth-enabled = false

Save with CTRL + X + Y and restart the InfluxDB service

sudo service influxdb restart

Note regarding SD boards

The Raspberry Pi uses an SD board to operate the system and store the data. It is imperative to purchase an SD board suitable for intensive data logging. These are mostly SD boards suitable for camcorders or digital cameras. Feel free to spend a few extra euros on a fast brand name board. Opt for a minimum SDXC II board. You will find more info in this article.

See all deals

How to install InfluxDB on Windows

It takes a little searching on the site of InfluxData, but there is a version for Windows. She is available for Windows 64-bit.

You can install it by downloading this page or from wget for Windows . In this case, run the following command

 wget tar xvfz influxdb - 1.1.0_linux_amd64.tar.gz

With no Windows 64 bit at my disposal, I have not tested on this environment.

How to install InfluxDB on macOS

macOS version tested : 10.11.6 (El Captain) on a Mac Mini 2011

InfluxDB installs on macOS using Brew . BREW is a package manager for Mac (project official page).

Open a Terminal and paste this command

/usr/bin/ruby -e "$(curl -fsSL"

Answer the questions to complete the installation of Brew on your Mac.

Now we can install InfluxDB by running these commands

brew update 
brew install influxdb

To run influxDB at startup, run this command

ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents

Now, to start InfluxDB, run this command (accept the request of incoming connections in the window that appears)

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist

Or to start manually in a Terminal

influxd -config /usr/local/etc/influxdb.conf

Check if InfluxDB works

InfluxDB exposes an API with which one can easily check its good working condition. Here’s what you will receive in return for this curl command

$ curl -sl -I localhost:8086/ping
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 165b0fa4-ad88-11e6-8a6f-000000000000
X-Influxdb-Version: v1.1.0
Date: Fri, 18 Nov 2016 12:11:08 GMT

InfluxDB is properly started

Terminology, difference with SQL database

Like all non-relational database, InfluxDB for its own vocabulary you need to know before starting.

Database Management Methods

There are 6 (CREATE database management methods DATABASE, DROP DATABASE, DROP SETS, DELETE, DROP MEASUREMENT, DROP SHARD). Here’s how work the first 2, for others, everything can be found here.

Create a database


CREATE DATABASE <database_name> [WITH [DURATION <duration>] [REPLICATION <n>] [SHARD DURATION <shard_duration>] [NAME <retention-policy-name>]]

Basic settings


 CREATE DATABASE "temperatures"

Delete a database (drop database)


DROP DATABASE <database_name>

We just the name of the base (database_name) to remove.

Establish a retention policy

InfluxDB incorporates a system of automatic deletion of data. It is the policy of Retention (Retention Policy). Spent some time, data is automatically deleted from the base. This mechanism is very convenient because it for a good grasp of the size of the base and we don’t have to worry about this maintenance operation. Free to each set the lifetime of any particular measure. If you want to follow the temperature of its microprocessor, one less may be sufficient, instead the retention policy must be more flexible if we want to compare the temperature in a House from one year to the other. It will also think about the system upstream, you don’t have to store a measurement of atmosphere temperature every 10 seconds! A measure per minute, 15 minutes, that’s enough. Instead in an industrial process, we certainly want to go for the second… or a lot less.

We therefore for 3 methods

Create a retention policy


CREATE RETENTION POLICY <name_politic_retention> ON <name_database> DURATION <duration> REPLICATION <n> [SHARD DURATION <duration_shard>] [DEFAULT]



> CREATE RETENTION POLICY "one_day_only" WE "NOAA_water_database" DURATION 1 d REPLICATION 1 

This policy keeps the records during a day (one_day_only) based NOAA_water_database. The data are stored in space shard 1 day. Replication 1 indicates that a copy of each item is copied in the cluster (it takes only it cluster exists).

Modify retention policy (alter retention policy) 

This method allows to change an existing retention policy.


ALTER RETENTION POLICY <name_politic_retention> ON <nom_database> DURATION <duration> REPLICATION <n> SHARD DURATION <duration_shard> DEFAULT




the method returns an empty result.

Destroyed a retention policy (retention policy drop)


DROP RETENTION POLICY <name_polic_retention> ON <name_database>


Discover the InfluxDB Shell

Now we know some methods , we will provide to run some tests. Just like MongoDB, InfluxDB for its own command shell that allows to perform all operations on databases. To start it, nothing complicated, just enter Influx in the Terminal.

$ influx
Visit to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version v1.1.0
InfluxDB shell version: v1.1.0

The exit command allows to get out of the shell.

Note. All the operations described in this paragraph can also be accomplished using commands curl .

Let’s start by creating a database

name: databases

Add a user projetsdiy for this database

 > CREATE USER projetsdiy WITH PASSWORD 'password!'

And now we give him all rights based basetest .

> GRANT ALL ON basetest TO projetsdiy 

Now we add a 30-day retention policy


Check retention policy

name		duration	shardGroupDuration	replicaN	default
----		--------	------------------	--------	-------
autogen		0s		168h0m0s		1		false
thirty_days	720h0m0s	24h0m0s			1		true


It is finished for this first presentation on InfluxDB. There is still much to discover, but it’s more than enough to take charge and start working with. In the next tutorial, we’ll see how to save steps of a DHT22 probe built around MySensors by using Node-RED firmware.


[June 11, 2018] How to install InfluxDB on Raspbian Stretch for Raspberry Pi.

Click to rate this post!
[Total: 0 Average: 0]
Exit mobile version