How to Install and Configure InfluxDB2 in Debian 11

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 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. Setup InfluxDB
  6. 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. Add Influxdb gpg key using this command

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

Then add the repo

export DISTRIB_ID=$(lsb_release -si); export DISTRIB_CODENAME=$(lsb_release -sc)
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

Now update repos and install influxdb

sudo apt-get update && sudo apt-get install influxdb2

Confirm

$ apt-cache policy influxdb2
influxdb2:
  Installed: 2.1.1
  Candidate: 2.1.1
  Version table:
 *** 2.1.1 500
        500 https://repos.influxdata.com/debian bullseye/stable amd64 Packages
        100 /var/lib/dpkg/status

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 (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2021-12-07 07:38:17 UTC; 38s ago
       Docs: https://docs.influxdata.com/influxdb/
    Process: 24918 ExecStart=/usr/lib/influxdb/scripts/influxd-systemd-start.sh (code=exited, status=0/SUCCESS)
   Main PID: 24919 (influxd)
      Tasks: 8 (limit: 4626)
     Memory: 37.6M
        CPU: 523ms
     CGroup: /system.slice/influxdb.service
             └─24919 /usr/bin/influxd

Dec 07 07:38:16 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:16.921099Z lvl=info msg="Open store (start)" log_id=0YGy6LBG000 service=storage-engine service=store op_name=tsdb_open >
Dec 07 07:38:16 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:16.921171Z lvl=info msg="Open store (end)" log_id=0YGy6LBG000 service=storage-engine service=store op_name=tsdb_open op>
Dec 07 07:38:16 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:16.921196Z lvl=info msg="Starting retention policy enforcement service" log_id=0YGy6LBG000 service=retention check_inte>
Dec 07 07:38:16 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:16.921206Z lvl=info msg="Starting precreation service" log_id=0YGy6LBG000 service=shard-precreation check_interval=10m >
Dec 07 07:38:16 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:16.921246Z lvl=info msg="Starting query controller" log_id=0YGy6LBG000 service=storage-reads concurrency_quota=1024 ini>
Dec 07 07:38:16 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:16.923024Z lvl=info msg="Configuring InfluxQL statement executor (zeros indicate unlimited)." log_id=0YGy6LBG000 max_se>
Dec 07 07:38:17 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:17.208936Z lvl=info msg=Starting log_id=0YGy6LBG000 service=telemetry interval=8h
Dec 07 07:38:17 ip-10-2-40-122 influxd-systemd-start.sh[24919]: ts=2021-12-07T07:38:17.208978Z lvl=info msg=Listening log_id=0YGy6LBG000 service=tcp-listener transport=http addr=:8086 port=8086
Dec 07 07:38:17 ip-10-2-40-122 influxd-systemd-start.sh[24918]: InfluxDB started
Dec 07 07:38:17 ip-10-2-40-122 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 apt install -y influxdb2-cli

Check the installed package information using this command

$ apt-cache policy influxdb2-cli
influxdb2-cli:
  Installed: 2.2.1
  Candidate: 2.2.1
  Version table:
 *** 2.2.1 500
        500 https://repos.influxdata.com/debian bullseye/stable amd64 Packages
        100 /var/lib/dpkg/status

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
OK

5. 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 µ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
 Yes
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
0890f5a5baf6e000	citizix's Token	Token_xxxx==	citizix		0890f5a59cb6e000	[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.

6. 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