InfluxDB is an open-source time series database (TSDB), written in Go and optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics.
In this blog post, we are going to install InfluxDB and create an InfluxDB database in order to store data coming from MQTT through Node-RED
What is Node-RED and how does it work?
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.
What is InfluxDB used of?
InfluxDB is a time series platform that empowers developers to build IoT, analytics and monitoring software.
It is purpose-built to handle the massive volumes and countless sources of time-stamped data produced by sensors, applications and infrastructure.
What is MQTT?
MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT).
It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth.
MQTT today is used in a wide variety of industries, such as automotive, manufacturing, telecommunications, oil and gas, etc.
Now we know a little bit more about the tools that we are going to use, we are going to install InfluxDB on our Raspberry PLC.
1. First of all, update the aptitude package:
sudo apt update
2. Then, add the InfluxDB repository key to our Raspberry Pi in order to allow the package manager on Raspbian to search the repository and verify the packages installed.
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
3. Add the repository to the sources list
echo "deb https://repos.influxdata.com/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
4. Update the package list again.
sudo apt update
5. Install InfluxDB onto your Raspberry PLC:
sudo apt install influxdb
6. Enable InfluxDB to start at boot on your Raspberry Pi.sudo systemctl unmask influxdb
sudo systemctl enable influxdb
sudo systemctl start influxdb
Finally, start InfluxDB by typing influx in the commandline of your Raspberry PLC:
How to create an InfluxDB database
As InfluxDB comes without any database by default, we are going to create the first one, called test. Into this influx prompt, follow the next steps:
1. Create a database called testcreate database test
2. Go into the database:use test
3. Now , we will show everything from the database with the command below. We will see that obviously is empty. We just do this step in order to make sure what it contains right now.select * from test
Now that you have been able to create your first database with InfluxDB, let's continue with inserting data from Node-RED!
Want to know how?