体验“边云协同”【我的IoT端边云体验】

举报
千江有水千江月 发表于 2022/10/31 00:00:06 2022/10/31
【摘要】 边云协同将云端的应用,通过边云通道,部署在边缘节点上,并实现在云端远程管理应用,保障部署在边缘的应用能够正常运行,并通过与云端的连线,将业务执行结果在云端呈现。iot边缘的优势:就近接入、本地自治和低时延。在实际项目中,边缘计算是一定要有的,因为各方面的原因,比如网络波动和网络带宽等。本地大存储和本地高性能计算的存在,都会对数据进行预处理,将预处理后得到的高价值数据再上传至云端,以此来分担...

边云协同

将云端的应用,通过边云通道,部署在边缘节点上,并实现在云端远程管理应用,保障部署在边缘的应用能够正常运行,并通过与云端的连线,将业务执行结果在云端呈现。

iot边缘的优势:就近接入、本地自治和低时延。在实际项目中,边缘计算是一定要有的,因为各方面的原因,比如网络波动和网络带宽等。本地大存储和本地高性能计算的存在,都会对数据进行预处理,将预处理后得到的高价值数据再上传至云端,以此来分担计算任务、减轻中心压力。

在博文体验征文|没有设备也能体验“边云协同”中有一张非常好的架构图,我贴在这里,作为学习参考。

iot-edge-c-1.png

没有设备也能体验“边云协同”

iot edge - 开通服务

iot-edge-c-2.png

iot-edge-c-3.png

iot edge - 注册节点

iot-edge-c-4.png

iot-edge-c-5.png

  • 此处要按时间限制,复制并完成指定的操作指令(30分钟有效,过了30分钟要重新复制命令)

iot-edge-c-6.png

购买ecs,配置系统和网络

根据硬件规格和刚刚选择的支持架构 x86_64购买对应的ecs。

iot-edge-c-7.png

iot-edge-c-8.png

iot-edge-c-9.png

iot-edge-c-10.png

安装docker

  • 远程登录

iot-edge-c-11.png

[root@ecs-1db2 etc]# uname -r
3.10.0-1160.53.1.el7.x86_64
[root@ecs-1db2 etc]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
  • 此处要注意docker的版本,iot edge要检查docker版本
[root@ecs-1db2 ~]# yum install yum-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
updates/7/x86_64/primary_db                                                   |  17 MB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
--> Running transaction check
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
 Package                    Arch               Version                        Repository        Size
=====================================================================================================
Installing:
 yum-utils                  noarch             1.1.31-54.el7_8                base             122 k
Installing for dependencies:
 python-chardet             noarch             2.2.1-3.el7                    base             227 k
 python-kitchen             noarch             1.1.1-5.el7                    base             267 k

Transaction Summary
=====================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 616 k
Installed size: 2.8 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): python-chardet-2.2.1-3.el7.noarch.rpm                                  | 227 kB  00:00:00     
(2/3): yum-utils-1.1.31-54.el7_8.noarch.rpm                                   | 122 kB  00:00:00     
(3/3): python-kitchen-1.1.1-5.el7.noarch.rpm                                  | 267 kB  00:00:00     
-----------------------------------------------------------------------------------------------------
Total                                                                2.9 MB/s | 616 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : python-chardet-2.2.1-3.el7.noarch                                                 1/3 
  Installing : python-kitchen-1.1.1-5.el7.noarch                                                 2/3 
  Installing : yum-utils-1.1.31-54.el7_8.noarch                                                  3/3 
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                                                 1/3 
  Verifying  : yum-utils-1.1.31-54.el7_8.noarch                                                  2/3 
  Verifying  : python-chardet-2.2.1-3.el7.noarch                                                 3/3 

Installed:
  yum-utils.noarch 0:1.1.31-54.el7_8                                                                 

Dependency Installed:
  python-chardet.noarch 0:2.2.1-3.el7               python-kitchen.noarch 0:1.1.1-5.el7              

Complete!
[root@ecs-1db2 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@ecs-1db2 ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base                                                                                                                                                         | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                                                             | 3.5 kB  00:00:00     
epel                                                                                                                                                         | 4.7 kB  00:00:00     
extras                                                                                                                                                       | 2.9 kB  00:00:00     
updates                                                                                                                                                      | 2.9 kB  00:00:00     
(1/13): base/7/x86_64/filelists_db                                                                                                                           | 7.2 MB  00:00:00     
(2/13): docker-ce-stable/7/x86_64/filelists_db                                                                                                               |  36 kB  00:00:00     
(3/13): docker-ce-stable/7/x86_64/updateinfo                                                                                                                 |   55 B  00:00:00     
(4/13): base/7/x86_64/other_db                                                                                                                               | 2.6 MB  00:00:00     
(5/13): epel/x86_64/filelists_db                                                                                                                             |  12 MB  00:00:00     
(6/13): epel/x86_64/other_db                                                                                                                                 | 3.4 MB  00:00:00     
(7/13): docker-ce-stable/7/x86_64/primary_db                                                                                                                 |  87 kB  00:00:00     
(8/13): epel/x86_64/prestodelta                                                                                                                              | 2.8 kB  00:00:00     
(9/13): extras/7/x86_64/other_db                                                                                                                             | 149 kB  00:00:00     
(10/13): updates/7/x86_64/other_db                                                                                                                           | 1.2 MB  00:00:00     
(11/13): docker-ce-stable/7/x86_64/other_db                                                                                                                  | 127 kB  00:00:00     
(12/13): updates/7/x86_64/filelists_db                                                                                                                       | 9.6 MB  00:00:00     
(13/13): extras/7/x86_64/filelists_db                                                                                                                        | 276 kB  00:00:00     
Metadata Cache Created
                                                           extras
[root@ecs-1db2 ~]# yum list docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
docker-ce.x86_64      
[root@ecs-1db2 ~]# yum install docker-ce
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies

......

Complete!
[root@ecs-1db2 ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.7
 Git commit:        baeda1f
 Built:             Tue Oct 25 18:04:24 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@ecs-1db2 ~]# systemctl start docker
[root@ecs-1db2 ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-10-30 22:47:25 CST; 9s ago
     Docs: https://docs.docker.com
 Main PID: 8201 (dockerd)
    Tasks: 8
   Memory: 26.6M
   CGroup: /system.slice/docker.service
           └─8201 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.431856597+08:00" level=info msg="scheme \"unix\" not registered, fallback to default scheme" module=grpc
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.431869271+08:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/...module=grpc
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.431877384+08:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.449846179+08:00" level=info msg="Loading containers: start."
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.542427311+08:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/...IP address"
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.578040031+08:00" level=info msg="Loading containers: done."
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.593529816+08:00" level=info msg="Docker daemon" commit=3056208 graphdriver(s)=overlay2 version=20.10.21
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.593593427+08:00" level=info msg="Daemon has completed initialization"
Oct 30 22:47:25 ecs-1db2 systemd[1]: Started Docker Application Container Engine.
Oct 30 22:47:25 ecs-1db2 dockerd[8201]: time="2022-10-30T22:47:25.617186065+08:00" level=info msg="API listen on /var/run/docker.sock"
Hint: Some lines were ellipsized, use -l to show in full.
[root@ecs-1db2 ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.21
 API version:       1.41
 Go version:        go1.18.7
 Git commit:        baeda1f
 Built:             Tue Oct 25 18:04:24 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.21
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.7
  Git commit:       3056208
  Built:            Tue Oct 25 18:02:38 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.9
  GitCommit:        1c90a442489720eec95342e1789ee8a5e1b9536f
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

执行iot edge的安装指令

  • 可以在此处再次复制安装命令

iot-edge-c-12.png

  • 输入安装命令后,截取结果末尾显示为
......
2022-10-30T22:49:33,743777 | INFO | reportModuleStatus | 131 | reportModuleStatus, modulesInfo:ModuleStatusInfoList[ host_tag:DEFAULT, deploy_id:1667141356138, modules:[ModuleStatusInfo[ module_id:sys_edge_agent, app_id:$edge_agent, app_version:1-1-14-standard-x86, container_state:RUNNING, liveness_state:(zero), update_time:1667141356136,]],]
2022-10-30T22:49:33,817430 | INFO | install | 432 | install edge finish.
2022-10-30T22:49:33,817541 | INFO | stop | 483 | edgeInstaller stop.
/root
[root@ecs-1db2 ~]# 
  • 设备在线,安装成功!

iot-edge-c-13.png

SWR容器镜像服、创建组织与登录指令

[root@ecs-1db2 ~]# docker pull swr.cn-north-4.myhuaweicloud.com/huawei-iot-edge/edgerule:1.1.0001.20200428202651.x86
1.1.0001.20200428202651.x86: Pulling from huawei-iot-edge/edgerule
b191b8aab1bf: Already exists 
9f734839da19: Pull complete 
55904ee0fa41: Pull complete 
c922edcb579b: Pull complete 
bb8e1d757a13: Pull complete 
f632dc244831: Pull complete 
Digest: sha256:42528397dbf966fab9b7682a51b5b1534bf1e13d3a439e1a4ecf9c4dce6713c7
Status: Downloaded newer image for swr.cn-north-4.myhuaweicloud.com/huawei-iot-edge/edgerule:1.1.0001.20200428202651.x86
swr.cn-north-4.myhuaweicloud.com/huawei-iot-edge/edgerule:1.1.0001.20200428202651.x86

iot-edge-c-14.png

  • 创建组织iot_edge_demo

iot-edge-c-15.png

  • 查看登录指令

iot-edge-c-16.png

[root@ecs-1db2 ~]# docker login -u XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

将镜像改名并上传到SWR

注意手册中的这一段,要把组织名称改成自己设置的。

// 1、为本地镜像打标签,格式为docker tag [镜像名称:版本名称] [镜像仓库地址]/[组织名称]/[镜像名称:版本名称]
// 2、上传镜像到SWR,格式为docker push [镜像仓库地址]/[组织名称]/[镜像名称:版本名称]
  • push了多次才完全成功
[root@ecs-1db2 ~]# docker tag swr.cn-north-4.myhuaweicloud.com/huawei-iot-edge/edgerule:1.1.0001.20200428202651.x86 swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app:1.0.0

[root@ecs-1db2 ~]# docker push swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app:1.0.0
The push refers to repository [swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app]
783aa7baaf86: Pushed 
4b9d1d1d2465: Pushing [==================================================>]  54.23MB
8e0f12b3ecba: Pushed 
7e2c8af8fc71: Retrying in 2 seconds 
4f950bfe3f69: Pushed 
18173aa2d3c5: Pushed 
read tcp 192.168.0.145:52660->100.125.40.98:443: read: connection reset by peer
[root@ecs-1db2 ~]# docker push swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app:1.0.0
The push refers to repository [swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app]
783aa7baaf86: Layer already exists 
4b9d1d1d2465: Pushed 
8e0f12b3ecba: Layer already exists 
7e2c8af8fc71: Pushed 
4f950bfe3f69: Layer already exists 
18173aa2d3c5: Layer already exists 
1.0.0: digest: sha256:42528397dbf966fab9b7682a51b5b1534bf1e13d3a439e1a4ecf9c4dce6713c7 size: 1588
[root@ecs-1db2 ~]# docker push swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app:1.0.0
The push refers to repository [swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app]
783aa7baaf86: Layer already exists 
4b9d1d1d2465: Layer already exists 
8e0f12b3ecba: Layer already exists 
7e2c8af8fc71: Layer already exists 
4f950bfe3f69: Layer already exists 
18173aa2d3c5: Layer already exists 
1.0.0: digest: sha256:42528397dbf966fab9b7682a51b5b1534bf1e13d3a439e1a4ecf9c4dce6713c7 size: 1588

查看SWR中的镜像并设置权限

iot-edge-c-17.png

iot-edge-c-18.png

iot-edge-c-19.png

iot边缘 - 应用管理 - 添加应用

iot-edge-c-20.png

iot-edge-c-21.png

iot-edge-c-22.png

iot-edge-c-23.png

iot-edge-c-24.png

  • 这里有一步发布应用!切记!

iot-edge-c-26.png

将应用部署到边缘节点(iot边缘 - 边缘节点)

iot-edge-c-25.png

iot-edge-c-27.png

iot-edge-c-28.png

  • 查看docker运行状态

[root@ecs-1db2 ~]# docker ps
CONTAINER ID   IMAGE                                                                                      COMMAND                  CREATED          STATUS          PORTS                                                      NAMES
bc3495c3fc6e   swr.cn-north-4.myhuaweicloud.com/iot_edge_demo/app:1.0.0                                   "/opt/iot/edge_rule/…"   57 seconds ago   Up 57 seconds                                                              user-app-demo
92f7cb3e84db   swr.cn-north-4.myhuaweicloud.com/huawei-iot-edge/edgehub-go:2022.0816.1140.57              "/opt/iot/edge_hub/s…"   31 minutes ago   Up 31 minutes   0.0.0.0:7882-7883->7882-7883/tcp, 0.0.0.0:8943->8943/tcp   sys-edge-hub
924a7ea81003   swr.cn-north-4.myhuaweicloud.com/huawei-iot-edge/edgeagent_x86_64:0.3.072.20220901191300   "/bin/sh -c 'sh /opt…"   32 minutes ago   Up 32 minutes                                                              sys-edge-agent
[root@ecs-1db2 ~]# 

添加边缘设备-自定义模型

iot-edge-c-29.png

直接导入现有的模型压缩包(自己之前做的水泵物模型,现在直接用即可)

iot-edge-c-30.png

添加边缘设备

iot-edge-c-31.png

iot-edge-c-32.png

iot-edge-c-33.png

iot-edge-c-34.png

后续

之后呢,可以使用Huaweicloud IoTDA Mqtt ClientId Generator 和 MQTT.fx 软件进行设备模拟。具体步骤可以参考 如何在边缘节点下添加设备

提醒一句:如果资源不用的话,要记得释放。

感想

整个流程是比较流畅的,给写文档的同学点个赞,文档写的很好。多个产品相互打通,实现了中心集控+边缘中控的架构。

感谢iot小助手提醒我有这个活动,我才能赶上征文的末班车,Thanks♪(・ω・)ノ。

参考资料

附加

【我的IoT端边云体验】有奖征文火热进行中:https://bbs.huaweicloud.com/blogs/378687

此外,在(https://bbs.huaweicloud.com/activity/suggestion.html)提出您的宝贵建议,标题以【云驻计划-定向征文】开头,还有机会赢取额外奖励。

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。