• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

树莓派安装Thingsboard-gateway遇到的问题

武飞扬头像
工控啥都得会
帮助1

1、下载安装包

wget https://github.com/thingsboard/thingsboard-gateway/releases/latest/download/python3-thingsboard-gateway.deb

2、使用apt安装网关

以软件包形式安装ThingsBoard网关并以守护程序身份运行,请使用以下命令:

sudo apt install ./python3-thingsboard-gateway.deb -y

deb软件包将自动安装必要的库,以使IOT网关正常工作:

  1. 系统库:libffi-dev,libglib2.0-dev,libxml2-dev,libxslt-dev,libssl-dev,zlib1g-dev,python3-dev,python3-pip

  2. Python模块:importlib,importlib-metadata,jsonschema,pymodbus,lxml,jsonpath-rw,paho-mqtt,pyserial,PyYAML,simplejson,pysistent

3、检查网关状态

systemctl status thingsboard-gateway

出现如下信息则表示没有配置网关和ThingsBoard连接:

  1.  
    502 17:09:12 raspberrypi python3[15068]: ""2022-05-02 17:09:12" - |ERROR| - [mqtt_connector.py] - mqtt_connector - load_handlers - 159 - attributeRequests handler is missing some mandatory keys => rejected: {"retain": false, "topicFilt
  2.  
    502 17:09:12 raspberrypi python3[15068]: ""2022-05-02 17:09:12" - |INFO| - [mqtt_connector.py] - mqtt_connector - load_handlers - 167 - Number of accepted attributeRequests handlers: 0"

**在这一步我出现了与安装步骤不同的问题:

  1.  
    root@raspberrypi:/etc/thingsboard-gateway/config# systemctl status thingsboard-gateway
  2.  
    ● thingsboard-gateway.service - ThingsBoard Gateway
  3.  
      Loaded: loaded (/etc/systemd/system/thingsboard-gateway.service; enabled; vendor preset: enabled)
  4.  
      Active: failed (Result: exit-code) since Mon 2022-05-02 16:54:19 CST; 1min 12s ago
  5.  
    Process: 13379 ExecStart=/usr/bin/python3 -c from thingsboard_gateway.tb_gateway import daemon; daemon() (code=exi
  6.  
    Main PID: 13379 (code=exited, status=1/FAILURE)
  7.  
  8.  
    502 16:54:19 raspberrypi systemd[1]: thingsboard-gateway.service: Service RestartSec=100ms expired, scheduling re
  9.  
    502 16:54:19 raspberrypi systemd[1]: thingsboard-gateway.service: Scheduled restart job, restart counter is at 5.
  10.  
    502 16:54:19 raspberrypi systemd[1]: Stopped ThingsBoard Gateway.
  11.  
    502 16:54:19 raspberrypi systemd[1]: thingsboard-gateway.service: Start request repeated too quickly.
  12.  
    502 16:54:19 raspberrypi systemd[1]: thingsboard-gateway.service: Failed with result 'exit-code'.
  13.  
    502 16:54:19 raspberrypi systemd[1]: Failed to start ThingsBoard Gateway.
  14.  
    lines 1-12/12 (END)...skipping...

thingsboard-gateway重启后,状态总是失败,解决办法如下:

1、查看thingsboard-gateway日志

journalctl -u thingsboard-gateway.service

journalctl 是查看日志命令,-u则是指定单元。上述命令查看thingsboard-gateway单元日志

日志中发现

  1.  
    502 16:17:24 raspberrypi python3[1675]: Traceback (most recent call last):
  2.  
    502 16:17:24 raspberrypi python3[1675]:   File "<string>", line 1, in <module>
  3.  
    502 16:17:24 raspberrypi python3[1675]:   File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-3.0
  4.  
    5月 02 16:17:24 raspberrypi python3[1675]:     from thingsboard_gateway.gateway.tb_gateway_service import TBGatew
  5.  
    5月 02 16:17:24 raspberrypi python3[1675]:   File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-3.0
  6.  
    502 16:17:24 raspberrypi python3[1675]:     from thingsboard_gateway.gateway.grpc_service.grpc_connector impor
  7.  
    502 16:17:24 raspberrypi python3[1675]:   File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-3.0
  8.  
    5月 02 16:17:24 raspberrypi python3[1675]:     from thingsboard_gateway.gateway.grpc_service.tb_grpc_manager impo
  9.  
    5月 02 16:17:24 raspberrypi python3[1675]:   File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-3.0
  10.  
    502 16:17:24 raspberrypi python3[1675]:     from thingsboard_gateway.gateway.grpc_service.grpc_downlink_conver
  11.  
    502 16:17:24 raspberrypi python3[1675]:   File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-3.0
  12.  
    5月 02 16:17:24 raspberrypi python3[1675]:     from thingsboard_gateway.gateway.proto.messages_pb2 import *
  13.  
    5月 02 16:17:24 raspberrypi python3[1675]:   File "/usr/local/lib/python3.7/dist-packages/thingsboard_gateway-3.0
  14.  
    502 16:17:24 raspberrypi python3[1675]:     create_key=_descriptor._internal_create_key,
  15.  
    502 16:17:24 raspberrypi python3[1675]: AttributeError: module '谷歌.protobuf.descriptor' has no attribute '
学新通

到最后一步报错,网上查询解决办法,是要将protoc和porobuf版本一致,但是用protoc --version无法查看版本。

使用以下命令:

pip install --upgrade protobuf

更新protobuf后,重启thingsboard-gateway

thingsboard-gateway正常

启动如下:

  1.  
    root@raspberrypi:/etc/thingsboard-gateway/config# systemctl status thingsboard-gateway
  2.  
    ● thingsboard-gateway.service - ThingsBoard Gateway
  3.  
      Loaded: loaded (/etc/systemd/system/thingsboard-gateway.service; enabled; vendor preset: enabled)
  4.  
      Active: active (running) since Mon 2022-05-02 17:08:38 CST; 8s ago
  5.  
    Main PID: 15068 (python3)
  6.  
      Tasks: 8 (limit: 4915)
  7.  
      CGroup: /system.slice/thingsboard-gateway.service
  8.  
              ├─15068 /usr/bin/python3 -c from thingsboard_gateway.tb_gateway import daemon; daemon()
  9.  
              └─15080 /usr/bin/python3 -m pip install pymodbus>=2.3.0 --user

因为我使用CH340,USB转串口工具,后面tb-gateway还会有另外一个报错,后面的文章再说

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfjajhi
系列文章
更多 icon
同类精品
更多 icon
继续加载