Bobcares

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 *

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

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF