产品定价 立即试用
PE边缘
文档 > 集成 > 远程集成
入门
安装 架构 API 常见问题
目录

远程集成

Introduction

It is possible to run any ThingsBoard Integration remotely from the main ThingsBoard Edge instance. This guide provides step-by-step instructions for launching ThingsBoard integration remotely.

We’ll demonstrate how to set up a remote HTTP integration to push data to ThingsBoard Edge.

For more general details, see the deployment options.

Prerequisites

  • A running ThingsBoard Edge instance, already connected to the Server, with access as a Tenant administrator.

ThingsBoard Server configuration steps

To create Converter and Integration templates, log in to the Cloud instance as Tenant administrator.

Before creating the Integration template, create an Uplink converter template in the Converters templates section.

The uplink data converter is needed to convert the incoming data from the device into the format required for display on ThingsBoard Edge.

  • Log in to the Cloud and go to the Edge management > Converter templates section. To create a Converter template, click the “Add data converter” button (the + icon) and select the “Create new converter” option.
  • In the “Add data converter” pop-up window:
    • Name: Enter the name of the data converter.
    • Type: Select the “Uplink” converter type from the drop-down menu.
    • To view the events, enable Debug mode.
    • function Decoder: Enter a script to parse and transform data.
    • Click the “Add” button.
文档信息图标

Debug 模式在开发与故障排查中非常有用,但在生产环境中保持启用会显著增加数据库存储需求,因为所有调试数据均会存入数据库。

强烈建议在调试完成后 禁用 Debug 模式

Example for the Uplink converter:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Decode an uplink message from a buffer
// payload - array of bytes
// metadata - key/value object
/** Decoder **/
// decode payload to string
// var payloadStr = decodeToString(payload);
// decode payload to JSON
var data = decodeToJson(payload);
var deviceName = data.deviceName;
// Result object with device attributes/telemetry data
var result = {
   deviceName: deviceName,
   deviceType: 'default',
   attributes: {
       model: data.model,
   },
   telemetry: {
       temperature: data.temperature
   }
};
/** Helper functions **/
function decodeToString(payload) {
   return String.fromCharCode.apply(String, payload);
}
function decodeToJson(payload) {
   // covert payload to string.
   var str = decodeToString(payload);
   // parse string to JSON
   var data = JSON.parse(str);
   return data;
}
return result;

Step 2. Create Remote Integration

Once the Uplink converter template is created, you can proceed to create the Integration: Go to the Edge management > Integration templates section, click the “Add new integration” button (the + icon) and select the “Create new integration” option.

  • In the “Add integration” pop-up window and fill out the “Basic settings” block:
    • Integration type: Select the “HTTP” integration type from the drop-down menu.
    • Name: Enter the name of the integration.
  • In the “Uplink data converter” block:
    • Select the “Select existing” tab.
    • Uplink data converter: Select the uplink data converter from the drop-down menu.
  • The “Downlink data converter” block is optional and can be skipped.
    • In the “Connection” block:
    • Base URL: Set ${{remoteHttpIntegrationUrl}} as the base URL.
    • Execute remotely: Toggle this option to enable remote execution of the integration.
  • To save the Integration, click the Add button.

Step 3. Save Remote Integration credentials.

Later during the Remote integration installation steps, we’ll use integration credentials.

  • To view and copy the credentials, go to the Edge management > Integration templates section and click the integration.
  • On the “Integration details” page, in the “Execute remotely” block copy the Integration key and Secret by clicking the corresponding button.

Step 4. Assign Integration to Edge.

Once the converter and integration templates are created, we can assign the Integration template to the Edge.

Since we are using the ${{remoteHttpIntegrationUrl}} placeholder in the integration configuration, we must first add the remoteHttpIntegrationUrl attribute to the Edge. Provide the IP address and port of your remote HTTP integration as the remoteHttpIntegrationUrl attribute. By default, the HTTP remote integration uses port 8082.

We will use the same port in the demo, and the IP address will be set as the IP of the machine where the remote integration service will be launched. Once the attribute is added, we are ready to assign the integration and verify that it has been added.

  • Go to the Edge management > Instances section and click on the corresponding Edge instance.
  • On the Edge details page, select the Attributes tab and add click the "Add" button to add a new attribute.
  • In the "Add attribute" pop-up window, enter the remoteHttpIntegrationUrl attribute. Set http://IP:port as the remote URL for your HTTP integration and click the Add button.
  • Once you added the new attribute, close the Edge details page and stay on the Instances section.
  • To assign the integration to the Edge, click the "Manage edge integrations" button.
  • Click the Assign to edge button.
  • In the "Assign Integrations To Edge" pop-up window, select the target integration from the "Entity list" drop-down menu and click the Assign button.
  • Open the Edge instance and go to the Integrations center > Integrations section. Click on HTTP Demo Remote integration to check that placeholder is substituted with the value of the attribute.

Remote integration installation steps

Choose your platform and install

You can install the ThingsBoard integration via Docker, Debian or RPM packages. Please use one of the following steps.

要通过 Docker 运行集成,请确保已 安装 Docker CE

Select the integration to install

拉取镜像,运行命令:

1
docker pull thingsboard/tb-pe-http-integration:4.3.0.1PE

为集成日志创建卷(799 为非root ThingsBoard Docker 用户的用户ID):

1
mkdir -p ~/.tb-pe-http-integration-logs && sudo chown -R 799:799 ~/.tb-pe-http-integration-logs

使用以下命令运行集成:

1
2
3
4
docker run -it -v ~/.tb-pe-http-integration-logs:/var/log/tb-http-integration \
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" \
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" \
--name my-tb-pe-http-integration --network edge_docker_default --restart always thingsboard/tb-pe-http-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口。由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际 integration routing key
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际 integration secret
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v ~/.tb-pe-http-integration-logs:/var/log/tb-http-integration: 将主机的 ~/.tb-pe-http-integration-logs 目录挂载到 ThingsBoard 远程集成日志目录。
  • –name my-tb-pe-http-integration: 此容器的本地名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard Integration。
  • thingsboard/tb-pe-http-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开位于 ~/.tb-pe-http-integration-logs 的日志。 您应能看到包含从Server接收的最新集成配置的 INFO 级别日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新附加到终端(查看 ThingsBoard 远程集成日志),运行:

1
docker attach tb-pe-http-integration

停止容器:

1
docker stop tb-pe-http-integration

启动容器:

1
docker start tb-pe-http-integration

执行以下命令拉取镜像:

1
docker pull thingsboard/tb-pe-mqtt-integration:4.3.0.1PE

创建集成日志卷(799 为 ThingsBoard 非 root Docker 用户的用户 ID):

1
mkdir -p ~/.tb-pe-mqtt-integration-logs && sudo chown -R 799:799 ~/.tb-pe-mqtt-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -v ~/.tb-pe-mqtt-integration-logs:/var/log/tb-mqtt-integration \
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" \
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" \
--name my-tb-pe-mqtt-integration --network edge_docker_default --restart always thingsboard/tb-pe-mqtt-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v ~/.tb-pe-mqtt-integration-logs:/var/log/tb-mqtt-integration: 将主机目录 ~/.tb-pe-mqtt-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name my-tb-pe-mqtt-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-mqtt-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开位于 ~/.tb-pe-mqtt-integration-logs 的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-mqtt-integration

停止容器:

1
docker stop tb-pe-mqtt-integration

启动容器:

1
docker start tb-pe-mqtt-integration

执行以下命令拉取镜像:

1
docker pull thingsboard/tb-pe-opc-ua-integration:4.3.0.1PE

创建集成日志卷(799 为 ThingsBoard 非 root Docker 用户的用户 ID):

1
mkdir -p ~/.tb-pe-opc-ua-integration-logs && sudo chown -R 799:799 ~/.tb-pe-opc-ua-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -v ~/.tb-pe-opc-ua-integration-logs:/var/log/tb-opc-ua-integration \
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" \
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" \
--name my-tb-pe-opc-ua-integration --network edge_docker_default --restart always thingsboard/tb-pe-opc-ua-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v ~/.tb-pe-opc-ua-integration-logs:/var/log/tb-opc-ua-integration: 将主机目录 ~/.tb-pe-opc-ua-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-opc-ua-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-opc-ua-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开位于 ~/.tb-pe-opc-ua-integration-logs 的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-opc-ua-integration

停止容器:

1
docker stop tb-pe-opc-ua-integration

启动容器:

1
docker start tb-pe-opc-ua-integration

执行以下命令拉取镜像:

1
docker pull thingsboard/tb-pe-tcp-udp-integration:4.3.0.1PE

为集成日志创建卷(799 为非 root ThingsBoard Docker 用户的用户 ID):

1
mkdir -p ~/.tb-pe-tcp-udp-integration-logs && sudo chown -R 799:799 ~/.tb-pe-tcp-udp-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -p 11560:11560/udp -v ~/.tb-pe-tcp-udp-integration-logs:/var/log/tb-tcp-udp-integration  \-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" \
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" \
--name my-tb-pe-tcp-udp-integration --network NETWORK_NAME \
--restart always thingsboard/tb-pe-tcp-udp-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。

  • -p 11560:11560/udp: 当 exposed 端口为 UDP 时使用。
  • -p 10560:10560: 将本地端口 10560 映射到 TCP 集成的内部端口 10560。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥

  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v ~/.tb-pe-tcp-udp-integration-logs:/var/log/tb-tcp-udp-integration: 将主机目录 ~/.tb-pe-tcp-udp-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-tcp-udp-integration: 设置集成的本地名称。
  • –network NETWORK_NAME: mytbedge 服务所在的网络名称。请将 NETWORK_NAME 替换为实际网络名。
    • 要查看网络名称,可运行以下命令:
    1
    
    docker network ls
    
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-tcp-udp-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开位于 ~/.tb-pe-tcp-udp-integration-logs 的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach my-tb-pe-tcp-udp-integration

停止容器:

1
docker stop my-tb-pe-tcp-udp-integration

启动容器:

1
docker start my-tb-pe-tcp-udp-integration

执行以下命令拉取镜像:

1
docker pull thingsboard/tb-pe-coap-integration:4.3.0.1PE

执行以下命令创建集成日志卷(799 为 ThingsBoard 非 root Docker 用户的用户 ID):

1
mkdir -p ~/.tb-pe-coap-integration-logs && sudo chown -R 799:799 ~/.tb-pe-coap-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -p 5683:5683/udp -v ~/.tb-pe-coap-integration-logs:/var/log/tb-coap-integration  \
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" \
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" \
--name my-tb-pe-coap-integration --network edge_docker_default --restart always thingsboard/tb-pe-coap-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -p 5683:5683/udp: 将本地 UDP 端口 5683 映射到集成的内部 UDP 端口 5683。
  • -v ~/.tb-pe-coap-integration-logs:/var/log/tb-coap-integration: 将主机目录 ~/.tb-pe-coap-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-coap-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-coap-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开位于 ~/.tb-pe-coap-integration-logs 的日志。 查找显示从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-coap-integration

停止容器:

1
docker stop tb-pe-coap-integration

启动容器:

1
docker start tb-pe-coap-integration

高级配置

下方 yml 配置列出了可用参数、对应环境变量及默认值。 例如,集成调试消息中使用的默认客户端 ID 为 “remote”, 可通过设置 “RPC_CLIENT_ID” 环境变量修改。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
server:
  # 服务绑定地址
  address: "${HTTP_BIND_ADDRESS:0.0.0.0}"
  # 服务绑定端口
  port: "${HTTP_BIND_PORT:8082}"

integration:
  routingKey: "${INTEGRATION_ROUTING_KEY:PUT_YOUR_ROUTING_KEY_HERE}"
  secret: "${INTEGRATION_SECRET:PUT_YOUR_SECRET_HERE}"
  # 允许连接 localhost 资源,如本地 MQTT broker 等
  allow_local_network_hosts: "${INTEGRATION_ALLOW_LOCAL_NETWORK_HOSTS:true}"
  statistics:
    # 启用/禁用集成统计
    enabled: "${INTEGRATION_STATISTICS_ENABLED:true}"
    # 统计发送间隔,默认每小时一次
    persist_frequency: "${INTEGRATION_STATISTICS_PERSIST_FREQUENCY:3600000}"

storage:
  # 数据文件存储目录
  data_folder_path: "${INTEGRATION_STORAGE_DATA_FOLDER_PATH:./}"
  # 最多保留的数据文件数量
  max_file_count: "${INTEGRATION_STORAGE_MAX_FILE_COUNT:100}"
  # 每个数据文件最大记录数
  max_records_per_file: "${INTEGRATION_STORAGE_MAX_RECORDS_PER_FILE:30}"
  # 数据文件持久化之间的最大记录数
  max_records_between_fsync: "${INTEGRATION_STORAGE_MAX_RECORDS_BETWEEN_FSYNC:100}"
  # 上传块大小
  max_read_records_count: "${INTEGRATION_STORAGE_MAX_READ_RECORDS_COUNT:50}"
  # 无新记录时的休眠间隔
  no_read_records_sleep: "${INTEGRATION_STORAGE_NO_READ_RECORDS_SLEEP:1000}"

executors:
  # 处理消息和任务的线程池大小
  thread_pool_size: "${EXECUTORS_SIZE:1}"
  # 重连 ThingsBoard 的超时(毫秒)
  reconnect_timeout: "${EXECUTORS_RECONNECT_TIMEOUT:3000}"

rpc:
  # ThingsBoard 服务主机
  host: "${RPC_HOST:thingsboard.cloud}"
  # ThingsBoard 服务端口
  port: "${RPC_PORT:9090}"
  # 无回复超时(秒),用于通道终止
  timeout: "${RPC_TIMEOUT:5}"
  # RPC 客户端 ID
  client_id: "${RPC_CLIENT_ID:remote}"
  ssl:
    # 启用/禁用 SSL
    enabled: "${RPC_SSL_ENABLED:false}"
    # SSL 证书
    cert: "${RPC_SSL_CERT:roots.pem}"

js:
  evaluator: "${JS_EVALUATOR:local}"
  # 内置 JVM JavaScript 环境属性
  local:
    # 使用沙箱(安全)JVM JavaScript 环境
    use_js_sandbox: "${USE_LOCAL_JS_SANDBOX:true}"
    # JavaScript 沙箱资源监控线程池大小
    monitor_thread_pool_size: "${LOCAL_JS_SANDBOX_MONITOR_THREAD_POOL_SIZE:4}"
    # 脚本执行允许的最大 CPU 时间(毫秒)
    max_cpu_time: "${LOCAL_JS_SANDBOX_MAX_CPU_TIME:5000}"
    # JavaScript 被列入黑名单前的最大执行错误数
    max_errors: "${LOCAL_JS_SANDBOX_MAX_ERRORS:3}"

service:
  type: "${TB_SERVICE_TYPE:tb-integration}"

故障排查

注意 若出现与 DNS 相关的错误,例如:

1
127.0.1.1:53: cannot unmarshal DNS message

可将系统配置为使用 Google 公共 DNS 服务器。 请参阅对应的 LinuxMac OS 说明。

要通过 Docker 运行集成,请确保已 安装 Docker Toolbox for Windows

Select the integration to install

Windows 用户应使用 Docker 托管卷存储远程集成日志。 在执行 docker 命令前创建 Docker 卷(如 tb-http-integration-logs)。 打开 Docker Quickstart Terminal 并执行以下命令:

1
docker volume create tb-pe-http-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -v tb-pe-http-integration-logs:/var/log/tb-http-integration `
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" `
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" `
--name my-tb-pe-http-integration --network edge_docker_default --restart always thingsboard/tb-pe-http-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v tb-pe-http-integration-logs:/var/log/tb-http-integration: 将卷 tb-pe-http-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-http-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-http-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开位于 ~/.tb-pe-http-integration-logs 的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-http-integration

停止容器:

1
docker stop tb-pe-http-integration

启动容器:

1
docker start tb-pe-http-integration

Windows 用户应使用 Docker 托管卷存储远程集成日志。 在执行 docker 命令前创建 Docker 卷(如 tb-mqtt-integration-logs)。 打开 Docker Quickstart Terminal 并执行以下命令:

1
docker volume create tb-pe-mqtt-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -v tb-pe-mqtt-integration-logs:/var/log/tb-mqtt-integration `
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" `
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" `
--name my-tb-pe-mqtt-integration --network edge_docker_default --restart always thingsboard/tb-pe-mqtt-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v tb-pe-mqtt-integration-logs:/var/log/tb-mqtt-integration: 将卷 tb-pe-mqtt-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-mqtt-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-mqtt-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开卷对应位置的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-mqtt-integration

停止容器:

1
docker stop tb-pe-mqtt-integration

启动容器:

1
docker start tb-pe-mqtt-integration

Windows 用户应使用 Docker 托管卷存储远程集成日志。 在执行 docker 命令前创建 Docker 卷(如 tb-opc-ua-integration-logs)。 打开 Docker Quickstart Terminal 并执行以下命令:

1
docker volume create tb-pe-opc-ua-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -v tb-pe-opc-ua-integration-logs:/var/log/tb-opc-ua-integration `
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" `
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" `
--name my-tb-pe-opc-ua-integration --network edge_docker_default --restart always thingsboard/tb-pe-opc-ua-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v tb-pe-opc-ua-integration-logs:/var/log/tb-opc-ua-integration: 将卷 tb-pe-opc-ua-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-opc-ua-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-opc-ua-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开卷对应位置的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-opc-ua-integration

停止容器:

1
docker stop tb-pe-opc-ua-integration

启动容器:

1
docker start tb-pe-opc-ua-integration

Windows 用户应使用 Docker 托管卷存储远程集成日志。 在执行 docker 命令前创建 Docker 卷(如 tb-tcp-udp-integration-logs)。 打开 Docker Quickstart Terminal 并执行以下命令:

1
docker volume create tb-pe-tcp-udp-integration-logs

执行以下命令运行集成:

1
2
3
4
docker run -it -p 11560:11560/udp -v tb-pe-tcp-udp-integration-logs:/var/log/tb-tcp-udp-integration `-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" `
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" `
--name my-tb-pe-tcp-udp-integration --network edge_docker_default `
--restart always thingsboard/tb-pe-tcp-udp-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。

  • -p 11560:11560/udp: 当 exposed 端口为 UDP 时使用。
  • -p 10560:10560: 将本地端口 10560 映射到 TCP 集成的内部端口 10560。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥

  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -v tb-pe-tcp-udp-integration-logs:/var/log/tb-tcp-udp-integration: 将卷 tb-pe-tcp-udp-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-tcp-udp-integration: 设置集成的本地名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-tcp-udp-integration:4.3.0.1PE Docker 镜像。

执行此命令后,可打开卷对应位置的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach my-tb-pe-tcp-udp-integration

停止容器:

1
docker stop my-tb-pe-tcp-udp-integration

启动容器:

1
docker start my-tb-pe-tcp-udp-integration

Windows 用户应使用 Docker 托管卷存储远程集成日志。 在执行 docker run 命令前创建 Docker 卷(如 tb-coap-integration-logs):

打开 Docker Quickstart Terminal 并执行以下命令创建 Docker 卷:

1
docker volume create tb-pe-coap-integration-logs
1
2
3
4
docker run -it -p 5683:5683/udp -v tb-pe-coap-integration-logs:/var/log/tb-coap-integration `
-e "RPC_HOST=mytbedge" -e "RPC_PORT=9090" `
-e "INTEGRATION_ROUTING_KEY=YOUR_ROUTING_KEY"  -e "INTEGRATION_SECRET=YOUR_SECRET" `
--name my-tb-pe-coap-integration --network edge_docker_default --restart always thingsboard/tb-pe-coap-integration:4.3.0.1PE

参数说明:

  • mytbedge: ThingsBoard Edge 服务的主机名。
  • 9090: 集成端口,由 tb-edge.yml 文件中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的实际集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的实际集成密钥
  • docker run: 运行此容器的命令。
  • -it: 附加终端会话以查看当前 ThingsBoard 远程集成进程输出。
  • -p 5683:5683/udp: 将本地 UDP 端口 5683 映射到集成的内部 UDP 端口 5683。
  • -v tb-pe-coap-integration-logs:/var/log/tb-coap-integration: 将卷 tb-pe-coap-integration-logs 挂载到 ThingsBoard 远程集成日志目录。
  • –name tb-pe-coap-integration: 容器的本地友好名称。
  • –network edge_docker_default: mytbedge 服务所在的网络名称。
  • –restart always: 系统重启或故障后自动启动 ThingsBoard 集成。
  • thingsboard/tb-pe-coap-integration:4.3.0.1PE: Docker 镜像。

执行此命令后,可打开卷对应位置的日志。 您应能看到包含从服务器接收的最新集成配置的 INFO 日志消息。

要保持容器在后台运行并脱离当前终端会话,请按 Ctrl+p 后按 Ctrl+q

重新附加、停止和启动命令

要重新连接到终端(查看 ThingsBoard 远程集成日志)请运行:

1
docker attach tb-pe-coap-integration

停止容器:

1
docker stop tb-pe-coap-integration

启动容器:

1
docker start tb-pe-coap-integration

高级配置

下方 yml 配置列出了可用参数、对应环境变量及默认值。 例如,集成调试消息中使用的默认客户端 ID 为 “remote”, 可通过设置 “RPC_CLIENT_ID” 环境变量修改。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
server:
  # 服务绑定地址
  address: "${HTTP_BIND_ADDRESS:0.0.0.0}"
  # 服务绑定端口
  port: "${HTTP_BIND_PORT:8082}"

integration:
  routingKey: "${INTEGRATION_ROUTING_KEY:PUT_YOUR_ROUTING_KEY_HERE}"
  secret: "${INTEGRATION_SECRET:PUT_YOUR_SECRET_HERE}"
  # 允许连接 localhost 资源,如本地 MQTT broker 等
  allow_local_network_hosts: "${INTEGRATION_ALLOW_LOCAL_NETWORK_HOSTS:true}"
  statistics:
    # 启用/禁用集成统计
    enabled: "${INTEGRATION_STATISTICS_ENABLED:true}"
    # 统计发送间隔,默认每小时一次
    persist_frequency: "${INTEGRATION_STATISTICS_PERSIST_FREQUENCY:3600000}"

storage:
  # 数据文件存储目录
  data_folder_path: "${INTEGRATION_STORAGE_DATA_FOLDER_PATH:./}"
  # 最多保留的数据文件数量
  max_file_count: "${INTEGRATION_STORAGE_MAX_FILE_COUNT:100}"
  # 每个数据文件最大记录数
  max_records_per_file: "${INTEGRATION_STORAGE_MAX_RECORDS_PER_FILE:30}"
  # 数据文件持久化之间的最大记录数
  max_records_between_fsync: "${INTEGRATION_STORAGE_MAX_RECORDS_BETWEEN_FSYNC:100}"
  # 上传块大小
  max_read_records_count: "${INTEGRATION_STORAGE_MAX_READ_RECORDS_COUNT:50}"
  # 无新记录时的休眠间隔
  no_read_records_sleep: "${INTEGRATION_STORAGE_NO_READ_RECORDS_SLEEP:1000}"

executors:
  # 处理消息和任务的线程池大小
  thread_pool_size: "${EXECUTORS_SIZE:1}"
  # 重连 ThingsBoard 的超时(毫秒)
  reconnect_timeout: "${EXECUTORS_RECONNECT_TIMEOUT:3000}"

rpc:
  # ThingsBoard 服务主机
  host: "${RPC_HOST:thingsboard.cloud}"
  # ThingsBoard 服务端口
  port: "${RPC_PORT:9090}"
  # 无回复超时(秒),用于通道终止
  timeout: "${RPC_TIMEOUT:5}"
  # RPC 客户端 ID
  client_id: "${RPC_CLIENT_ID:remote}"
  ssl:
    # 启用/禁用 SSL
    enabled: "${RPC_SSL_ENABLED:false}"
    # SSL 证书
    cert: "${RPC_SSL_CERT:roots.pem}"

js:
  evaluator: "${JS_EVALUATOR:local}"
  # 内置 JVM JavaScript 环境属性
  local:
    # 使用沙箱(安全)JVM JavaScript 环境
    use_js_sandbox: "${USE_LOCAL_JS_SANDBOX:true}"
    # JavaScript 沙箱资源监控线程池大小
    monitor_thread_pool_size: "${LOCAL_JS_SANDBOX_MONITOR_THREAD_POOL_SIZE:4}"
    # 脚本执行允许的最大 CPU 时间(毫秒)
    max_cpu_time: "${LOCAL_JS_SANDBOX_MAX_CPU_TIME:5000}"
    # JavaScript 被列入黑名单前的最大执行错误数
    max_errors: "${LOCAL_JS_SANDBOX_MAX_ERRORS:3}"

service:
  type: "${TB_SERVICE_TYPE:tb-integration}"

故障排查

注意 若出现与 DNS 相关的错误,例如:

1
127.0.1.1:53: cannot unmarshal DNS message

可将系统配置为使用 Google 公共 DNS 服务器

安装 Java 17 (OpenJDK)

ThingsBoard 服务运行在 Java 17 上。请按以下说明安装 OpenJDK 17:

1
sudo apt update && sudo apt install openjdk-17-jdk-headless

将您的操作系统配置为默认使用 OpenJDK 17。您可以通过运行以下命令来配置默认版本:

1
sudo update-alternatives --config java

要检查系统上已安装的 Java 版本,请使用以下命令:

1
java -version

预期输出为:

1
2
3
openjdk version "17.x.xx" 
OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (...)

选择集成包

下载安装包:

1
wget https://dist.thingsboard.io/tb-http-integration-4.3.0.1pe.deb

以服务方式安装集成:

1
sudo dpkg -i tb-http-integration-4.3.0.1pe.deb

打开配置文件进行编辑:

1
sudo nano /etc/tb-http-integration/conf/tb-http-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-http-integration start

高级配置

可在 tb-http-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-http-integration/conf/tb-http-integration.conf

修改配置后,可在 /var/log/tb-http-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-mqtt-integration-4.3.0.1pe.deb

以服务方式安装集成:

1
sudo dpkg -i tb-mqtt-integration-4.3.0.1pe.deb

打开配置文件进行编辑:

1
sudo nano /etc/tb-mqtt-integration/conf/tb-mqtt-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-mqtt-integration start

高级配置

可在 tb-mqtt-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-mqtt-integration/conf/tb-mqtt-integration.conf

修改配置后,可在 /var/log/tb-mqtt-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-opc-ua-integration-4.3.0.1pe.deb

以服务方式安装集成:

1
sudo dpkg -i tb-opc-ua-integration-4.3.0.1pe.deb

打开配置文件进行编辑:

1
sudo nano /etc/tb-opc-ua-integration/conf/tb-opc-ua-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-opc-ua-integration start

高级配置

可在 tb-opc-ua-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-opc-ua-integration/conf/tb-opc-ua-integration.conf

修改配置后,可在 /var/log/tb-opc-ua-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-tcp-udp-integration-4.3.0.1pe.deb

以服务方式安装集成:

1
sudo dpkg -i tb-tcp-udp-integration-4.3.0.1pe.deb

打开配置文件进行编辑:

1
sudo nano /etc/tb-tcp-udp-integration/conf/tb-tcp-udp-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。

  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-tcp-udp-integration start

高级配置

可在 tb-tcp-udp-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-tcp-udp-integration/conf/tb-tcp-udp-integration.conf

修改配置后,可在 /var/log/tb-tcp-udp-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-coap-integration-4.3.0.1pe.deb

以服务方式安装集成:

1
sudo dpkg -i tb-coap-integration-4.3.0.1pe.deb

打开配置文件进行编辑:

1
sudo nano /etc/tb-coap-integration/conf/tb-coap-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

Make sure to uncomment the export statement.

See the example below:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

Execute the following command to start ThingsBoard integration:

1
sudo service tb-coap-integration start

高级配置

可在 tb-coap-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-coap-integration/conf/tb-coap-integration.conf

修改配置后,可在 /var/log/tb-coap-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

安装 Java 17 (OpenJDK)

ThingsBoard 服务运行在 Java 17 上。请按以下说明安装 OpenJDK 17:

1
sudo dnf install java-17-openjdk-headless

请勿忘记将您的操作系统配置为默认使用 OpenJDK 17。您可以使用以下命令配置默认版本:

1
sudo update-alternatives --config java

您可以使用以下命令检查安装:

1
java -version

预期命令输出为:

1
2
3
openjdk version "17.x.xx"
OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (build ...)

选择集成包

下载安装包:

1
wget https://dist.thingsboard.io/tb-http-integration-4.3.0.1pe.rpm

以服务方式安装集成:

1
sudo rpm -Uvh tb-http-integration-4.3.0.1pe.rpm

打开配置文件进行编辑:

1
sudo nano /etc/tb-http-integration/conf/tb-http-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-http-integration start

高级配置

可在 tb-http-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-http-integration/conf/tb-http-integration.conf

修改配置后,可在 /var/log/tb-http-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-mqtt-integration-4.3.0.1pe.rpm

以服务方式安装集成:

1
sudo rpm -Uvh tb-mqtt-integration-4.3.0.1pe.rpm

打开配置文件进行编辑:

1
sudo nano /etc/tb-mqtt-integration/conf/tb-mqtt-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-mqtt-integration start

高级配置

可在 tb-mqtt-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-mqtt-integration/conf/tb-mqtt-integration.conf

修改配置后,可在 /var/log/tb-mqtt-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-opc-ua-integration-4.3.0.1pe.rpm

以服务方式安装集成:

1
sudo rpm -Uvh tb-opc-ua-integration-4.3.0.1pe.rpm

打开配置文件进行编辑:

1
sudo nano /etc/tb-opc-ua-integration/conf/tb-opc-ua-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-opc-ua-integration start

高级配置

可在 tb-opc-ua-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-opc-ua-integration/conf/tb-opc-ua-integration.conf

修改配置后,可在 /var/log/tb-opc-ua-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-tcp-udp-integration-4.3.0.1pe.rpm

以服务方式安装集成:

1
sudo rpm -Uvh tb-tcp-udp-integration-4.3.0.1pe.rpm

打开配置文件进行编辑:

1
sudo nano /etc/tb-tcp-udp-integration/conf/tb-tcp-udp-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。

  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-tcp-udp-integration start

高级配置

可在 tb-tcp-udp-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-tcp-udp-integration/conf/tb-tcp-udp-integration.conf

修改配置后,可在 /var/log/tb-tcp-udp-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

下载安装包:

1
wget https://dist.thingsboard.io/tb-coap-integration-4.3.0.1pe.rpm

以服务方式安装集成:

1
sudo rpm -Uvh tb-coap-integration-4.3.0.1pe.rpm

打开配置文件进行编辑:

1
sudo nano /etc/tb-coap-integration/conf/tb-coap-integration.conf

找到如下配置块:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
# export RPC_HOST=thingsboard.cloud
# export RPC_PORT=9090
# export INTEGRATION_ROUTING_KEY=YOUR_INTEGRATION_KEY
# export INTEGRATION_SECRET=YOUR_INTEGRATION_SECRET

填入配置参数:

  • RPC_HOST: 使用 Edge 实例的 IP 地址,若在同一台机器运行则使用 localhost
  • 9090: 集成端口,由 tb-edge.yml 中的 INTEGRATIONS_RPC_PORT 环境变量配置。
  • YOUR_ROUTING_KEY: 替换为 步骤 3 中获取的 集成路由密钥
  • YOUR_SECRET: 替换为 步骤 3 中获取的 集成密钥

取消注释 export 语句。

示例:

1
2
3
4
5
# UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS:
export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE
export RPC_PORT=9090
export INTEGRATION_ROUTING_KEY=b75**************************34d
export INTEGRATION_SECRET=vna**************mik

启动 ThingsBoard 集成:

1
sudo service tb-coap-integration start

高级配置

可在 tb-coap-integration.conf 中查看并修改更多配置参数。

使用以下命令编辑文件:

1
sudo nano /etc/tb-coap-integration/conf/tb-coap-integration.conf

修改配置后,可在 /var/log/tb-coap-integration/ 下查看日志以验证集成是否正常运行。 可查找 INFO 级别日志,确认已收到服务器下发的集成配置。

Remote HTTP integration validation

To send an uplink message, you need an HTTP endpoint URL from the integration.
Let’s log in to the ThingsBoard Edge and go to the Integrations section. Find the HTTP integration and click it. There you can find the HTTP endpoint URL. Click the icon to copy the URL.

文档信息图标

Important!

Please make sure that your machine is able to access the machine on which the remote HTTP integration is running, and the port 8082 is not blocked by any firewall rules.

To send the message, use the following command. Replace $DEVICE_NAME and $YOUR_HTTP_ENDPOINT_URL with the corresponding values.

1
curl -v -X POST -d "{\"deviceName\":\"$DEVICE_NAME\",\"temperature\":33,\"model\":\"test\"}" $YOUR_HTTP_ENDPOINT_URL -H "Content-Type:application/json"

The created device with data can be viewed in the Device groups > All on the Edge section:

Remote integration configuration

Configuring remote integrations is done through the ThingsBoard interface, with no special steps required. Explore the following guides and video tutorials related to the specific integrations:

Remote integration troubleshooting

Check the log files. Their location is specific to the platform and installation package you are using and is indicated in the installation steps.

下一步

  • Getting started guide(入门指南)- 快速概览 ThingsBoard Edge 主要功能。预计 15–30 分钟完成:

  • Installation guides(安装指南)- 了解如何在各种操作系统上安装 ThingsBoard Edge 并连接到 ThingsBoard Server。

  • Edge 规则引擎:

  • 安全:
    • gRPC over SSL/TLS - 了解如何为 Edge 与云端之间的通信配置 gRPC over SSL/TLS。
  • 功能:

    • Edge Status(Edge 状态)- 了解 ThingsBoard Edge 上的 Edge Status 页面。

    • Cloud Events(云端事件)- 了解 ThingsBoard Edge 上的 Cloud Events 页面。

  • 使用场景:

  • Roadmap(路线图)- ThingsBoard Edge 路线图。