InfluxDB is an open-source and time series database developed by InfluxData. It is written in Go and designed to handle high write and query loads. It is known for its simplicity and ability to perform at scale. It can be run across multiple operating systems and also supports a wide range of client libraries.

This tutorial will explain how to install InfluxDB time series database on CentOS 8.

Prerequisites

  • A server running CentOS 8.
  • A root password is configured on your server.

Install InfluxDB

By default, InfluxDB is not available in the CentOS 8 default repository. So you will need to create a repo for InfluxDB. You can create it with the following command:

nano /etc/yum.repos.d/influxdb.repo

Add the following lines:

[influxdb]
name = InfluxDB Repository
baseurl = https://repos.influxdata.com/rhel/8/x86_64/stable/
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key

Save and close the file then update the repo cache with the following command:

dnf makecache

Next, install the InfluxDB using the following command:

dnf -y install influxdb

Once the installation is completed, verify the installed version of InfluxDB with the following command:

rpm -qi influxdb

You should get the following output:

Name        : influxdb
Version     : 1.8.4
Release     : 1
Architecture: x86_64
Install Date: Wednesday 07 April 2021 01:24:54 AM EDT
Group       : default
Size        : 174431824
License     : Proprietary
Signature   : RSA/SHA256, Monday 01 February 2021 08:01:46 PM EST, Key ID 684a14cf2582e0c5
Source RPM  : influxdb-1.8.4-1.src.rpm
Build Date  : Thursday 28 January 2021 05:31:21 AM EST
Build Host  : bf85fc4b5de4
Relocations : / 
Packager    : [email protected]
Vendor      : InfluxData
URL         : https://influxdata.com
Summary     : Distributed time-series database.
Description :
Distributed time-series database.

Manage InfluxDB Service

You can start and stop the InfluxDB service using the following command:

systemctl start influxdb

systemctl stop influxdb

To start the InfluxDB at system reboot, run the following command:

systemctl enable influxdb

To verify the status of the InfluxDB, run the following command:

systemctl status influxdb

You should get the following output:

? influxdb.service - InfluxDB is an open-source, distributed, time series database
   Loaded: loaded (/usr/lib/systemd/system/influxdb.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2021-04-07 01:25:11 EDT; 11s ago
     Docs: https://docs.influxdata.com/influxdb/
 Main PID: 48978 (influxd)
    Tasks: 8 (limit: 12524)
   Memory: 7.9M
   CGroup: /system.slice/influxdb.service
           ??48978 /usr/bin/influxd -config /etc/influxdb/influxdb.conf

Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426523Z lvl=info msg="Starting precreation service" log_id=0TMhWB~l000 service=>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426552Z lvl=info msg="Starting snapshot service" log_id=0TMhWB~l000 service=sna>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426570Z lvl=info msg="Starting continuous query service" log_id=0TMhWB~l000 ser>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426616Z lvl=info msg="Starting HTTP service" log_id=0TMhWB~l000 service=httpd a>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426634Z lvl=info msg="opened HTTP access log" log_id=0TMhWB~l000 service=httpd >
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426802Z lvl=info msg="Listening on HTTP" log_id=0TMhWB~l000 service=httpd addr=>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.426831Z lvl=info msg="Starting retention policy enforcement service" log_id=0TM>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.427033Z lvl=info msg="Listening for signals" log_id=0TMhWB~l000
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.427330Z lvl=info msg="Storing statistics" log_id=0TMhWB~l000 service=monitor db>
Apr 07 01:25:11 centos8 influxd[48978]: ts=2021-04-07T05:25:11.427779Z lvl=info msg="Sending usage statistics to usage.influxdata.com" log_id=>

By default, InfluxDB listens on port 8086. You can check it with the following command:

ss -tunelp | grep 8086

You should see the following output:

tcp     LISTEN   0        128                    *:8086                *:*       users:(("influxd",pid=49040,fd=14)) uid:987 ino:824427 sk:c v6only:0        

Enable Authentication

By default, InfluxDB is configured to connect without authentication. So it is recommended to secure InfluxDB with a username and password.

To do so, you will need to enable the authentication in influxdb.conf file.

nano /etc/influxdb/influxdb.conf

Change the following line in [http] section:

auth-enabled = true

Save and close the file then restart the InfluxDB to apply the changes:

systemctl restart influxdb

Next, you will need to create a admin user to authenticate InfluxDB. You can create it with the following command:

curl -XPOST "http://localhost:8086/query" --data-urlencode "q=CREATE USER admin WITH PASSWORD 'password' WITH ALL PRIVILEGES"

At this point, InfluxDB is secured with a username and password.

Working with InfluxDB

Now, you can connect to the InfluxDB shell with the following command:

influx -username 'admin' -password 'password'

Once connected, you should get the following output:

Connected to http://localhost:8086 version 1.8.4
InfluxDB shell version: 1.8.4

Now, create a new database using the following command:

> CREATE DATABASE mydb

To display all databases, run the following command:

> SHOW DATABASES

You should get the following output:

name: databases
name
----
_internal
mydb

Now, exit from the InfluxDB shell with the following command:

> exit

You can also list all databases without login to InfluxDB as shown below:

curl -G http://localhost:8086/query -u admin:password --data-urlencode "q=SHOW DATABASES"

You should get the following output:

{"results":[{"statement_id":0,"series":[{"name":"databases","columns":["name"],"values":[["_internal"],["mydb"]]}]}]}

Conclusion

Congratulations! You have successfully installed InfluxDB on CentOS 8. You can now use InfluxDB to handle a large amount of data in the production environment.