wesupport

Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Install InfluxDB on Ubuntu 20.04

by | Oct 24, 2021

Wondering how to install InfluxDB on Ubuntu 20.04? We can help you.

As part of our Server Management Services, we assist our customers with several InfluxDB queries.

Today, let us see how our Support Techs perform the installation for our customers.

 

Install InfluxDB on Ubuntu 20.04

InfluxDB provides familiarity and ease of a powerful API for building apps with less code, less effort, and fewer configurations.

In order t0 begin, our Support Techs recommend having an Ubuntu 20.04 server and a Sudo user.

  • Download and Install the InfluxDB Package

First, we will install the InfluxDB server by pulling the installation files from the official repo.

We SSH to the server. Then to download and add the InfluxDB GPG key into the server, we run:

$ sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -

This command will result in an OK message.

After that, we add a new influxdb.list repository file to the list of available packages:

$ sudo echo "deb https://repos.influxdata.com/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Then, we update the package information index:

$ sudo apt update

Next, we install the influxdb package:

$ sudo apt install influxdb

Once done, we start the influxdb service:

$ sudo systemctl start influxdb

Later, to check the status of the InfluxDB server, we run:

$ sudo systemctl status influxdb

The package will be active and loaded on the server.

influxdb.service - InfluxDB is an open-source, distributed, time series da>
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor p>
Active: active (running) since Fri 2021-09-03 06:08:59 UTC; 2min 3s ago
Docs: https://docs.influxdata.com/influxdb/
  • Configure the InfluxDB Server

Now, we will configure a new admin user with root privileges for the InfluxDB server.

To do this, we execute the influx command.

$ influx

This will show the current connection, port, and version number.

Connected to http://localhost:8086 version 1.8.9
InfluxDB shell version: 1.8.9
>

The prompt > shows that the InfluxDB server is ready to accept commands.

To create an admin account, we run:

> CREATE USER admin WITH PASSWORD 'EXAMPLE_PASSWORD' WITH ALL PRIVILEGES

In addition, we need to make sure to replace EXAMPLE_PASSWORD with a strong value.

After that, we exit from the InfluxDB shell:

> quit

Eventually, we need to enable authentication. To do so, we modify the main InfluxDB configuration file.

We use nano to open the /etc/influxdb/influxdb.conf file:

$ sudo nano /etc/influxdb/influxdb.conf

Then we locate the line # auth-enabled = false under the [http] section.

...
[http]
...
# Determines whether user authentication is enabled over HTTP/HTTPS.
# auth-enabled = false
...

Here, we change the value of auth-enabled from false to true and remove the leading # symbol from the line to uncomment the setting.

...
[http]
...
# Determines whether user authentication is enabled over HTTP/HTTPS.
auth-enabled = true
...

Eventually, we save and close the file.

Next, to load the new security setting, we restart the influxdb service:

$ sudo systemctl restart influxdb

Now we can log in to the InfluxDB server with the admin username and password that we set:

$ influx -username 'admin' -password 'EXAMPLE_PASSWORD'

To verify everything is working, we run:

> SHOW DATABASES

We will see a default _internal database in the list like this:

name: databases
name
----
_internal
  • Create an InfluxDB Database

Moving ahead, we’ll set up a sample database that stores metrics from a sample water level monitoring system.

On the influx shell, we create the water_db database. To do so, we run:

> CREATE DATABASE water_db

Then we hit enter, this will give us a new prompt > and nothing else.

This means the command execution has no errors.

However, we can verify if we’ve successfully set up the water_db database:

> SHOW DATABASES

This will give us a list of two databases:

name: databases
name
----
_internal
water_db

We are done here. The database is now ready to accept new data.

  • Write InfluxDB Data

Now, we’ll execute additional InfluxQL statements against the new water_db database.

Therefore, before we proceed, we switch to the new water_db database. To do so, we run:

> USE water_db

We will get an output similar to the following:

Using database water_db

Now we have a database that can accept writes and queries.


  • InfluxDB HTTP API

As we know InfluDB we basically built for developers. Hence, it has a very useful API that allows querying metrics with common tools without writing additional codes.

To query data from the water_db database, we run:

$ curl -G 'http://localhost:8086/query?pretty=true' -u admin:EXAMPLE_PASSWORD --data-urlencode "db=water_db" --data-urlencode "q=SELECT \"tank_location\", \"value_in_ft\" FROM \"water_level\""

Here, we need to make sure to replace EXAMPLE_PASSWORD with the correct password value.

The output will look similar to this:

{
"results": [
{
"statement_id": 0,
"series": [
{
"name": "water_level",
"columns": [
"time",
"tank_location",
"value_in_ft"
],
"values": [
[
"2021-09-03T09:07:04.738274574Z",
"MIAMI",
10
],
[
"2021-09-03T09:07:13.290269685Z",
"SEATTLE",
5.4
],
[
"2021-09-03T09:07:29.030041003Z",
"DALLAS",
3.2
],
[
"2021-09-03T09:08:16.340252215Z",
"LOS-ANGELES",
1.3
]
]
}
]
}
]
}

Finally, the InfluxDB server and API will work as expected.

[Stuck in between? We are here to help you out]

 

Conclusion

In short, we saw the steps our Support Techs employ to install InfluxDB on Ubuntu 20.04.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags