How To Install InfluxDB on AlmaLinux or Rocky 8 to create database

Here we learn the steps and commands to install the InfluxDB database server and secure it on AlmaLinux or Rocky Linux 8 using the terminal. And also how to access it remotely using Influx’s HTTP API…

What is InfluxDB?

InfluxDB is an open-source database developed by InfluxData that prioritizes maximum efficiency with limited complexity, unlike relational databases such as MySQL and MariaDB or structured databases such as Redis. Although the software is distributed under an open-source license, the company also offers commercial extensions such as access controls for business customers within its own root server and cloud services with graphical data analysis via a web interface.

Relational databases like MySQL are extremely flexible but due to the complex structure and accordingly requires high memory and computing capacity, whereas InfluxDB uses a simple structure. It enables databases to be managed quickly and reliably without the need for extensive analyzes of a tabular structure or the analysis of numerous cross-references. These features enable the DBMS to register data sets in real-time, including sensors or states, using smart devices of the Internet-Of-Thing (IoT), and to save and transmit them almost at the same time. Since version 2.0, InfluxDB has made it possible to use its own programming language called Flux for querying information.

Key features of InfluxDB:

  • Specialization in time series
  • Combination of several sources in one central instance
  • Very high processing efficiency
  • Support of Flux as a scripting language for administration
  • Collection of data from different sources, for example via the third-party API
  • Exchange of data via Apache Arrow as an interface

 

Steps to install InfluxDB on AlmaLinux or Rocky 8

The steps given below to install InfluxDB on AlmaLinux are also applicable for RHEL or CentOS 8 Linux server operating systems.

Step 1: Add InfluxDB repository

Although we can download the latest RPM package of InfluxDB directly from its official website, however, the repository way will ensure our system will get its latest packages every time you run the system update command-

Copy the below given whole block of command and paste it into your command terminal. After that hit the enter key and provide your user password to create an InfluxDB repo file on your system.

sudo tee /etc/yum.repos.d/influxdb.repo<<EOF
[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
EOF

Add InfluxDB repository

 

Step 2: Run system update command

Next, use the system package manager DNF to run the system update command this will not only install the latest available packages & updates for the system but also refresh the repo cache.

sudo dnf update

 

Step 3: Command to install InfluxDB on Almalinux or Rocky Linux

Finally, use the given command to download and install the InfluxdB packages on your RPM-based Linux operating system.

sudo dnf install influxdb

 

Step 4: Start and Enable Influxdb service

To let the database server service start automatically with the system boot, start and enable it using the given commands.

sudo systemctl start influxdb
sudo systemctl  enable influxdb

 

Step 5: Allow InfluxDB TCP port 8086 in Firewall

If you have enabled the system firewall then allow the port 8086 in it to access InfluxDb from the client over its HTTP API.

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

In the same way, we can also open TCP port 8088 using the above command, if needed. This port is used by the RPC service for backup and restore. In case you want to change its ports, then that can be done from its configuration files resides at /etc/influxdb/influxdb.conf

 

Access CLI to create user and database

Simply type:

influx

Create at least one Admin user using the given command. Replace the admin and password with the one you want to set.

CREATE USER admin WITH PASSWORD 'password' WITH ALL PRIVILEGES

To check all users:

SHOW USERS

To create a Database:

CREATE DATABASE dbname

Get a List of all DBs

SHOW DATABASES

To grant all privileges of database to available use, use this syntax

GRANT  ALL  ON database_name TO username

Note: Replace the database_name and username values with yours.

To REVOKE all database privileges from an existing use

REVOKE  ALL ON database_name FROM username

To check what are the rights or privileges assigned to some InfluxDB user on some databases, use:

SHOW GRANTS FOR user_name

 

Enable Authentication to connect and manage Database remotely using Influx’s HTTP API

If you have allowed the Influxdb port 8086 in your Almalinux or Rocky’s firewall then we can use the remote system’s command terminal to issue database commands.

For that enable HTTP and Authentication in the InfluxDB configuration file.

sudo nano /etc/influxdb/influxdb.conf

Enable the following things by removing # available in front of them. Ans also change auth-enable = false to auth-enable = true as shown in the screenshot.

[http]
enabled = true
bind-address = ":8086"
auth-enabled = true  
log-enabled = true

Save the file by pressing Ctrl+Alt, after that Y, and then hit the Enter key.

Enable HTTP authentication in InfluxDB

Restart InfluxDB services:

sudo systemctl restart influxdb

Now, from any other system, you can use the terminal to issues commands, such as to create a Database:

Make sure curl is already on your remote system.

curl --user admin:pass -k -XPOST 'http://server-ip-address:8086/query' --data-urlencode \
'q=CREATE DATABASE "h2sdev"'

In the above command change the admin user and password with the one you have created on your Influx Database server. Whereas h2sdev is the database we want to create.

the output for the command will be:

{"results":[{"statement_id":0}]}

 

Point to be noted: Once you enable the authentication in the configuration file, you won’t be able to access the InfluxDB commands on the local server without authenticating it first. Thus, every time you want to access the InfluxDB server CLI on the localhost, need to specify the user and password, in the following way:

influx -username username -password 'password'

Replace the username and password in the above command. Remember password must be in single quotes as shown in the above command syntax.

Secure InfluxDB on AlmaLinux or Rocky

This was the quick way to install InfluxDB Database Server and use it on Almalinux or Rocky Linux 8. To know more about security and authentication- see the official documentation.

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

X