樹莓派使用Docker部署EdgeX(jakarta版本)

HelliWrold1發表於2022-06-03

使用Docker部署EdgeX

老師安排我搞邊緣計算,搞了很久都沒能明白邊緣計算是什麼,甚至對其興趣不大,前一陣弄好了lorawan閘道器,該做閘道器內部的邊緣計算了,發現自己已經慢慢地學了進去,總是想要把這個東西搞完善。我都要著手準備考研了,居然還在這裡搞這個,執念太深。後繼無人啊,自己的孩子總怕沒人好好養。
這幾天查閱文獻的時候發現了這個邊緣計算框架,這個看起來不是很容易上手,國內的EMQX也在搞相關的東西,他那一套是Neutron+NanoMQ+eKuiper+EMQX,不過感覺會變成收費產品,於是還是瞭解瞭解這個從2017年就已經有了的開源專案EdgeX Foundry。
弄了三天,終於弄好了。這幾天看了幾個舊版的EdgeX相關部落格,有的缺少一些docker-compose安裝的內容,有的已經不再適用新版本,使用curl命令快速體驗EdgeX的方法總是會受到網路的限制,經常433拒絕連線。於是選擇了官方文件中的“Getting Started with Docker”

多說無益,正文開始

硬體環境:Raspberry 4B
軟體環境:Linux raspberrypi 5.10.17-v8+ #1414 SMP PREEMPT Fri Apr 30 13:23:25 BST 2021 aarch64 GNU/Linux
系統映象在下文的相關資料中,如果不會燒寫映象,可以找一找相關部落格,燒寫器和映象在下文中已經一併給出

安裝docker&docker-compose

安裝docker-ce

新增GPG金鑰

curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/raspbian/gpg | sudo apt-key add -

獲取安裝包

wget https://download.docker.com/linux/debian/dists/buster/pool/edge/arm64/containerd.io_1.3.7-1_arm64.deb
wget https://download.docker.com/linux/debian/dists/buster/pool/edge/arm64/docker-ce-cli_19.03.13~3-0~debian-buster_arm64.deb
wget https://download.docker.com/linux/debian/dists/buster/pool/edge/arm64/docker-ce_19.03.13~3-0~debian-buster_arm64.deb

設定docker映象

sudo nano /etc/docker/daemon.json

填入內容

{
        "registry-mirrors": ["http://hub-mirror.c.163.com"]
}

過載

sudo systemctl daemon-reload
sudo systemctl restart docker

驗證安裝

docker -v
Docker version 19.03.13, build 4484c46

安裝docker-compose

sudo apt install python3-pip # 安裝pip3
sudo apt install libffi-dev # 安裝libffi
pip3 install docker-compose # 安裝docker-compose

為安裝的docker-compose新增環境變數

nano ~/.zshrc

填入

export PATH="${PATH}:/home/pi/.local/bin"

載入

source ~/.zshrc

驗證安裝

docker-compose -v
docker-compose version 1.29.2, build unknown

部署EdgeX

克隆edgexfoundry/edgex-compose

git clone https://github.com/edgexfoundry/edgex-compose.git

如果git clone時出現超時和斷開連線的情況,可以看下文相關資料中的Github克隆加速

切換分支

cd edgex-compose/
git checkout jakarta

生成docker-compose.yml

cd compose-builder/
make gen no-secty arm64 ds-mqtt asc-mqtt asc-ex-mqtt mqtt-broker mqtt-bus

拉取映象

docker-compose pull

出現Permission Denied

sudo chmod 777 /var/run/docker.sock

啟動Edgex

docker-compose up -d # -d可選,選擇是否後臺執行(無執行資訊)

檢視是否啟動

docker-compose ps

訪問EdgeX Console進入EdgeXUI介面
image

關閉Edgex

docker-compose down

Question

本人遇到了幾個問題,還望可以得到解答

1.啟用了EdgeX的安全模式後,不知道如何獲取EdgeX UI介面的token

按照官方文件的操作會報錯
有的時候時container衝突,有的時本地ip172.23.0.5:8443拒絕連線,最後的錯誤是container"/edgex-security-bootstrapper" Conflict,也就是容器衝突,可是用docker ps和docker-compose ps也看不到衝突的那個容器的id

docker-compose -p edgex -f docker-compose.yml run --rm -v `pwd`:/host:ro -u "$UID" --entrypoint "/edgex/secrets-config" proxy-setup -- proxy adduser --token-type jwt --id "$ID" --algorithm ES256 --public_key /host/ec256.pub --user _SOME_USERNAME_ --jwt "$KONGJWT"
Creating network "edgex_edgex-network" with driver "bridge"
Creating volume "edgex_consul-acl-token" with default driver
Creating volume "edgex_consul-config" with default driver
Creating volume "edgex_consul-data" with default driver
Creating volume "edgex_db-data" with default driver
Creating volume "edgex_edgex-init" with default driver
Creating volume "edgex_kong" with default driver
Creating volume "edgex_kuiper-data" with default driver
Creating volume "edgex_postgres-config" with default driver
Creating volume "edgex_postgres-data" with default driver
Creating volume "edgex_redis-config" with default driver
Creating volume "edgex_vault-config" with default driver
Creating volume "edgex_vault-file" with default driver
Creating volume "edgex_vault-logs" with default driver
Creating edgex-security-bootstrapper ... error

ERROR: for edgex-security-bootstrapper  Cannot create container for service security-bootstrapper: Conflict. The container name "/edgex-security-bootstrapper" is already in use by container "aec25a2ae279686bc4a7e5518902d84b30af12e7fa547e8d4e74201c199fd439". You have to remove (or rename) that container to be able to reuse that name.

ERROR: for security-bootstrapper  Cannot create container for service security-bootstrapper: Conflict. The container name "/edgex-security-bootstrapper" is already in use by container "aec25a2ae279686bc4a7e5518902d84b30af12e7fa547e8d4e74201c199fd439". You have to remove (or rename) that container to be able to reuse that name.
ERROR: Encountered errors while bringing up the project.

docker-compose -p edgex -f docker-compose.yml run --rm -v `pwd`:/host:ro -u "$UID" --entrypoint "/edgex/secrets-config" proxy-setup -- proxy adduser --token-type jwt --id "$ID" --algorithm ES256 --public_key /host/ec256.pub --user _SOME_USERNAME_ --jwt "$KONGJWT"
Creating edgex_proxy-setup_run ... done
level=ERROR ts=2022-06-03T07:09:17.874323866Z app=secrets-config source=bootstraphandler.go:76 msg="Failed to send new consumer request _SOME_USERNAME_: Post \"https://edgex-kong:8443/admin/consumers\": dial tcp 172.23.0.5:8443: connect: connection refused"
ERROR: 2

2.如何配置連線真實的MQTT南向裝置?

3.為什麼使用64位raspbian之後,它的瀏覽器只要是開啟一個網頁就會卡頓?其他的命令列一類的東西都不卡

參考

樹莓派安裝docker-compose

EdgeX 樹莓派實踐部署

EdgeX Foundry Documentation-Getting Started with Docker

https://github.com/edgexfoundry/edgex-compose/blob/jakarta/compose-builder/README.md

docker-compose up 時 Permission denied

相關資料

樹莓派映象燒錄器

樹莓派4B64位系統映象

docker刪除所有容器映象

如何安裝uuidgen

安裝uuidgen

sudo apt-get install uuid-runtime

EdgeX啟用安全模式(make gen 時不新增no-secty選項)時,可能會用到,至今不會使用EdgeX UI介面的Token生成

據說是用來生成UI介面token的方法

docker-compose多檔案
Github克隆加速

最後

如果本文章有任何錯誤還請指正,最後幾個問題,希望可以得到高人指點,謝謝!

相關文章