This guide shows how to install InfluxDB 2 on Raspberry Pi. InfluxDB is an open-source time-series database (TSDB). So, it is ideal to store sensor data with timestamps over a determined period of time.
Updated 16 May 2024
In previous tutorials, we showed you how to use InfluxDB cloud and send data from the ESP32 and ESP8266. The InfluxDB free cloud plan has some limitations that might not be suitable for your projects like the maximum 30-day data retention. If you want to have full control over your data, you can install InfluxDB on a local computer, like your Raspberry Pi.
The amount of data you can save will be limited to the storage of your Raspberry Pi, so make sure you use a microSD card with appropriate size storage.
Prerequisites
- MicroSD Card: The Pi doesn’t have built-in memory, so you’ll need a microSD card to install your OS. We’ll install the operating system on the microSD card. I recommend using a microSD card class 10 with at least 16GB of memory.
- Raspberry Pi 3 or Raspberry Pi 4
- 64-bit architecture—we’ll install Raspberry Pi OS (64-bit).
Install Raspberry Pi OS (64-bit)
InfluxDB 2 is only compatible with 64-bit architectures. So, you must be running Raspberry Pi OS (64-bit) or any other 64-bit OS (like Ubuntu, for example) to successfully install InfluxDB 2. Raspberry Pi OS (64-bit) is only compatible with Raspberry Pi 3 and 4.
Follow the next steps to install Raspberry Pi OS (64-bit).
1) Start by connecting the microSD card to your computer.
2) Go to the Raspberry Pi Software page.
3) Select and download the Raspberry Pi Imager (a tool to flash the OS on the microSD card) for your computer’s operating system.
4) Click on the downloaded file to install the Raspberry Pi Imager.
5) When the installation is complete, the Raspberry Pi Imager will open.
6) Click on Choose OS to select the Operating System. Select the Raspberry Pi OS (other) and then select Raspberry Pi OS (64-bit).
7) Choose storage. You must choose the microSD card where you want to install the OS.
8) The Raspberry Pi Imager allows you to access advanced settings to configure hostname, SSH, and Wi-Fi, among others—click on the gear icon to open advanced settings. If your window doesn’t show the gear icon, press Ctrl–Shift–X to open the advanced setting window.
9) You can set hostname (the default will be raspberrypi), enable SSH, and set a password for SSH connection.
10) Additionally, set up Wi-Fi with your local network credentials so that you can connect to your Raspberry Pi using Wi-Fi later on.
11) Set up your country and time zone. Finally, click Save.
12) After selecting the operating system, storage, and advanced settings, click on write to start installing the operating system on the microSD card.
13) Wait a few seconds while it installs the Operating System.
14) When the installation is complete click on Continue. It will eject the microSD card safely.
15) Now, remove the card from your computer and insert it into your Raspberry Pi. Then, apply power to the Raspberry Pi to start it.
Install InfluxDB 2 on a Raspberry Pi
We’ll use SSH to communicate with the Raspberry Pi. If you’re using Windows, you can use a software like PuTTY. If you’re using Linux or Mac OS, you can use the Terminal.
If you don’t know how to establish an SSH connection with your Pi, check these instructions.
With an SSH connection established with your Raspberry Pi, run the following command (copy the complete command with CTRL-C and then paste it into the Terminal window with a right-click on the mouse).
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install influxdb2
Issues with the installation? Check this page for the official instructions. Make sure you select the platform Ubuntu & Debian.
At some time, it will ask you to install additional packages. Press Y and hit Enter to accept. After installing, the Terminal window should look as follows:
Type the following command to start InfluxDB as a background service on startup.
sudo service influxdb start
Run the following command to verify that InfluxDB is running as expected.
sudo service influxdb status
You should get something as follows:
This means that InfluxDB is successfully running as a service.
Note: you may also want to check the official installation instructions here or here.
Accessing InfluxDB on Raspberry Pi
Now, you can access InfluxDB on your Raspberry Pi IP address port 8086. My Raspberry Pi IP address is 192.168.1.106, so to access InfluxDB, I just need to type the following in my web browser:
192.168.1.106:8086
To get your Raspberry Pi IP address, you can run the following command:
hostname -I
When you first access InfluxDB, you’ll see the following screen. Click on Get Started.
You’ll need to set up an initial user. Fill in the form details, you can use whatever names you want. You need to remember the username and password so that you can access InfluxDB data later on.
Then, click on Continue to proceed.
Make sure you copy your operator API token before proceeding. You won’t be able to see it again.
Then, you can click on Quick Start.
You’ll be redirected to the Getting Started screen.
Wrapping Up
Congratulations! You’ve successfully installed InfluxDB on your Raspberry Pi and set up an initial user, organization, and bucket.
You are now ready to load data to InfluxDB.
You can follow one of the next tutorials to get started loading data from the ESP32 or ESP8266 to InfluxDB:
- ESP32: Getting Started with InfluxDB
- ESP8266 NodeMCU: Getting Started with InfluxDB
- ESP32/ESP8266: Send BME280 Sensor Readings to InfluxDB
Do you like Home Automation? Check our most complete eBook about this subject:
- SMART HOME with Raspberry Pi, ESP32, and ESP8266: Learn Node-RED and InfluxDB on a Raspberry Pi to build a Home Automation System with the ESP32 and ESP8266.
Thanks for reading.
post#3
Another great way to use a pi headless, is using VNC. Up to five devices can be fully remotely used via the internet (Windows, linux, android, iphone, rpis, whatever…).
Within the own network an home you can use as many devices as you want.
VNC is preinstalled on any rpi os with desktop. A truly great tool!
TEAMVIEWER also works very good, and some of the other remote tools.
With them you can work on serveral pis as if they would have a dedicated screen. It works even via a slow Edge-Connection on an old remote rasperry pi zero.Clumsy, but it works. If you have a newer pi then you can work even with 64kBit/s reasonably.
Thanks for sharing that.
I never thought of using Teamviewer with the Raspberry Pi. But it is indeed a smart way to access the Raspberry Pi “screen”.
Regards,
Sara
I first used TEAMVIEWER, but after a while they came along with “commercial usage”, which was not the case. I then switched to VNC. They left me alone and do my projects. I tested AnyDesk as well, and maybe this could be the best of all three in terms of features. E.g. the filetransfer function of AnyDesk is the best, and the user interface also. However the free version looks like crippleware. So, as a conclusion for makers, VNC is the best choice overall.
Influxdb does not install.
I get message “404 not found [ip:13.225.195.48. 443]
I tried several times but get same result.
Hi.
Did you install Raspberry Pi OS 64-bit?
Regards,
Sara
Hi, scanning over the IP address, you have an invalid ‘.’ after the 4th octet (48.)
Hi!
Just to let you know that I did this tutorial but using an Ubuntu container in Proxmox instead of a physical Raspberry PI. I used container template “ubuntu-21.04-standard_21.04-1_amd64.tar”. The only situation is that the container does not have GPG installed, but you can use command “apt install gpg” to install it. Do this just before running the “wget …etc, etc” commands.
As always, great and simple tutorial from RandomNerd!!!
Hello.
I just want to ask if there will be influxDB2 and microPython with ESP. There are tutorials on GitHub, but I “drowned” in it :). I created an account in InfluxDB, I started in Thonny, and here I “stuck”. InfluxDB only locally. Thanks.
Hi.
I’m sorry, I didn’t understand what you mean.
Do you want a similar tutorial using MicroPython?
What examples did you experiment with?
Regards,
Sara
Circumvent the cloud
From what I know, InfluxDB 2 can be installed on a vServer. However, even the cheapest one costs about 100 Eur/y.
So, a way to publish InfluxDB Data in the Web via a free server would be great.
Alternative: dygraphs
dygraphs, is a charting alternative with almost no requirements. No database needed, the metrics an be stored in simple CSVs. This runs everywhere.
However, it would be greate to have access to databases such as InfluxDB, SQLite, …
With the proper code this would be possible.
Addendum:
dygraphs at InfluxDay 2017:
https://youtu.be/I6E5e1HBFi0
Still Interesting!
I already have influxdb ver 1.8 on my rPI4. How would I upgrade/migrate?
Hi.
It is better to check the documentation: https://docs.influxdata.com/influxdb/v2.3/upgrade/v1-to-v2/
Regards,
Sara
Hi
A complete newbie to InfluxDB here. I have InfluxDB successfully installed on my raspberry pi 4B. I however have a problem accessing the UI in the Pi browser to complete the set-up/configuration. I get a “404 page not found” error each time I load the address. I am able to get to the configuration file of InfluxDB but do not know what else to do. Can you please assist?
Hi.
What are you referring to? In our installation instructions, you don’t need to edit any configuration file.
Regards,
Sara
Im new to all of this but got raspberrypi installed and connected via SSH with Putty. When I try to run the first command for installing influxdb I and getting errors such as
gpg: no valid OpenPGP data found. and E: Unable to locate package influxdb2. Any ideas what this issue is?
Did you copy the whole command?
Yes I copied the whole command and even tried breaking up the command
Try it like this:
Run the following commands sequentially to install InfluxDB
wget -q https://repos.influxdata.com/influxdb.key
echo '23a1c8836f0afc5ed24e0486339d7cc8f6790b83886c4c96995b88a061c5bb5d influxdb.key' | sha256sum -c && cat influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install influxdb2
When prompted, press Y and hit Enter.
Start InfluxDB by running the following command:
sudo service influxdb start
Check if InfluxDB is running:
sudo service influxdb status
Let me know if this works.
Tried the first command several times and nothing happens. also did first command and second command and still wasnt working.
ChristianAdmin@raspberrypi:~ $ wget -q https://repos.influxdata.com/influxdb.key
ChristianAdmin@raspberrypi:~ $ echo ’23a1c8836f0afc5ed24e0486339d7cc8f6790b83886c4c96995b88a061c5bb5d influxdb.key’ | sha256sum -c && cat influxdb.key | gpg –dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
sha256sum: influxdb.key: No such file or directory
influxdb.key: FAILED open or read
sha256sum: WARNING: 1 listed file could not be read
Are you running Raspberry Pi OS 64-bit?
Yes.
I’m not sure what might be wrong. Were you using a fresh RPi installation?
Those instructions worked just fine for us.
You might also want to take a look at the official web page: https://docs.influxdata.com/influxdb/v2.4/install/?t=Linux
Yes it was a fresh install. I guess I can try formatting the card and installing again….
Ok.
Then, tell me the results.
Regards,
Sara
https://repos.influxdata.com/ contains no raspian. So I switched to debian instead and it works, obviously. Change /etc/apt/sources.list.d/influxdb.list to
deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] https://repos.influxdata.com/debian buster stable
Hello,
please be aware that the people @ Influxdata have rotated their repository key for security reasons. This means that practically all instructions on the web are outdated. Please check here on how to get the correct repositoory key: https://www.influxdata.com/blog/linux-package-signing-key-rotation/
Hi.
Thanks for sharing and letting us know.
I’ll test the new instructions and update the tutorial soon.
Regards,
Sara
Hi, according to influxdata blog post recently they did rotate their signing key. To avoid getting GPG error signature couldn’t be verified, change https://repos.influxdata.com/influxdb.key into this https://repos.influxdata.com/influxdata-archive_compat.key
Hi.
Thanks for sharing.
I updated the tutorial with the new installation instructions: https://portal.influxdata.com/downloads/
Regards,
Sara
I’m seeing similar problems to those mentioned above following this tutorial and from the link you posted here on 2023/02/05 from influxdata.com… Still getting an unable to locate package influxdb2
Hi.
What is exactly the error that you get?
Regards,
Sara
Hello, I was unable to install influx on RP4. When executing:
sudo apt-get update && sudo apt-get install influxdb2
I get:
Err:1 https://repos.influxdata.com/debian stable InRelease
The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY D8FF8E1F7DF8B07E
Reading package lists… Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://repos.influxdata.com/debian stable InRelease: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY D8FF8E1F7DF8B07E
W: Failed to fetch https://repos.influxdata.com/debian/dists/stable/InRelease The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY D8FF8E1F7DF8B07E
W: Some index files failed to download. They have been ignored, or old ones used instead.
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package influxdb2
Any suggestions on how to solve it?
same for me, I follow
Hi.
What version of the Raspberry Pi OS are you using?
Regards,
Sara
same issue here. tracking.
Hi.
What is exactly your issue?
Regards,
Sara
Hi. I figured it out. i was running 32 bit OS. I redid it with 64 bit image and it worked the first time.
Is there a way that i can write the db to a external drive or run it from there? so I dont have to be writing to the sd card all the time? thanks
Yes. I think that is possible, but I don’t have any tutorial about that subject.
First, you need to figure out how to configure an external drive with the RPi.
Then, you may need to search how to change the InfluxDB saving location to the HDD instead of the microSD card.
Regards,
Sara
Same error here for raspi2b.
Unable to locate package influxdb2
Hi.
Are you using Raspberry Pi OS 64-bit?
InfluxDB 2 is not compatible with 32-bit.
Regards,
Sara
I had the exact same issue. I did some googleing and found out influxdb2 is not compatible with 32 bit version of the RPI OS. After installing on 64 bit version it worked the first time following the steps on this tutorial.
InfluxDB is perfectly installed on Raspberry Pi 4B (8GB) under Raspberry Pi 64 bit OS Lite
Installed Telegraf but getting error while activating it with the command: $ sudo service telegraf start
Kindly suggest what to do
Thanks for the Tutorial. I was able to install the Influxdb under Rasp Pi4. Great
Hi,
after following your instructions (installation was smooth) I missed to note down the operator API token. Can I view this via CLI?
Thanks, Frank
Hi.
You can create another API token on the InfluxDB dashboard interface and use that one instead.
Regards,
Sara
hallo Leute,
gute Anleitung,aber sie weisen am Beginn auf die SD Karten Größe hin und hinzu kommt noch die Anzahl der Schreibzugriffe. deswegen suche ich nach einer einfachen Anleitung die Daten extern zu speichern . influxdb funktioniert wie beschrieben aber die Daten auf den USB stick (zukünftig SSD) zubekommen scheitert . wenn ich nach Anleitung von influxdb die Pfade ändere starte der influxdb Server nicht mehr. ich bin Anfänger und suche im Internet wo es einige unterschiedliche Anleitungen gibt , gute und anspruchsvolle. haben sie für mich einen einfache ( copie and paste) weg zum Ziel?