Date: Fri, 29 Mar 2024 07:07:10 +0000 (UTC) Message-ID: <1546768712.11587.1711696030954@aws-us-west-2-edgex-confluence-1.web.codeaurora.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_11586_410570953.1711696030953" ------=_Part_11586_410570953.1711696030953 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
This document will walk you through installing and running the e= ssential EdgeX Foundry microservices on a RaspberryPi for testing and evalu= ation. This should not be used in a production environment. This guide is f= or developers who want to learn EdgeX by running it as a mock gateway devic= e on a commonly available hobbyist device.
Know your device
<= /span>This guide has been tested to work on a RaspberryPi 3B+, it may work on = other models of the RaspberryPi 3, but it will not work on any older or lig= hter variations of the RaspberryPi as it requires a 64bit capable CPU.
For this setup we will be using the 64-bit version of Ubuntu Server 18.0= 4.3 LTS specifically for the Raspberry Pi 3B+.
Download the image file for Ubuntu Server from http://cdi= mage.ubuntu.com/ubuntu/releases/bionic/release/ubuntu-18.04.5-preinstalled-= server-arm64+raspi3.img.xz then insert your microSD card into you= r computer so that you can flash the disk image onto it. If you are running= Ubuntu or any other Linux distro, you can flash the image using this comma= nd:
xzcat ubuntu-18.04.5-preinstalled-server-arm64+raspi3= .img.xz | sudo dd bs=3D32M of=3D/dev/mmcblk0 iflag=3Df= ullblock oflag=3Ddirect status=3Dprogress; sync
Note that you will need to replace the part in bold with the path to you= r own microSD card, and that it should point to the device and not a partit= ion on the device.
After this is done, insert the microSD card into your Raspberry Pi 3B+ a= nd power it on. You should see a screen with the Raspberry Pi logos at the = top. Even though we are flashing a pre-installed image, there are still a n= umber of things that need to be setup on first boot. However, after a few m= inutes, it should take you to the login screen. The default username is 'ub= untu' and default password is 'ubuntu'. You will be required to change the = password on first login.
The RaspberryPi 3B+ has a full gig of ram, but while running MongoDB (an= d also when building from source if you choose to do so) this may not be en= ough. So before going any further you will first want to create some additi= onal memory capacity by adding a swap file to your filesystem. Run the foll= owing command to create a new 2GB swap file, start swapping on it, and auto= matically remount the swapfile on reboot:
sudo touch /var/swap
sudo chmod 600 /var/swap
sudo dd if=3D/dev/zero of= =3D/var/swap bs=3D1M count=3D2048
sudo mkswap /var/swap
sudo swapon /va= r/swap
sudo sh -c "echo /var/swap swap swap defaults 0 0 >> /etc/fstab"
You may also want to be able to connect and manage your device rem= otely, in which case you should also install:
sudo apt install openssh-server vim-tiny
There are three ways provided by the EdgeX Foundry to install and run th= e EdgeX services. We provide pre-packaged versions as a snap package (works= on most Linux distros), as docker images, or you can build the EdgeX code = from source and run the executables directly.
The easiest way to get EdgeX Foundry is to install the officially suppor= ted edgexfoundry snap from the snap store.
To install the snap run:
sudo snap install e= dgexfoundry
If you want to install a particular release such as Delhi, you can use:<= /p>
sudo snap install edgexfoundry --channel=3Ddelhi
The snap contains all of the default core-* services, support-*, export-= * and security-* services though by default only the security-* and the cor= e-* services are enabled in the snap. To enable other services (such as exp= ort-distro in this example), use snap set:
sudo snap set edgexfoundry export-distro=3Don
EdgeX Foundry additionally supports running via a docker-compose file fr= om the IoTech Community Developer Kit. To run that docker-compose file, ins= tall docker:
You can easily install docker via a snap:
sudo snap install docker
Or by following other installation methods here.
After that, download the docker-compose file using:
wget -O docker-compose.yml https://raw.githubusercontent.com= /edgexfoundry/demo-grove-pi/master/docker-compose-demo-grove.yml=
Then start the services with docker-compose
docker-compose up -d
Note that running EdgeX from source is not a supported way and not recom= mended for production.
Once you have logged in, it's time to install the system dependencies ne= eded to run EdgeX Foundry. Connect your device to your network and run the = following commands:
sudo apt update
sudo apt upgrade -y
sudo apt install build-essential git wget libzmq3-dev pkg-config
To get the exact same version of Go as used by the EdgeX, install it usi= ng the go snap (note that the project currently uses Go 1.11 for the u= pcoming Edinburgh release, but the Delhi release was originally built with = go 1.10, however go being backwards compatible you should still be able to = build the Delhi release of EdgeX with go 1.11) :
sudo snap install go --channel=3D1.11 --classic
cat >> ~/.bashrc << 'EOF'
export GOPATH=3D$HOME/go
export PATH=3D/usr/local/go/bin:$PATH:$GOPATH/bin
EOF
source ~/.bashrc
mkdir -p $GOPATH/bin
If you are going to build the Delhi release, you also need to install Gl= ide, which is used to manage go dependencies for EdgeX Foundry. Install it = with:
wget https://github.com/Masterminds/glide/releases/download/v0.12.3/glide= -v0.12.3-linux-arm64.tar.gz
tar -C $GOPATH/bin -xvf glide-v0.12.3-linux-arm64.tar.gz --strip 1 linux= -arm64/glide
Now that you have Go and Glide installed, you can tell them to fetch the= EdgeX services and their dependencies:
Then cd into the directory with the EdgeX source code:
cd ~/go/src/github.com/edgexfoundry/edgex-go
There are two steps for building the EdgeX Go microservices, the first t= o prepare the build, and the second to compile it:
make prepare
make build
If you are going to build the Delhi release of EdgeX, install glide as a= bove and then checkout that branch:
git checkout delhi
EdgeX used MongoDB for local data storage. You can install it with:
sudo apt install mongodb-server
and verify that it's running with:
systemctl status mongodb
If it's not running you can start it with:
sudo systemctl start mongodb
Once it's up and running, it needs to be initialized with data for the E= dgeX services, you can do that with the init_mongo.js file= :
wget https://githu= b.com/edgexfoundry/docker-edgex-mongo/raw/master/init_mongo.js
sudo -u mongodb mongo < init_mongo.js
Now that you have the EdgeX go services built and all the dependencies i= nstalled and running, you can run the EdgeX services themselves. The source= code contains a convenient script for doing this, in the same directory as = your can make build above, run:
make run=
This will start all of the EdgeX go services and leave them running unti= l you terminate the process (with Ctrl-C). While it's running you can make = EdgeX API calls to it using the IP address of your RaspberryPi.
In order to keep the EdgeX services running when you're not logged in or= connected to the RaspberryPi, and to have it start automatically when it b= oots, you can create a SystemD service to manage it. Create a new file at <= strong>/etc/systemd/system/edgex.service with the the following co= ntent:
[Unit]
Description=3DEdgeX Foundry Microservices
After=3Dnetwork.target auditd.service
ConditionPathExists=3D/home/pi/go/src/github.com/edgexfoundry/edgex-go/b= in
[Service]
WorkingDirectory=3D/home/pi/go/src/github.com/edgexfoundry/edgex-go/bin<= /p>
ExecStart=3D/home/pi/go/src/github.com/edgexfoundry/edgex-go/bin/edgex-l= aunch.sh
Restart=3Don-failure
RestartPreventExitStatus=3D255
Type=3Dsimple
[Install]
WantedBy=3Dmulti-user.target
Alias=3Dedgex.service
sudo systemctl daemon-reload
sudo systemctl start edgex
sudo systemctl status edgex
Make run=