Cyberithub

How to Install InfluxDB2 on Ubuntu 20.04 LTS [Step by Step]

Advertisements

In this article, I will take you through the steps to install InfluxDB2 on Ubuntu 20.04 LTS. InfluxDB is an open source time series database mostly suitable for use cases like storage and retrieval of large amount of time-stamped data which includes real time analytics data, IoT data, application metrics and many more. It is preferred due to its fast processing and low latency features. InfluxDB also offers an SQL-like query language for interacting with data.

It is known to be a part of TICK stack which comprises Telegraf, InfluxDB, Chronograf and Kapacitor. While in this article we are looking to install InfluxDB2, we will see the other ones in later articles. More on InfluxDB Official website.

What is Time Series Database

It is a special and unique kind of database which stores measurements or events that are tracked, monitored, downsampled and aggregated over time.

How to Install InfluxDB2 on Ubuntu 20.04 LTS [Step by Step]

How to Install InfluxDB on Ubuntu 20.04 LTS

Also Read: How to Install and Use Docker on Ubuntu 20.04 LTS [Step by Step]

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

b) You should have sudo or root access to run privileged commands.

c) You should have apt or apt-get utility available in your System.

c) You should also have wget, curl, tee and gpg utility available in your System.

 

Step 2: Add GPG Key

You can go to Official website and download the GPG key using below command. This is to verify the authenticity of the downloaded package.

root@cyberithub:~# wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null

 

Step 3: Setup Repo

Then setup the repo to download the Influxdb2 package using below command.

root@cyberithub:~# export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
root@cyberithub:~# echo "deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list > /dev/null

 

Step 4: Update Your Server

Next you need to update the package cache with all the packages information from newly added repository using apt update or apt-get update command as shown below.

root@cyberithub:~# apt-get update
Hit:1 http://ppa.launchpad.net/hluk/copyq/ubuntu focal InRelease
Hit:2 https://download.docker.com/linux/ubuntu focal InRelease
Hit:3 https://artifacts.elastic.co/packages/oss-7.x/apt stable InRelease
Hit:4 https://dl.google.com/linux/chrome/deb stable InRelease
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 https://repos.influxdata.com/ubuntu focal InRelease [4,736 B]
Ign:7 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease
Hit:8 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 Release
Get:10 https://repos.influxdata.com/ubuntu focal/stable amd64 Packages [1,271 B]
Get:12 https://repos.influxdata.com/ubuntu focal/stable i386 Packages [932 B]
Get:13 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [35.8 kB]
Hit:9 https://packages.graylog2.org/repo/debian stable InRelease

 

Step 5: Install InfluxDB2

Once the repository is added, you can download and install the latest version by using apt-get install influxdb2 command. This will install the package along with all its dependencies as shown below.

root@cyberithub:~# apt-get install influxdb2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
influxdb2-cli
The following NEW packages will be installed:
influxdb2 influxdb2-cli
0 upgraded, 2 newly installed, 0 to remove and 43 not upgraded.
Need to get 114 MB of archives.
After this operation, 195 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://repos.influxdata.com/ubuntu focal/stable amd64 influxdb2 amd64 2.1.1 [108 MB]
Get:2 https://repos.influxdata.com/ubuntu focal/stable amd64 influxdb2-cli amd64 2.2.1 [5,325 kB]
Fetched 114 MB in 9s (13.2 MB/s)
Selecting previously unselected package influxdb2.
........................................................................

 

Step 6: Verify Installation

Once the package installed successfully, you can verify the path of installed package files by using dpkg -L influxdb2 command as shown below.

root@cyberithub:~# dpkg -L influxdb2
/usr
/usr/bin
/usr/bin/influxd
/usr/lib
/usr/lib/influxdb
/usr/lib/influxdb/scripts
/usr/lib/influxdb/scripts/influxd-systemd-start.sh
/usr/lib/influxdb/scripts/influxdb.service
/usr/share
/usr/share/influxdb
/usr/share/influxdb/influxdb2-upgrade.sh
/usr/lib/influxdb/scripts/init.sh
/etc
/etc/logrotate.d
/etc/logrotate.d/influxdb

 

Step 7: Check InfluxDB Version

To check the current installed version, you can use influx version command. As you can see from the below output, current version is 2.2.1

root@cyberithub:~# influx version
Influx CLI 2.2.1 (git: 31ac783) build_date: 2021-11-09T21:24:22Z

 

Step 8: Start InfluxDB Service

By default, influxdb service will be in Inactive state. So after installation you need to start the service by using systemctl start influxdb command as shown below. To verify the status, you can use systemctl status influxdb command. If all goes well, then it should you in active and running state as shown below.

root@cyberithub:~# systemctl start influxdb
root@cyberithub:~# systemctl status influxdb
● influxdb.service - InfluxDB is an open-source, distributed, time series database
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-12-29 13:39:43 IST; 1s ago
Docs: https://docs.influxdata.com/influxdb/
Process: 60960 ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh (code=exited, status=0/SUCCESS)
Main PID: 60961 (influxd)
Tasks: 9 (limit: 4637)
Memory: 35.6M
CGroup: /system.slice/influxdb.service
└─60961 /usr/bin/influxd

Dec 29 13:39:42 cyberithub influxd-systemd-start.sh[60961]: ts=2021-12-29T08:09:42.714636Z lvl=info msg="Open store (start)" log_id=0YiJe2pG000 service=stor>
Dec 29 13:39:42 cyberithub influxd-systemd-start.sh[60961]: ts=2021-12-29T08:09:42.714705Z lvl=info msg="Open store (end)" log_id=0YiJe2pG000 service=storag>
Dec 29 13:39:42 cyberithub influxd-systemd-start.sh[60961]: ts=2021-12-29T08:09:42.714733Z lvl=info msg="Starting retention policy enforcement service" log_>
Dec 29 13:39:42 cyberithub influxd-systemd-start.sh[60961]: ts=2021-12-29T08:09:42.714744Z lvl=info msg="Starting precreation service" log_id=0YiJe2pG000 se>

 

Step 9: Enable Service

To persist the service start during System reboot, you need to enable the service by using systemctl enable influxdb command as shown below.

root@cyberithub:~# systemctl enable influxdb
Created symlink /etc/systemd/system/influxd.service → /lib/systemd/system/influxdb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/influxdb.service → /lib/systemd/system/influxdb.service.

 

Step 10: Setup InfluxDB

Now the InfluxDB is ready to be setup. You need to run influx setup command to start with the setup. Here you need to provide information like username, password, organization name, bucket name and retention period as shown below. Please feel free to specify the details as per your local requirement.

root@cyberithub:~# influx setup
> Welcome to InfluxDB 2.0!
? Please type your primary username cyberithub
? Please type your password *********
? Please type your password again *********
? Please type your primary organization name CyberITHub
? Please type your primary bucket name cyberithub_bucket
? Please type your retention period in hours, or 0 for infinite 0
? Setup with these parameters?
Username: cyberithub
Organization: CyberITHub
Bucket: cyberithub_bucket
Retention Period: infinite
Yes
User Organization Bucket
cyberithub CyberITHub cyberithub_bucket

 

Step 11: Check Token List

Once the setup is ready, you can check the authorization token list by using influx auth list command as shown below.

root@cyberithub:~# influx auth list
ID Description Token User Name User ID Permissions
08ad51473d9e4000 cyberithub's Token 0X1HNVy-Q0JqKzzCYlv32NhZ2bScq3axGlCdZsuGINEEtr7cmYRbCQdVsQSt4labLMB0lQISQzmzZDNARRyrGw== cyberithub 08ad51470f5e4000 [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]

 

Step 12: Create an User

If you want to create a new InfluxDB user then you can do that by using influx user create --name <user_name> --org <org_name> --password <password> syntax. Here we are creating a user test under organization CyberITHub with the password Test@123$ using influx user create --name test --org CyberITHub --password Test@123$ command as shown below.

NOTE:

Please note that here organization CyberITHub created before hand. If you want you can also create an organization using influx org create -n <org_name> command. But it is mandatory to create an organization before mentioning it in the below command.
root@cyberithub:~# influx user create --name test --org CyberITHub --password Test@123$
ID               Name
08ada1af52c60000 test

 

Step 13: Create User Authorization

You can also specify the user authorization using influx auth create --user <user_name> <authorization> syntax. For example, here we are providing bucket read and write authorization to user test using influx auth create --user test --read-buckets --write-buckets command as shown below.

root@cyberithub:~# influx auth create --user test --read-buckets --write-buckets
ID Description Token User Name User ID Permissions
08ada62956060000 DjIsnvUfqh2kyY_EOobQpS7LH1QodeD3d3VXkiLRYarmmrTJFigaZsxEH75GtLORr58hrfmYVWkWJTgCQl_l2A== test 08ada1af52c60000 [read:orgs/3847e4b9d3c473f5/buckets write:orgs/3847e4b9d3c473f5/buckets]

Leave a Comment