edgeX 在树莓派上启动
edgeX
听说R版本要起名了. 作为一个山东人, 就推荐了日照. 虽然不是第一个推荐的. 最后还是选了日照.
edgeX的架构
简单介绍一下为啥选这个平台. 朋友推荐. 我也自己看订阅号的分享, 再选一个mainflux做对比.
官网介绍 https://www.edgexfoundry.org/
golang肯定上边缘的首选语言. 无论选哪个肯定都是golang技术栈的.
左边是安全. 右面是管理. 这两个方向可以暂时不细看.
从上到下有四层
- 应用服务
- 支持服务
规则, 通知, 报警, 调度, 其他 - 核心服务
核心数据, 命令? 元数据, 配置和注册 - 设备服务
各种设备通信协议. 虚拟设备
这四个层次, 从上到下, 为啥是这个样子, 需要慢慢体会. 因为这些分层决定了代码的组织方式.
作为用户, 可能最先关注应用层, 至少在现有的代码上把应用做起来. 不过有更优先的,就上在板卡上把服务跑起来. 为啥不在电脑上跑? 大概率可行. 但是我的电脑连docker都没装成功, 系统太新了. 我选择树莓派, 一步到位吧.
你可以这么想, 把这个架构拆倒电脑上一半, 另一半在树莓派上.那不就做到云端一体化了吗?
树莓派上的docker compose
前文已经装好了docker 树莓派5 初始化docker
快速开始 EdgeX https://docs.edgexfoundry.org/2.1/getting-started/quick-start/
Running EdgeX –>
curl https://raw.githubusercontent.com/edgexfoundry/edgex-compose/jakarta/docker-compose-no-secty-arm64.yml -o docker-compose.yml; docker-compose up -d
备注: 新版本
docker compose up -d
我安装的版本 docker compose已经是个插件了. 名字中间不带横杠了.
icecut@raspberrypi:~/work/edgex $ docker compose up -d
[+] Running 72/22
✔ app-service-rules 5 layers [⣿⣿⣿⣿⣿] 0B/0B Pulled 16.0s
✔ device-rest 4 layers [⣿⣿⣿⣿] 0B/0B Pulled 45.0s
✔ data 4 layers [⣿⣿⣿⣿] 0B/0B Pulled 26.4s
✔ command 5 layers [⣿⣿⣿⣿⣿] 0B/0B Pulled 9.7s
✔ device-virtual 5 layers [⣿⣿⣿⣿⣿] 0B/0B Pulled 60.2s
✔ scheduler 3 layers [⣿⣿⣿] 0B/0B Pulled 60.1s
✔ metadata 3 layers [⣿⣿⣿] 0B/0B Pulled 18.9s
✔ notifications 3 layers [⣿⣿⣿] 0B/0B Pulled 60.0s
✔ rulesengine 6 layers [⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 71.4s
✔ system 11 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 43.9s
✔ consul 5 layers [⣿⣿⣿⣿⣿] 0B/0B Pulled 79.2s
✔ database 6 layers [⣿⣿⣿⣿⣿⣿] 0B/0B Pulled 65.1s
[+] Running 0/0
⠋ Network edgex_edgex-network Creating 0.0s
WARN[0079] mount of type `volume` should not define `bind` option
[+] Running 5/7t of type `volume` should not define `bind` option
[+] Running 17/17edgex-network Created 0.1s
✔ Network edgex_edgex-network Created 0.1s
✔ Volume "edgex_db-data" Created 0.0s
✔ Volume "edgex_consul-config" Created 0.0s
✔ Volume "edgex_consul-data" Created 0.0s
✔ Volume "edgex_kuiper-data" Created 0.0s
✔ Container edgex-redis Started 9.4s
✔ Container edgex-core-consul Started 9.4s
✔ Container edgex-support-notifications Started 0.3s
✔ Container edgex-kuiper Started 0.4s
✔ Container edgex-support-scheduler Started 0.3s
✔ Container edgex-core-metadata Started 0.2s
✔ Container edgex-core-data Started 0.2s
✔ Container edgex-core-command Started 0.2s
✔ Container edgex-app-rules-engine Started 0.2s
✔ Container edgex-device-rest Started 0.2s
✔ Container edgex-device-virtual Started 0.2s
✔ Container edgex-sys-mgmt-agent Started 0.2s
下载正常, 启动也正常. 纯软件的项目, 还是比较稳定的. 但是也有一个不兼容, 对于完全docker不熟悉的人,有点坑.
网络配置
虽然树莓派上有显示器, 可以localhost访问. 对于学习来说. 不如直接远程访问. docker-compose.yaml里面的端口都是绑定在127.0.0.1的. 我把所有ports配置的127.0.0.1:给删掉了.
直接restart没有生效. stop了所有容器, 然后重启可以看到 以前是
icecut@raspberrypi:~/work/edgex $ netstat -an | grep tcp
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59861 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59860 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59900 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59882 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59881 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59880 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59720 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59701 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:8500 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:59986 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5563 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:58890 0.0.0.0:* LISTEN
tcp 0 1 192.168.50.123:46312 142.251.43.10:443 SYN_SENT
现在是
icecut@raspberrypi:~/work/edgex $ netstat -an | grep tcp
tcp 0 0 0.0.0.0:5563 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:58890 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59861 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59860 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59900 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59882 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59881 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59880 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59701 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8500 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59720 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:59986 0.0.0.0:* LISTEN
局域网访问正常了.
icecut@jiangyiundeMBP2 ~ % curl http://192.168.50.123:59880/api/v2/ping
{"apiVersion":"v2","timestamp":"Thu Dec 7 04:56:22 UTC 2023"}
到此为止,基本验证环境就跑起来了. 后续可以用源代码自己构建服务添加或者替换了.
当然, 一个完整的应用还没跑起来. 我看一下文档看看下一步如何搞.