Deploy PostgreSQL on Raspberry Pi3 via Pantacor Hub

With Pantavisor and Pantacor Hub product makers can easily manage and update embedded devices. Pantavisor is the framework for containerized embedded Linux development that connects devices and containerizes the embedded firmware user-land as well as any apps you want to run on the device. In this tutorial, we’ll show you how to install Pantavisor on to a Raspberry Pi3. You’ll then claim your device and make it available from the Pantacor Hub dashboard. Finally you’ll containerize and deploy PostgreSQL onto the device and connect to it using the database dashboard Adminer.

Prepare your Raspberry Pi3 device for PostgreSQL with these 6 Steps:

Step 1: Flash the RPi3 initial stable image onto your SD card.

a) Download RPI3 initial stable image:

Click to download

b) unzip the device image with:

Run $ unxz rpi3_initial_stable.img.xz

c) Write image onto the SK card with the Raspberry Pi Imager 1.2

Step 2: Boot your Raspberry Pi3

a) Insert the flashed SD card and attach the power supply.

Step 3: Sign up to Pantacor Hub

Step 4: Download & Install a CLI tool “pvr”

Note: pvr is a CLI that is used to interact with your device through Pantacor Hub platform. With a few pvr commands, you can share your firmware and projects as simply as a git tree. After downloading the pvr binary, move it to your bin folder.

PVR Cli download options:

Linux(AMD64): Download Linux(ARM32v6): Download Darwin(AMD64): Download

pvr clone; pvr commit; pvr post

To install and build from GitLab source code:

$ go get gitlab.com/pantacor/pvr
$ go build -o ~/bin/pvr gitlab.com/pantacor/pvr

Note: You need “GOLANG” to be installed in your system for building pvr from gitlab source.

Step 5: Detect and claim your device

a) Connect a LAN cable between your RPi3 and your computer or router.
b) Open your terminal and run
$ pvr scan device
c) Claim your device

$ pvr claim -c merely-regular-gorilla https://api.pantahub.com:443/devices/5f1b9c44e193a5000afa9901

d) Log into Pantacor Hub and check whether the newly claimed device appears in the dashboard.

Step 6: Clone the device to your computer using your device Clone URL:

$ pvr clone https://pvr.pantahub.com/sirinibin/presently_learning_pelican/0 presently_learning_pelican

Now your device is ready to deploy PostgreSQL

Deploy PostgreSQL to the device with these 3 steps:

Step 1: Add postgreSQL to the device and then deploy the change.

a) Add “postgresql” app
$ pvr app add postgresql --from=arm32v7/postgres:9.5-alpine --config-json=<(echo -n -e '{
"Env": [
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "POSTGRES_USER=root",
  "POSTGRES_PASSWORD=123",
  "LANG=en_US.utf8",
  "PGDATA=/var/lib/postgresql/data"
]
}')
b) Deploy the changes
 $ pvr add .
 $ pvr commit
 $ pvr post

Step 2: Access the PostgreSQL through a shell

psql -h 10.42.0.231 -U root -P 123

Step 3: Access PostgreSQL with adminer

Adminer is a dashboard app which can be used to visually manage the mysql database

By default Adminer is served on port 8080

a) Add adminer to the device with:

pvr app add adminer —from=arm32v7/adminer

b) Deploy the changes
 $ pvr add .
 $ pvr commit
 $ pvr post
c) Access the Adminer dashboard with http://10.42.0.231:8080/
d) Log into the Adminer dasdhboard by entering the following credentials
 System: PostgreSQL
 Server:10.42.0.231
 Username:root
 Password:123

Now you can easily Create/update/delete postgrSQL databases/tables through Adminer

You are Done!