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

使用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界面
树莓派使用Docker部署EdgeX(jakarta版本)

关闭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克隆加速

最后

如果本文章有任何错误还请指正,最后几个问题,希望可以得到高人指点,谢谢!

发表评论

相关文章

当前内容话题