This article explains how to set up InfluxDB 2 on a Raspberry Pi. A free and open-source time-series database is InfluxDB (TSDB). Therefore, it is desirable to store sensor data that includes timestamps across a specific time frame.
There are several restrictions in the InfluxDB free cloud plan that might not be appropriate for your applications, such as the maximum 30-day data retention. Install InfluxDB on a local computer, such as your Raspberry Pi, if you want complete control over your data.
Make sure you choose a MicroSD card with enough storage space because the quantity of data you can save will be restricted by Raspberry Pi's storage.
Prerequisites
- MicroSD Card: Since the Raspberry Pi lacks internal memory, you must install your operating system on a microSD card. On the microSD card, the operating system will be installed.
- I advise using a class 10 microSD card with at least 16GB of storage.
- Raspberry Pi 3 or the Raspberry Pi 4
- 64-bit architecture: Raspberry Pi OS will be installed (64-bit)
Setup the Raspberry Pi OS (64-bit)
Only 64-bit architectures are compatible with InfluxDB 2 today. In order to properly install InfluxDB 2, you must be using the 64-bit versions of the Raspberry Pi OS or any other operating system (such as Ubuntu, for example). Only the Raspberry Pi 3 and 4 are compatible with Raspberry Pi OS (64-bit).
Installing Raspberry Pi OS requires the following actions (64-bit).
- Begin by connecting your computer and microSD card.
- Visit the website for Raspberry Pi software.
- Decide the operating system for your machine to use and download the Raspberry Pi Imager (a tool to flash the OS on the microSD card).
- To set up the Raspberry Pi Imager, click the downloaded file.
- The Raspberry Pi Imager will launch when the installation is finished.
- To choose the operating system, click Choose OS. After choosing Raspberry Pi OS, choose Raspberry Pi OS (other) (64-bit).
- Opt for storage. The microSD card you wish to install the OS on must be selected.
- You may access advanced options in the Raspberry Pi Imager to set up hostname, SSH, and Wi-Fi, among other things. Click the gear icon to enter advanced settings. If the gear symbol isn't visible in your window, use Ctrl-Shift-X to bring up the advanced settings window.
- You may configure the hostname (which is raspberrypi by default), activate SSH, and specify a password for the SSH connection.
- Additionally, configure Wi-Fi using your local network login information so that you may subsequently access your Raspberry Pi over Wi-Fi.
- Establish your time zone and country. Lastly, select Save.
- Click on write to begin installing the operating system on the microSD card after selecting the operating system, storage, and advanced options.
- Be patient while the operating system is installed.
- Click Continue when the installation is finished. The microSD card will be removed securely.
- After that, take the card out of your computer and place it in the Raspberry Pi. After that, turn on the Raspberry Pi to get it going.
Installing InfluxDB 2 on Raspberry Pi Board.
To interact with the Raspberry Pi, we'll utilise SSH. An application like PuTTY can be used if you're using Windows. You can utilise the Terminal if you're running Mac OS or Linux.
Check out these steps if you don't know how to connect through SSH to your Raspberry Pi.
Run the following command after your Raspberry Pi and SSH are connected (copy the complete command with CTRL-C and then paste it into the Terminal window with a right-click on the mouse).
wget -qO- https://repos.influxdata.com/influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
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
sudo apt-get update && sudo apt-get install influxdb2
It will eventually request that you install more packages. To accept, type Y and then click Enter. The Terminal window should appear as follows after installation:
sudo service influxdb start
Run the next command to make sure InfluxDB is functioning as it should.
sudo service influxdb status
You should purchase the following:
This indicates that InfluxDB is functioning effectively as a service.
Please take note that you may also wish to look at the official installation guidelines here.
Raspberry Pi InfluxDB Access
You may now connect to InfluxDB using the Raspberry Pi's IP address and port 8086. I can just enter the following in my web browser to access InfluxDB because my Raspberry Pi's IP address is 192.168.1.106:
192.168.1.106:8086
You may enter the following command to learn your Raspberry Pi's IP address:
hostname -I
The screen below is what you'll see when you first enter InfluxDB. Simply choose to Get Started.
You must create the first user. Fill in the form's information using any names you choose. The username and password must be kept in mind so that you may access InfluxDB data later.
Click Continue to continue after that.
You may then select Quick Start.
The Getting Started screen will be reached after the redirect.
Conclusion
Congratulations! You have successfully set up a first user, organisation, and bucket in InfluxDB on your Raspberry Pi.
You may now begin loading data into InfluxDB.