Skip to content

Instantly share code, notes, and snippets.

@boseji
Last active February 5, 2022 17:34
Show Gist options
  • Save boseji/bb71910d43283a1b84ab200bcce43c26 to your computer and use it in GitHub Desktop.
Save boseji/bb71910d43283a1b84ab200bcce43c26 to your computer and use it in GitHub Desktop.
Raspberry Pi InfluxDB installation

Raspberry Pi InfluxDB: The solution for IoT Data storage

Raspberry Pi is costeffect linux computer very commonly used for IoT home automation projects.

Here are the 3 problems with conventional databases for IoT data store applications:

  • Too much or complex configuration
  • Unable to expire data / set retentional policies
  • Not tailor made of Time Series Data

Thankfully the easy to use InfluxDB solves all these problems and provides much more.

Installing InfluxDB in Raspbian

Adding Repository Key for InfluxDB

First we need to add the Repository Key for InfluxDB to the installation.

For this fire up a Shell terminal via putty or ssh pi@raspberrypi to your favorite Raspberry Pi on the network. Instead if you are lucky to have a montor connected then just open Lxterminal utility from the desktop.

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

This command would install the keys.

Adding Repository URL for InfuxDB

Next we need to add the required repository.

For this we need to know what is the release (OS version) we are working on.

lsb_release -a

For this command you would get some output like:

No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 8.0 (jessie)
Release:        8.0
Codename:       jessie

Here the version of OS is jessie or Debian 8.0.

In some cases it might be also wheezy or Debian 7.0 the older version of the OS.

This information about the OS would be used to determin what command we use next.

For jessie or Debian 8.0

sudo apt install apt-transport-https
echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update

For wheezy or Debian 7.0

sudo apt install apt-transport-https
echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt update

In case any of the above two fail !!

The https:\\ is not enabled in the default apt install for Rasberry Pi.

In order to enable that we use:

sudo apt install apt-transport-https

This would install the support, then go ahead a execute the above commands.

Installing InfluxDB

The actual install is pretty much the same as any other package from apt.

sudo apt-get install influxdb

Combined Commands : Installing InfluxDB

If you are really know what you want and want, here is a combined list of commands for the respective OS distros.

For jessie or Debian 8.0

sudo apt-get update && sudo apt install apt-transport-https curl
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb

For wheezy or Debian 7.0

sudo apt-get update && sudo apt install apt-transport-https curl
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb

Firewall configuration (OPTIONAL)

In you you have firewall like ufw enabled then you would need to open up the Admin port for the database.

Use the following commands

sudo ufw stats verbose # Just check if we have the firewall running
sudo ufw allow from {Subnet/IPaddress} to any port 8083 proto tcp

Replace the {Subnet/IPaddress} with the required Sub-net like 192.168.1.0/24 or a specific IP Address like 192.168.1.12

This would enable the Admin Port for the InfluxDB webinterface through the firewall.

Configure InfluxDB Admin Interface

In order to configure the internals of the InfluxDB operation one needs to modify the influxdb.conf file in the /etc/influxdb directory.

Open this file in any of your editors, like here in nano:

sudo nano -c /etc/influxdb/influxdb.conf

Edit the specific segment:

.....
###
### Controls the availability of the built-in, web-based admin interface. If HTTPS is
### enabled for the admin interface, HTTPS must also be enabled on the [http] service.
###
### NOTE: This interface is deprecated as of 1.1.0 and will be removed in a future release.

[admin]
  # Determines whether the admin service is enabled.
  enabled = true

  # The default bind address used by the admin service.
  bind-address = ":8083"

  # Whether the admin service should use HTTPS.
  # https-enabled = false

.....

The line:189 of influxdb.conf file has the feature to enable the admin interface.

This line needs to be uncommented and changed to enalbled = true

Next to observe at line:192 of influxdb.conf file, this specifies the port number.

This line needs to be uncommented and changed to bind-address = ":8083"

That would do the needful to configure the admin interace.

Start the InfluxDB

Starting the database is a straightforward command:

sudo service influxdb start

In case you would like to restart after some modifications to config:

sudo service influxdb restart

Also same using systemd

sudo systemctl start influxdb

and

sudo systemctl restart influxdb

........................

Hope to add more sections as I find more information - Please comment and post updates

@steam73
Copy link

steam73 commented Jan 1, 2018

Then I found this info telling me to use chronograf, but their links are not ok anymore either. Where should I go for the admin panel?

@AxelRHD
Copy link

AxelRHD commented Jan 9, 2018

@steam73 the admin-interface was removed from Influx:

https://docs.influxdata.com/influxdb/v0.9/tools/web_admin/

@K4nape
Copy link

K4nape commented Jan 25, 2018

Hi bro,
Why i get this error?

/etc/influxdb/influxdb.conf

[http]
  enabled = true
  bind-address = ":8083"

Error:
image

@greggyd
Copy link

greggyd commented Feb 17, 2018

There is no longer an admin interface in influx: https://docs.influxdata.com/influxdb/v1.4/tools/web_admin/

@tobyweston
Copy link

This seems to good to be true but I just tried running sudo apt-get install influxdb on a fresh Stretch install and it worked! w00t! 😱

$ influxd 

 8888888           .d888 888                   8888888b.  888888b.
   888            d88P"  888                   888  "Y88b 888  "88b
   888            888    888                   888    888 888  .88P
   888   88888b.  888888 888 888  888 888  888 888    888 8888888K.
   888   888 "88b 888    888 888  888  Y8bd8P' 888    888 888  "Y88b
   888   888  888 888    888 888  888   X88K   888    888 888    888
   888   888  888 888    888 Y88b 888 .d8""8b. 888  .d88P 888   d88P
 8888888 888  888 888    888  "Y88888 888  888 8888888P"  8888888P"

[run] 2018/06/15 10:53:04 InfluxDB starting, version 1.0.2, branch unknown, commit unknown
[run] 2018/06/15 10:53:04 Go version go1.7.3, GOMAXPROCS set to 1
[run] 2018/06/15 10:53:04 Using configuration at: /etc/influxdb/influxdb.conf
run: open server: listen: listen tcp :8088: bind: address already in use

@techi602
Copy link

@tobyweston yeah, but version 1.0.2 in default repo is 2 years old (which is unusable for many users)
pi@amy:~/bme280 $ apt-cache madison influxdb influxdb | 1.6.1-1 | https://repos.influxdata.com/debian stretch/stable armhf Packages influxdb | 1.0.2+dfsg1-1 | http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment