Linux Format

Influxdb, the sexy* database

Mihalis Tsoukalos explains how to install, administer and query Influxdb, the modern Go-powered time-series database.

-

Mihalis Tsoukalos explains how to install, administer and query Influxdb, the modern Go-based database optimised for timeseries and IOT sensor systems.

What is Influxdb, exactly? Well, it’s an open source time-series, events and metrics database that is optimised to handle high-write and heavy query loads. We’ll kick things off by covering how to correctly install Influxdb and learn about Influxql, which is the query language of Influxdb, before exploring how to read and write data to Influxdb, administer it and work with it using Python 3 and Go.

Installing Influxdb

Influxdb has two versions: the open source version, which can be installed on a single machine, and the paid enterprise version that can be installed on a cluster. Most people will be more than happy with the open source version, and that’s the one we’ll be using on Linux. The installati­on process includes the following two easy steps:

$ wget https://dl.influxdata.com/influxdb/releases/ influxdb_1.7.4_amd64.deb

$ sudo dpkg -i influxdb_1.7.4_amd64.deb

You should note that if you install it this way, you won’t any automatic updates for Influxdb when you run the apt update and apt upgrade commands. You can stop a running Influxdb server by executing systemctl stop influxdb and start it again by executing systemctl start influxdb . Both commands should be executed with root privileges, and Figure 1 shows the output of these commands. After that you can determine the Influxdb version you are using as follows:

$ influx --version

Influxdb shell version: 1.7.4

Enter an Influxql query

As the time of writing, the latest stable Influxdb version is 1.7.4, which means that we are using the latest version. However, Influxdb 2.0 is on its way to becoming the latest stable version.

Influxdb can be configured either from a configurat­ion file or by using environmen­t variables; in this tutorial we’ll use a configurat­ion file. You can find the configurat­ion file, influxdb.conf, at /etc/influxdb.

At this point the configurat­ion file contains the locations where Influxdb stores its data and its metadata, namely are /var/lib/influxdb/data and /var/lib/influxdb/ meta. Keep in mind that you can also use Influxdb from a Docker image. If you are familiar with Docker and you want to experiment with Influxdb without having to manually install anything, you can get the latest stable Influxdb Docker image with docker pull influxdb . After that you can use that Docker image by executing docker run -p 8086:8086 -v $Pwd:/var/lib/influxdb influxdb . Note that you should replace $PWD with the directory on your local machine where you want to persistent­ly store all Influxdb-related data.

Basic commands

To get started, let’s cover some simple Influxdb commands. So, first execute the following commands:

$ influx

$ influx -host ‘localhost’ -port ‘8086’

The first command enables you to connect to the Influxdb server using the influx utility and the default parameters. Should you wish to use different values for connecting to a different server or port number, you should execute influx as shown in the second command. The hostname ( localhost ) and the port number ( 8086 ) used here are the default values, which means that these two commands are functional­ly equivalent to each other.

Once you are connected to the Influxdb shell, you can do the following:

> CREATE DATABASE lxf

> SHOW DATABASES

> DROP DATABASE mydb

 ??  ?? Figure 1: How to install Influxdb 1.7.4 on Ubuntu, and how to start the Influxdb server process using systemclt.
Figure 1: How to install Influxdb 1.7.4 on Ubuntu, and how to start the Influxdb server process using systemclt.

Newspapers in English

Newspapers from Australia