How to Install & Configure InfluxDB2 in Rocky Linux/CentOS 8

InfluxDB is the database in which we will store the metrics sent from the agent. This database is designed to withstand high write and read loads.

InfluxDB is an open source time series database. It has everything you need from a time series platform in a single binary – a multi-tenanted time series database, UI and dashboarding tools, background processing and monitoring agent. All this makes deployment and setup a breeze and easier to secure.

The InfluxDB Platform also includes APIs, tools, and an ecosystem that includes 10 client and server libraries, Telegraf plugins, visualization integrations with Grafana, Google Data Studio, and data sources integrations with Google Bigtable, BigQuery, and more.

In this guide we will install InfluxDB OSS version 2 in RHEL based servers.

# Table of Content

  1. Esuring the server is up to date
  2. Installing InfluxDB
  3. Starting and enabling InfluxDB Service
  4. Installing InfluxDB v2 cli
  5. Open InfluxDB Service port on Firewall
  6. Setup InfluxDB
  7. Common operations on InfluxDB

# 1. Esuring the server is up to date

Before proceeding let us ensure that our server packages are updated. Use this command to achieve this

sudo dnf -y update

# 2. Installing InfluxDB

InfluxDB is not available in the default Rocky Linux repos.

cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
name = InfluxDB Repository - RHEL \$releasever
baseurl =\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey =

Then install it using this command

sudo dnf install -y influxdb2


$ rpm -qi influxdb2
Name        : influxdb2
Epoch       : 0
Version     : 2.1.1
Release     : 1
Architecture: x86_64
Install Date: Wed 01 Dec 2021 05:26:00 PM EAT
Group       :
Size        : 178710338
License     : MIT
Signature   : RSA/SHA256, Tue 09 Nov 2021 07:47:35 PM EAT, Key ID 684a14cf2582e0c5
Source RPM  : influxdb2-2.1.1-1.src.rpm
Build Date  : Tue 09 Nov 2021 06:27:09 AM EAT
Build Host  : default-c6408258-74de-4b26-af25-5940f92a87c1
Relocations : (not relocatable)
Packager    :
Vendor      : InfluxData
URL         :
Summary     : Distributed time-series database.
Description :
Distributed time-series database.

InfluxDB OSS is now installed in the system.

# 3. Starting and enabling the InfluxDB Service

Once the installation is done, we need to start the service. In RHEL based systems, the service is not started by default. Start it using this command:

sudo systemctl start influxdb

Confirm that the service was started successfully using this command:

$ sudo systemctl status influxdb
● 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-12-01 17:28:14 EAT; 21s ago
  Process: 131635 ExecStart=/usr/lib/influxdb/scripts/ (code=exited, status=0/SUCCESS)
 Main PID: 131636 (influxd)
    Tasks: 8 (limit: 23168)
   Memory: 71.2M
   CGroup: /system.slice/influxdb.service
           └─131636 /usr/bin/influxd

Dec 01 17:28:13[131635]: ts=2021-12-01T14:28:13.776214Z lvl=info msg="Open store (start)" log_id=0Y9bAzcW000 service=storage-engine service=store >
Dec 01 17:28:13[131635]: ts=2021-12-01T14:28:13.776268Z lvl=info msg="Open store (end)" log_id=0Y9bAzcW000 service=storage-engine service=store op>
Dec 01 17:28:13[131635]: ts=2021-12-01T14:28:13.776390Z lvl=info msg="Starting retention policy enforcement service" log_id=0Y9bAzcW000 service=re>
Dec 01 17:28:13[131635]: ts=2021-12-01T14:28:13.776405Z lvl=info msg="Starting precreation service" log_id=0Y9bAzcW000 service=shard-precreation c>
Dec 01 17:28:13[131635]: ts=2021-12-01T14:28:13.776480Z lvl=info msg="Starting query controller" log_id=0Y9bAzcW000 service=storage-reads concurre>
Dec 01 17:28:13[131635]: ts=2021-12-01T14:28:13.779717Z lvl=info msg="Configuring InfluxQL statement executor (zeros indicate unlimited)." log_id=>
Dec 01 17:28:14[131635]: ts=2021-12-01T14:28:14.075756Z lvl=info msg=Starting log_id=0Y9bAzcW000 service=telemetry interval=8h
Dec 01 17:28:14[131635]: ts=2021-12-01T14:28:14.075789Z lvl=info msg=Listening log_id=0Y9bAzcW000 service=tcp-listener transport=http addr=:8086 p>
Dec 01 17:28:14[131635]: InfluxDB started
Dec 01 17:28:14 systemd[1]: Started InfluxDB is an open-source, distributed, time series database.

The Active: active (running) in the output confirms that the service was started successfully.

To enable the service to start on boot, use this command:

sudo systemctl enable influxdb

When installed as a service, InfluxDB stores data in the following locations:

  • Time series data: /var/lib/influxdb/engine/
  • Key-value data: /var/lib/influxdb/influxd.bolt.
  • influx CLI configurations: ~/.influxdbv2/configs (see influx config for more information) .

# 4. Installing InfluxDB v2 cli

InfluxDB Cli is available in the repo we added earlier. Use this command to install

sudo dnf install -y influxdb2-cli

Check the installed package information using this command

$ rpm -qi influxdb2-cli
Name        : influxdb2-cli
Epoch       : 0
Version     : 2.2.1
Release     : 1
Architecture: x86_64
Install Date: Thu 02 Dec 2021 10:10:05 AM EAT
Group       :
Size        : 16289792
License     : MIT
Signature   : RSA/SHA256, Wed 10 Nov 2021 12:48:37 AM EAT, Key ID 684a14cf2582e0c5
Source RPM  : influxdb2-cli-2.2.1-1.src.rpm
Build Date  : Wed 10 Nov 2021 12:26:53 AM EAT
Build Host  : default-5c006e36-3184-4233-81c1-fc623e69407d
Relocations : (not relocatable)
Packager    :
Vendor      : InfluxData
URL         :
Summary     : CLI for managing resources in InfluxDB v2
Description :
CLI for managing resources in InfluxDB v2

Youcan now use the influx command in the commandline. Confirm the version installed and check reachability to the server with ping

$ influx version
Influx CLI 2.2.1 (git: 31ac783) build_date: 2021-11-09T21:24:22Z

$ influx ping

# 5. Open InfluxDB Service Port on the firewall

With the service started, open the port on the firewall so you can access the server from the network. This will be neccessary if you are accessing the service using the port. This is only needed if you enforce firewall rules and you have firewalld installed.

sudo firewall-cmd --add-port=8086/tcp --permanent
sudo firewall-cmd --reload

# 6. Set up InfluxDB

The initial setup process for InfluxDB walks through creating a default organization, user, bucket, and Operator API token. The setup process is available in both the InfluxDB user interface (UI) and in the influx command line interface (CLI).

# Set up InfluxDB through the UI

  1. With InfluxDB running, visit localhost:8086.
  2. Click Get Started
# Set up your initial user
  1. Enter a Username for your initial user.
  2. Enter a Password and Confirm Password for your user.
  3. Enter your initial Organization Name.
  4. Enter your initial Bucket Name.
  5. Click Continue.

InfluxDB is now initialized with a primary user, organization, and bucket. You are ready to write or collect data.

# Set up InfluxDB through the influx CLI

Begin the InfluxDB setup process via the influx CLI by running:

influx setup
  1. Enter a primary username.
  2. Enter a password for your user.
  3. Confirm your password by entering it again.
  4. Enter a name for your primary organization.
  5. Enter a name for your primary bucket.
  6. Enter a retention period for your primary bucket—valid units are nanoseconds (ns), microseconds (us or &#xB5;s), milliseconds (ms), seconds (s), minutes (m), hours (h), days (d), and weeks (w). Enter nothing for an infinite retention period.
  7. Confirm the details for your primary user, organization, and bucket.

This is the output in my server

$ influx setup
> Welcome to InfluxDB 2.0!
? Please type your primary username citizix
? Please type your password ****************
? Please type your password again ****************
? Please type your primary organization name citizix
? Please type your primary bucket name citizix
? Please type your retention period in hours, or 0 for infinite 4380
? Setup with these parameters?
  Username:          citizix
  Organization:      citizix
  Bucket:            citizix
  Retention Period:  4380h0m0s
User	Organization	Bucket
citizix	citizix		citizix

InfluxDB is now initialized with a primary user, organization, bucket, and API token. InfluxDB also creates a configuration profile for you so that you don’t have to add your InfluxDB host, organization, and token to every command. To view that config profile, use the influx config list command.

$ influx config list
Active	Name	URL			Org
*	default	http://localhost:8086	citizix

To continue to use InfluxDB via the CLI, you need the API token created during setup. To view the token, log into the UI with the credentials created above. You can also use this command to view the token

$ influx auth list
ID			Description	Token										User Name	User ID			Permissions
088aa1517a763000	citizix's Token	Token_xxxxx	citizix		088aa15162b63000     	[read:/authorizations write:/authorizations read:/buckets write:/buckets read:/dashboards write:/dashboards read:/orgs write:/orgs read:/sources write:/sources read:/tasks write:/tasks read:/telegrafs write:/telegrafs read:/users write:/users read:/variables write:/variables read:/scrapers write:/scrapers read:/secrets write:/secrets read:/labels write:/labels read:/views write:/views read:/documents write:/documents read:/notificationRules write:/notificationRules read:/notificationEndpoints write:/notificationEndpoints read:/checks write:/checks read:/dbrp write:/dbrp read:/notebooks write:/notebooks read:/annotations write:/annotations]

You are ready to write or collect data.

# 7. Common operations on InfluxDB

Creating an org

influx org create -n citizix

Create bucket. The default retention is infinite by default, a retention can be defined when creating a bucket

$ influx bucket create --org citizix --name telegraf --retention 4380h
ID			Name		Retention	Shard group duration	Organization ID		Schema Type
3230c5ca8153dcd8	telegraf	4380h0m0s	168h0m0s		9d8c5d7565722d99	implicit

To list buckets (organization is required) :

influx bucket find --org citizix

InfluxDB v2 offers better security and authorizations management (stored in the bolt database).

To create a user

$ influx user create --name telegraf --org citizix --password SecretP4ss!
ID			Name
088aa327efb63000	telegraf

Then authorizations are defined for the user, in the example below, the user telegraf is allowed to read and writes in its organization buckets

$ influx auth create --user telegraf --read-buckets --write-buckets
ID			Description	Token												User Name	User ID			Permissions
088aa43d6c363000			52_9XBWNnygV2F_6axNezT5Xr-pkW4SX6xktLlfC5IQZxo4twvvj3B1W7nwU6FNcq0p7eE47NOD6rbGn6yyGGg==	telegraf	088aa327efb63000	[read:orgs/9d8c5d7565722d99/buckets write:orgs/9d8c5d7565722d99/buckets]

# Conclusion

We managed to install InfluxDB and Influx cli in this guide.

comments powered by Disqus
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy