Skip to content

Latest commit

 

History

History
executable file
·
231 lines (176 loc) · 7.1 KB

File metadata and controls

executable file
·
231 lines (176 loc) · 7.1 KB

Edge Orchestration on Raspberry Pi 3 Cluster

Raspberry Pi3 Cluster

Preparing Raspberry Pi 3 board

Minimum H/W requirements

  • Raspberry Pi3: 2 pcs
  • Power Cable: 2 pcs micro USB
  • Ethernet Cable: 1 pcs (but you can use wireless)
  • Micro SD Card: 2 pcs 16 Gb

Recommended H/W requirements

  • Raspberry Pi3: 4 pcs
  • Power Cable: 4 Short micro USB
  • Multiport USB Charging HUB: 1 pcs
  • Ethernet Switch: 1 pcs
  • Ethernet Cable: Short 4 pcs (but you can use wireless)
  • Micro SD Card: 32 Gb
  • Cluster Case: 1 pcs

1. Download image and writing Raspbian OS on a SD card

To install the Raspbian OS follow the instructions.

2. Start Raspberry Pi 3

Insert the SD card into the Raspberry Pi 3 and turn on the power. Make configuration settings for the Raspbian the first time you turn it on. And you should enable ssh.

The steps described above need to be done with each Raspberry Pi 3 boards.


Quick start

This section provides how to download and run pre-built Docker image without building the project.

1. Install docker

  • docker
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker

2. Download Docker image from Docker Hub

To download the image, you must execute the command: docker pull lfedge/edge-home-orchestration-go:{tag}, where {tag} is a release name.

docker pull lfedge/edge-home-orchestration-go:latest

If it succeeds, you can see the Docker image as follows:

docker images

REPOSITORY                            TAG           IMAGE ID            CREATED             SIZE
lfedge/edge-home-orchestration-go     latest        740bcf622152        6 hours ago         161MB

3. Run with Docker image

How to run see here.


How to build

There are two options for building a edge-orchestration container:

  1. On your PC and downloading the edge-orchestration container image from the edge-orchestration.tar archive (recommended).
  2. Build directly on the Raspberry Pi 3 board.

After the end of the build, we strongly recommend using the tools to run commands on multiple Raspberry Pi 3 boards.


How to run

Tools to run commands on multiple Raspberry Pi 3 boards.

We hope that you already have SSH setup to access all your Raspberry Pi 3s and secondly, when accessing multiple Raspberry Pi 3 boards simultaneously, it is appropriate to set up key-based password-less SSH on all of your Raspberry Pi 3 boards.

PSSH – Parallel SSH (Recommended)

  1. Install pssh on your PC
sudo apt-get install pssh
  1. Setting the ip addresses of your Raspberry Pi 3 boards.

Enter the hostnames or IP addresses of remote boards with SSH Port in a file called hosts.

Example hosts file:

  1. Command execution on all boards:
    Format that we use: $ parallel-ssh -i -h hosts "<your command>"

Example:

parallel-ssh -i -h hosts "date"
[1] 16:47:47 [SUCCESS] [email protected]:22
Fri 12 Feb 2021 04:47:48 PM EET
[2] 16:47:47 [SUCCESS] [email protected]:22
Fri 12 Feb 2021 04:47:48 PM EET
[3] 16:47:47 [SUCCESS] [email protected]:22
Fri 12 Feb 2021 04:47:48 PM EET
[4] 16:47:47 [SUCCESS] [email protected]:22
Fri 12 Feb 2021 04:47:48 PM EET

Pdsh – Parallel Remote Shell Utility

Very similar to the utility described above

Fabric (w/o using RSA-keys)

  1. Install fabric on your PC
sudo apt-get install fabric
  1. Setting the ip addresses of your Raspberry Pi 3 boards.

Example fabfile.py file:

from fabric.api import *

env.hosts = [
        '[email protected]',
        '[email protected]',
        '[email protected]',
        '[email protected]',
]

env.password = 'raspberry'

@parallel

def cmd(command):
    sudo(command)

  1. Command execution on all boards:
    Format that we use: $ fab cmd:"<your command>"

Example:

fab cmd:"date"
[[email protected]] Executing task 'cmd'
[[email protected]] Executing task 'cmd'
[[email protected]] Executing task 'cmd'
[[email protected]] Executing task 'cmd'
[[email protected]] sudo: date
[[email protected]] sudo: date
[[email protected]] sudo: date
[[email protected]] sudo: date
[[email protected]] out: 
[[email protected]] out: SSH is enabled and the default password for the 'pi' user has not been changed.
[[email protected]] out: This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
[[email protected]] out: 
[[email protected]] out: 
[[email protected]] out: SSH is enabled and the default password for the 'pi' user has not been changed.
[[email protected]] out: This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
[[email protected]] out: 
[[email protected]] out: Fri 12 Feb 2021 05:09:20 PM EET
[[email protected]] out: 
[[email protected]] out: 
[[email protected]] out: SSH is enabled and the default password for the 'pi' user has not been changed.
[[email protected]] out: This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
[[email protected]] out: 

[[email protected]] out: Fri 12 Feb 2021 05:09:20 PM EET
[[email protected]] out: 

[[email protected]] out: Fri 12 Feb 2021 05:09:20 PM EET
[[email protected]] out: 
[[email protected]] out: 
[[email protected]] out: SSH is enabled and the default password for the 'pi' user has not been changed.
[[email protected]] out: This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.
[[email protected]] out: 

[[email protected]] out: Fri 12 Feb 2021 05:09:20 PM EET
[[email protected]] out: 

Done.

Shell script (w/o using RSA-keys)

An example of an initial script:

#!/bin/bash
# Hosts
hostarray=(
        "[email protected]"
        "[email protected]"
        "[email protected]"
        "[email protected]"
        )

for i in "${hostarray[@]}"; do
    sshpass -p "raspberry"  ssh "$i" "$@"
done

Suggest your options for improvement or utilities that can be used.

Now you can start running the edge-orchestration saving time and effort


Copy edge-orchestration.tar, set up and run edge-orchestration.

Next, need to copy edge-orchestration.tar archive to the Paspberry Pi 3 boards

scp edge-orchestration.tar [email protected]:.

Install the docker container (see here only docker part) and load the image using the command:

parallel-ssh -i -h hosts "docker load -i edge-orchestration.tar"

How to run see here.