Installing ThingsBoard PE on Windows

Prerequisites

This guide describes how to install ThingsBoard on a Windows machine. Instructions below are provided for Windows 10/8.1/8/7 32-bit/64-bit. Hardware requirements depend on chosen database and amount of devices connected to the system. To run ThingsBoard and PostgreSQL on a single machine you will need at least 2Gb of RAM. To run ThingsBoard and Cassandra on a single machine you will need at least 8Gb of RAM.

Step 1. Install Java 8 (OpenJDK)

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

  • 访问Open JDK下载页面以下载最新的OpenJDK 8(LTS) MSI软件包。
  • 运行下载的MSI软件包并按照说明进行操作。 确保已选择“添加到路径”和“设置JAVA_HOME变量”选项为“将在本地硬盘驱动器上安装”状态。

您可以使用以下命令(使用命令提示符)检查安装:

java -version

命令输出结果:

C:\Users\User>java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b04, mixed mode)

Step 2. ThingsBoard service installation

Download and run the installation package.

https://dist.thingsboard.io/thingsboard-windows-setup-3.1.1pe.exe

Note: We assume you have installed ThingsBoard to default location: C:\Program Files (x86)\thingsboard

Step 3. Obtain and configure license key

We assume you have already chosen your subscription plan or decided to purchase a perpetual license. If not, please navigate to pricing page to select the best license option for your case and get your license. See How-to get pay-as-you-go subscription or How-to get perpetual license for more details.

Once you get the license secret, you should put it to the thingsboard configuration file.

Open the Notepad or other editor as administrator user (right click on the app icon and select “Run as administrator”).
Open the following file for editing (select “All Files” instead of “Text Documents” in file choosing dialog, the encoding is UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

Scroll to the bottom of the file and locate the following configuration block:

license:
    secret: "${TB_LICENSE_SECRET:}" # license secret obtained from ThingsBoard License Portal (https://license.thingsboard.io)

and put your license secret. See example below:

license:
    secret: "${TB_LICENSE_SECRET:YOUR_LICENSE_SECRET_HERE}" # license secret obtained from ThingsBoard License Portal (https://license.thingsboard.io)

Step 4. Configure ThingsBoard database

ThingsBoard能够使用SQL或hybrid数据库方式。 有关更多详细信息请参见相应的体系结构页面

将PostgreSQL用于开发和生产环境ThingsBoard团队建议负载(<5000消息/秒)。

使用托管的PostgreSQL服务器对于ThingsBoard实例而言都是一种经济高效的解决方案。

PostgreSQL安装

下载安装文件(PostgreSQL 11.7或更高版本此处并按照安装说明进行操作。

在PostgreSQL安装时系统将提示您输入超级用户(postgres)密码。

请一定牢记此密码,为了方便记忆我们将密码替换为postgres。

创建ThingsBoard数据库

安装成功后启动”pgAdmin”并使用超级用户(postgres)身份登录。

打开服务器并用”postgres”用户创建数据库”thingsboard”。

ThingsBoard配置

如果您已将PostgreSQL超级用户密码指定为”postgres”则可以跳过此步骤。

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择”以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”,编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

找到”SQL DAO Configuration”代码块将postgres用户密码替换”postgres”:

# SQL DAO Configuration
spring:
  data:
    jpa:
      repositories:
        enabled: "true"
  jpa:
    open-in-view: "false"
    hibernate:
      ddl-auto: "none"
    database-platform: "${SPRING_JPA_DATABASE_PLATFORM:org.hibernate.dialect.PostgreSQLDialect}"
  datasource:
    driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}"
    url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
    username: "${SPRING_DATASOURCE_USERNAME:postgres}"
    password: "${SPRING_DATASOURCE_PASSWORD:YOUR_POSTGRES_PASSWORD_HERE}"
    hikari:
      maximumPoolSize: "${SPRING_DATASOURCE_MAXIMUM_POOL_SIZE:5}"

找到”SQL_POSTGRES_TS_KV_PARTITIONING”参数以覆盖时间戳键值存储分区大小的默认值:

    sql:
      postgres:
        # Specify partitioning size for timestamp key-value storage. Example: DAYS, MONTHS, YEARS, INDEFINITE.
        ts_key_value_partitioning: "${SQL_POSTGRES_TS_KV_PARTITIONING:MONTHS}"

如果生产环境超过100万个数据采集频率(>5000消息/秒)建议使用Hybrid数据库方式。

建议使用Cassandra存储时间序列数据同时将PostgreSQL用于主要实体(设备/资产/仪表板/客户)存储。

PostgreSQL安装

下载安装文件(PostgreSQL 11.7或更高版本此处并按照安装说明进行操作。

在PostgreSQL安装时系统将提示您输入超级用户(postgres)密码。

请一定牢记此密码,为了方便记忆我们将密码替换为postgres。

创建ThingsBoard数据库

安装成功后启动“pgAdmin”并使用超级用户(postgres)身份登录。

打开服务器并用“postgres”用户创建数据库“thingsboard”。

Cassandra安装

下面列出的说明将帮助您安装Cassandra。

  • 下载DataStax社区版v3.0.9
  • 运行下载的MSI软件包。首先您会看到一个初始的欢迎面板,该面板标识您的安装软件包:

image

  • 单击Next将进入到最终用户许可协议:

image

  • 单击Next进入指定软件的安装位置:

image

  • 设置好安装目录后,安装程序将询问您如何处理将要安装的服务:

image

  • 单击Next开始安装过程:

image

image

  • 最后询问您是否希望在该软件的新版本可用时进行更新:

image

  • 您可以在安装程序为您创建的“ DataStax Community Edition”程序组中找到已安装的接口:

image

  • Cassandra的主要接口是CQL(Cassandra查询语言)shell实用程序,可用于为新的Cassandra服务器执行CQL命令。
ThingsBoard配置

如果您已将PostgreSQL超级用户密码指定为”postgres”,则可以跳过此步骤。

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标,然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”,编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

找到”SQL DAO Configuration”代码块将postgres用户密码替换”postgres”:

# SQL DAO Configuration
spring:
  data:
    jpa:
      repositories:
        enabled: "true"
  jpa:
    open-in-view: "false"
    hibernate:
      ddl-auto: "none"
    database-platform: "${SPRING_JPA_DATABASE_PLATFORM:org.hibernate.dialect.PostgreSQLDialect}"
  datasource:
    driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}"
    url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
    username: "${SPRING_DATASOURCE_USERNAME:postgres}"
    password: "${SPRING_DATASOURCE_PASSWORD:YOUR_POSTGRES_PASSWORD_HERE}"
    hikari:
      maximumPoolSize: "${SPRING_DATASOURCE_MAXIMUM_POOL_SIZE:5}"

找到“ DATABASE_TS_TYPE”参数。将“sql”替换为“ cassandra”。

    type: "${DATABASE_TS_TYPE:cassandra}" # cassandra OR sql (for hybrid mode, only this value should be cassandra)

您可以选择在“cassandra”代码块中调整参数。

# Cassandra driver configuration parameters
cassandra:
  # Thingsboard cluster name
  cluster_name: "${CASSANDRA_CLUSTER_NAME:Thingsboard Cluster}"
  # Thingsboard keyspace name
  keyspace_name: "${CASSANDRA_KEYSPACE_NAME:thingsboard}"
  # Specify node list
  url: "${CASSANDRA_URL:127.0.0.1:9042}"
  # Enable/disable secure connection
  ssl: "${CASSANDRA_USE_SSL:false}"
  # Enable/disable JMX
  jmx: "${CASSANDRA_USE_JMX:true}"
  # Enable/disable metrics collection.
  metrics: "${CASSANDRA_DISABLE_METRICS:true}"
  # NONE SNAPPY LZ4
  compression: "${CASSANDRA_COMPRESSION:none}"
  # Specify cassandra cluster initialization timeout in milliseconds (if no hosts available during startup)
  init_timeout_ms: "${CASSANDRA_CLUSTER_INIT_TIMEOUT_MS:300000}"
  # Specify cassandra claster initialization retry interval (if no hosts available during startup)
  init_retry_interval_ms: "${CASSANDRA_CLUSTER_INIT_RETRY_INTERVAL_MS:3000}"
  max_requests_per_connection_local: "${CASSANDRA_MAX_REQUESTS_PER_CONNECTION_LOCAL:32768}"
  max_requests_per_connection_remote: "${CASSANDRA_MAX_REQUESTS_PER_CONNECTION_REMOTE:32768}"
  # Credential parameters #
  credentials: "${CASSANDRA_USE_CREDENTIALS:false}"
  # Specify your username
  username: "${CASSANDRA_USERNAME:}"
  # Specify your password
  password: "${CASSANDRA_PASSWORD:}"

建议已经在生产环境中使用TimescaleDB的场景使用Timescale方式。

这种情况下使用TimescaleDB Hypertable存储时间序列数据同时将PostgreSQL用于主要实体(设备/资产/仪表板/客户)存储。

PostgreSQL安装

下载安装文件(PostgreSQL 11.7或更高版本此处并按照安装说明进行操作。

在PostgreSQL安装期间系统将提示您输入超级用户(postgres)密码。

我们将其设置为”postgres”。

创建ThingsBoard数据库

安装后启动”pgAdmin”软件并以超级用户(postgres)身份登录。

打开服务器并使用所有者”postgres”创建数据库”thingsboard”。

TimescaleDB安装

请参考CentOS发行版的官方TimescaleDB安装页面并按照说明进行操作已安装PostgreSQL版本。

ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标,然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”# SQL DAO Configuration”代码块填写真实postgres用户密码替换”postgres”:

# SQL DAO Configuration
spring:
  data:
    jpa:
      repositories:
        enabled: "true"
  jpa:
    open-in-view: "false"
    hibernate:
      ddl-auto: "none"
    database-platform: "${SPRING_JPA_DATABASE_PLATFORM:org.hibernate.dialect.PostgreSQLDialect}"
  datasource:
    driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}"
    url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
    username: "${SPRING_DATASOURCE_USERNAME:postgres}"
    password: "${SPRING_DATASOURCE_PASSWORD:YOUR_POSTGRES_PASSWORD_HERE}"
    hikari:
      maximumPoolSize: "${SPRING_DATASOURCE_MAXIMUM_POOL_SIZE:5}"

找到”DATABASE_TS_TYPE”参数将”sql”替换为”timescale”。

      ts:
        type: "${DATABASE_TS_TYPE:sql}" # cassandra, sql, or timescale (for hybrid mode, DATABASE_TS_TYPE value should be cassandra, or timescale)
    
    # note: timescale works only with postgreSQL database for DATABASE_ENTITIES_TYPE.

您可以选择调整引用Timescale DB配置的参数”sql”配置块中的”timescale”配置块。

# SQL configuration parameters
sql:
    timescale:
      # Specify Interval size for new data chunks storage.
      chunk_time_interval: "${SQL_TIMESCALE_CHUNK_TIME_INTERVAL:604800000}"

Step 5. Choose ThingsBoard queue service

选择下面消息中间件代理服务之前的通信。

  • 内存 默认队列适用于开发环境很有用请勿用于生产环境。

  • Kafka 对于本地和私有云部署可以独立于云服务供应商生产环境中使用。

  • RabbitMQ 如果没有太多负载并且已经具备一定的使用经验建议使用此方式。

  • AWS SQS 如是你打算在AWS上使用ThingsBoard则可以使用此消息队列。

  • Google发布/订阅 如果你打算在Google Cloud上部署ThingsBoard则可以使用此消息队列。

  • Azure服务总线 如果你打算在Azure上部署ThingsBoard则可以使用此消息队列。

  • Confluent云 基于Kafka的完全托管的事件流平台。

参见相应的架构页面和规则引擎页面以获取更多详细信息。

默认使用内置的内存队列无需其他配置。

Kafka

Apache Kafka是一个开放源代码的流处理软件平台。

安装Kafka

使用此说明在Docker容器中安装Kafka。

ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”queue”块确保type的值是kafka修改下面配置文件并将”localhost:9092”替换成真实的Kafka服务器地址:

queue:
  type: "${TB_QUEUE_TYPE:kafka}"
...
  kafka:
    bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
    acks: "${TB_KAFKA_ACKS:all}"
    retries: "${TB_KAFKA_RETRIES:1}"
    batch.size: "${TB_KAFKA_BATCH_SIZE:16384}"
    linger.ms: "${TB_KAFKA_LINGER_MS:1}"
    buffer.memory: "${TB_BUFFER_MEMORY:33554432}"
    replication_factor: "${TB_QUEUE_KAFKA_REPLICATION_FACTOR:1}"

AWS SQS配置

首先需要创建一个AWS账户然后访问AWS SQS服务。

要使用AWS SQS服务您将需要使用此说明创建下一个凭证。

  • Access key ID
  • Secret access key
ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”queue”块确保type的值是aws-sqs修改配置文件将”YOUR_KEY”和”YOUR_SECRET”替换为真实的AWS用户凭证并将”YOUR_REGION”替换成AWS SQS帐户区域:

queue:
  type: "${TB_QUEUE_TYPE:aws-sqs}"
...
  aws_sqs:
    access_key_id: "${TB_QUEUE_AWS_SQS_ACCESS_KEY_ID:YOUR_KEY}"
    secret_access_key: "${TB_QUEUE_AWS_SQS_SECRET_ACCESS_KEY:YOUR_SECRET}"
    region: "${TB_QUEUE_AWS_SQS_REGION:YOUR_REGION}"

These params affect the number of requests per second from each partitions per each queue.

Number of requests to particular Message Queue calculated based on the formula:

((Number of Rule Engine and Core Queues) * (Number of partitions per Queue) + (Number of transport queues) + (Number of microservices) + (Number of JS executors)) * 1000 / POLL_INTERVAL_MS

For example, number of requests based on default parameters is:

Rule Engine queues:

Main 10 partitions + HighPriority 10 partitions + SequentialByOriginator 10 partitions = 30

Core queue 10 partitions

Transport request Queue + response Queue = 2

Rule Engine Transport notifications Queue + Core Transport notifications Queue = 2

Total = 44

Number of requests per second = 44 * 1000 / 25 = 1760 requests

Based on the use case, you can compromise latency and decrease number of partitions/requests to the queue, if the message load is low.

Sample parameters to fit into 10 requests per second on a “monolith” deployment:

queue:
...
  transport_api:
    request_poll_interval: "${TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS:1000}"
    response_poll_interval: "${TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  core:
    poll-interval: "${TB_QUEUE_CORE_POLL_INTERVAL_MS:1000}"
    partitions: "${TB_QUEUE_CORE_PARTITIONS:2}"
...
  js:
    response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  rule-engine:
    poll-interval: "${TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS:1000}"
...
    queues:
        poll-interval: "${TB_QUEUE_RE_MAIN_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_MAIN_PARTITIONS:2}"
...
        poll-interval: "${TB_QUEUE_RE_HP_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_HP_PARTITIONS:1}"
...
        poll-interval: "${TB_QUEUE_RE_SQ_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_SQ_PARTITIONS:1}"
...
  transport:
    poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:1000}"

Google发布/订阅配置

创建一个Google云帐户并访问发布/订阅服务。

使用此说明创建一个项目并使用发布/订阅服务。

使用此说明创建服务帐户凭据并编辑角色管理员后保存json凭据步骤9的文件此处

ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”queue”块确保type的值是pubsub修改下面配置内容使用真正用户密码替换”YOUR_PROJECT_ID”, “YOUR_SERVICE_ACCOUNT”:

queue:
  type: "${TB_QUEUE_TYPE:pubsub}"
...
  pubsub:
    project_id: "${TB_QUEUE_PUBSUB_PROJECT_ID:YOUR_PROJECT_ID}"
    service_account: "${TB_QUEUE_PUBSUB_SERVICE_ACCOUNT:YOUR_SERVICE_ACCOUNT}"
    max_msg_size: "${TB_QUEUE_PUBSUB_MAX_MSG_SIZE:1048576}" #in bytes
    max_messages: "${TB_QUEUE_PUBSUB_MAX_MESSAGES:1000}"

These params affect the number of requests per second from each partitions per each queue.

Number of requests to particular Message Queue calculated based on the formula:

((Number of Rule Engine and Core Queues) * (Number of partitions per Queue) + (Number of transport queues) + (Number of microservices) + (Number of JS executors)) * 1000 / POLL_INTERVAL_MS

For example, number of requests based on default parameters is:

Rule Engine queues:

Main 10 partitions + HighPriority 10 partitions + SequentialByOriginator 10 partitions = 30

Core queue 10 partitions

Transport request Queue + response Queue = 2

Rule Engine Transport notifications Queue + Core Transport notifications Queue = 2

Total = 44

Number of requests per second = 44 * 1000 / 25 = 1760 requests

Based on the use case, you can compromise latency and decrease number of partitions/requests to the queue, if the message load is low.

Sample parameters to fit into 10 requests per second on a “monolith” deployment:

queue:
...
  transport_api:
    request_poll_interval: "${TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS:1000}"
    response_poll_interval: "${TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  core:
    poll-interval: "${TB_QUEUE_CORE_POLL_INTERVAL_MS:1000}"
    partitions: "${TB_QUEUE_CORE_PARTITIONS:2}"
...
  js:
    response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  rule-engine:
    poll-interval: "${TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS:1000}"
...
    queues:
        poll-interval: "${TB_QUEUE_RE_MAIN_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_MAIN_PARTITIONS:2}"
...
        poll-interval: "${TB_QUEUE_RE_HP_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_HP_PARTITIONS:1}"
...
        poll-interval: "${TB_QUEUE_RE_SQ_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_SQ_PARTITIONS:1}"
...
  transport:
    poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:1000}"

Azure服务总线配置

创建一个Azure帐户并访问Azure服务总线。

通过使用说明了解并使用总线服务。

使用说明创建共享访问签名。

ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”queue”块确保type的值是service-bus修改下面配置内容使用真正的服务总线名称空间替换”YOUR_NAMESPACE_NAME”和”YOUR_SAS_KEY_NAME”及”YOUR_SAS_KEY”:

queue:
  type: "${TB_QUEUE_TYPE:service-bus}"
...
  service_bus:
    namespace_name: "${TB_QUEUE_SERVICE_BUS_NAMESPACE_NAME:YOUR_NAMESPACE_NAME}"
    sas_key_name: "${TB_QUEUE_SERVICE_BUS_SAS_KEY_NAME:YOUR_SAS_KEY_NAME}"
    sas_key: "${TB_QUEUE_SERVICE_BUS_SAS_KEY:YOUR_SAS_KEY}"
    max_messages: "${TB_QUEUE_SERVICE_BUS_MAX_MESSAGES:1000}"

These params affect the number of requests per second from each partitions per each queue.

Number of requests to particular Message Queue calculated based on the formula:

((Number of Rule Engine and Core Queues) * (Number of partitions per Queue) + (Number of transport queues) + (Number of microservices) + (Number of JS executors)) * 1000 / POLL_INTERVAL_MS

For example, number of requests based on default parameters is:

Rule Engine queues:

Main 10 partitions + HighPriority 10 partitions + SequentialByOriginator 10 partitions = 30

Core queue 10 partitions

Transport request Queue + response Queue = 2

Rule Engine Transport notifications Queue + Core Transport notifications Queue = 2

Total = 44

Number of requests per second = 44 * 1000 / 25 = 1760 requests

Based on the use case, you can compromise latency and decrease number of partitions/requests to the queue, if the message load is low.

Sample parameters to fit into 10 requests per second on a “monolith” deployment:

queue:
...
  transport_api:
    request_poll_interval: "${TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS:1000}"
    response_poll_interval: "${TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  core:
    poll-interval: "${TB_QUEUE_CORE_POLL_INTERVAL_MS:1000}"
    partitions: "${TB_QUEUE_CORE_PARTITIONS:2}"
...
  js:
    response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  rule-engine:
    poll-interval: "${TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS:1000}"
...
    queues:
        poll-interval: "${TB_QUEUE_RE_MAIN_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_MAIN_PARTITIONS:2}"
...
        poll-interval: "${TB_QUEUE_RE_HP_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_HP_PARTITIONS:1}"
...
        poll-interval: "${TB_QUEUE_RE_SQ_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_SQ_PARTITIONS:1}"
...
  transport:
    poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:1000}"

RabbitMQ安装

请使用此说明安装RabbitMQ。

ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”queue”块确保type的值是rabbitmq修改下面配置内容使用真正的用户凭据替换”YOUR_USERNAME”和”YOUR_PASSWORD”以及”localhost”、”5672”:

queue:
  type: "${TB_QUEUE_TYPE:rabbitmq}"
...
  rabbitmq:
    exchange_name: "${TB_QUEUE_RABBIT_MQ_EXCHANGE_NAME:}"
    host: "${TB_QUEUE_RABBIT_MQ_HOST:localhost}"
    port: "${TB_QUEUE_RABBIT_MQ_PORT:5672}"
    virtual_host: "${TB_QUEUE_RABBIT_MQ_VIRTUAL_HOST:/}"
    username: "${TB_QUEUE_RABBIT_MQ_USERNAME:YOUR_USERNAME}"
    password: "${TB_QUEUE_RABBIT_MQ_PASSWORD:YOUR_PASSWORD}"
    automatic_recovery_enabled: "${TB_QUEUE_RABBIT_MQ_AUTOMATIC_RECOVERY_ENABLED:false}"
    connection_timeout: "${TB_QUEUE_RABBIT_MQ_CONNECTION_TIMEOUT:60000}"
    handshake_timeout: "${TB_QUEUE_RABBIT_MQ_HANDSHAKE_TIMEOUT:10000}"
    queue-properties:

Confluent云配置

你应该创建一个帐户后访问Confluent云然后创建一个Kafka集群API Key

ThingsBoard配置

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”编码为UTF-8):

C:\Program Files (x86)\thingsboard\conf\thingsboard.yml

并找到”queue”代码块确保队列类型为”kafka”和factor的值是”3”并且使用confluent云为”true”。

用真正的Confluent云服务器替换”CLUSTER_API_KEY”, “CLUSTER_API_SECRET”和”localhost:9092”:

queue:
  type: "${TB_QUEUE_TYPE:kafka}"
...
  kafka:
    bootstrap.servers: "${TB_KAFKA_SERVERS:localhost:9092}"
...
    replication_factor: "${TB_QUEUE_KAFKA_REPLICATION_FACTOR:3}"
...
    use_confluent_cloud: "${TB_QUEUE_KAFKA_USE_CONFLUENT_CLOUD:true}"
...
      sasl.config: "${TB_QUEUE_KAFKA_CONFLUENT_SASL_JAAS_CONFIG:org.apache.kafka.common.security.plain.PlainLoginModule required username=\"CLUSTER_API_KEY\" password=\"CLUSTER_API_SECRET\";}"

这些参数应用于每个队列每个分区每秒的请求数。

根据以下公式计算的对特定Message Queue的请求数:

((规则引擎和核心队数) * (队列分区数) + (传输队列数) + (微服务数) + (JS执行器数)) * 1000 / POLL_INTERVAL_MS

例如:基于默认参数的请求数为:

规则引擎队列:

10分区+高优先级10分区+SequentialByOriginator10分区 =30

核心队列10分区

传输请求队列+响应队列=2

规则引擎传输通知队列+核心传输通知队列=2

总计=44

每秒请求数=44*1000/25=1760请求

根据用例如果消息负载较低则可以降低延迟并减少对队列的分区/请求数。

在“整体”部署中每秒可满足10个请求的示例参数:

queue:
...
  transport_api:
    request_poll_interval: "${TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS:1000}"
    response_poll_interval: "${TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  core:
    poll-interval: "${TB_QUEUE_CORE_POLL_INTERVAL_MS:1000}"
    partitions: "${TB_QUEUE_CORE_PARTITIONS:2}"
...
  js:
    response_poll_interval: "${REMOTE_JS_RESPONSE_POLL_INTERVAL_MS:1000}"
...
  rule-engine:
    poll-interval: "${TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS:1000}"
...
    queues:
        poll-interval: "${TB_QUEUE_RE_MAIN_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_MAIN_PARTITIONS:2}"
...
        poll-interval: "${TB_QUEUE_RE_HP_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_HP_PARTITIONS:1}"
...
        poll-interval: "${TB_QUEUE_RE_SQ_POLL_INTERVAL_MS:1000}"
        partitions: "${TB_QUEUE_RE_SQ_PARTITIONS:1}"
...
  transport:
    poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:1000}"

Step 6. [Optional] Memory update for slow machines (1GB of RAM)

以管理员用户身份打开记事本或其他编辑器(右键单击应用程序图标,然后选择“以管理员身份运行”)。

打开以下文件进行编辑(在文件选择对话框中选择“所有文件”而不是“文本文档”,编码为UTF-8):

C:\Program Files (x86)\thingsboard\thingsboard.xml

在配置文件中找到以下几行。

    <startargument>-Xms512m</startargument>
    <startargument>-Xmx1024m</startargument>

并将它们更改为

    <startargument>-Xms256m</startargument>
    <startargument>-Xmx256m</startargument>

Step 7. Run installation script

Launch windows shell (Command Prompt) as Administrator. Change directory to your ThingsBoard installation directory.

Execute install.bat script to install ThingsBoard as a Windows service (or run “install.bat –loadDemo” to install and add demo data). This means it will be automatically started on system startup. Similar, uninstall.bat will remove ThingsBoard from Windows services. The output should be similar to this one:

C:\Program Files (x86)\thingsboard>install.bat --loadDemo
Detecting Java version installed.
CurrentVersion 18
Java 1.8 found!
Installing thingsboard ...
...
ThingsBoard installed successfully!

Step 8. Start ThingsBoard service

现在开始启动ThingsBoard服务!

以管理员身份打开命令提示符并执行以下命令:

net start thingsboard

执行输出结果:

The ThingsBoard Server Application service is starting.
The ThingsBoard Server Application service was started successfully.

您可以执行以下命令重新启动ThingsBoard服务:

net stop thingsboard
net start thingsboard

启动后您将可以使用以下链接打开Web UI:

http://localhost:8080/

如果在安装脚本的执行过程中指定了-loadDemo则可以使用以下默认凭据:

  • 系统管理员: sysadmin@thingsboard.org / sysadmin
  • 租户管理员: tenant@thingsboard.org / tenant
  • 客户: customer@thingsboard.org / customer

您始终可以在帐户详情页面中更改每个帐户的密码。

如果是1-2核CPU或1-2G内存的计算机请等待90秒后启动界面。

Step 9. Install ThingsBoard Web Report Server component

Download and extract the installation package.

https://dist.thingsboard.io/tb-web-report-windows-3.1.1pe.zip

Note: We assume you have extracted ThingsBoard Web Report Server to default location: C:\Program Files (x86)\tb-web-report

Launch windows shell (Command Prompt) as Administrator. Change directory to your ThingsBoard installation directory.

Execute install.bat script to install ThingsBoard Web Report Server as a Windows service. This means it will be automatically started on system startup. Similar, uninstall.bat will remove ThingsBoard from Windows services. The output should be like:

    C:\Program Files (x86)\tb-web-report>install.bat
    Installing tb-web-report ...
    tb-web-report installed successfully!  

Now let’s start the ThingsBoard service! Open the command prompt as an Administrator and execute the following command:

net start tb-web-report

Expected output:

C:\Program Files (x86)\tb-web-report>net start tb-web-report
The Thingsboard Web Report Microservice service is starting.
The Thingsboard Web Report Microservice service was started successfully.

Troubleshooting

The log files are located in logs folder (“C:\Program Files (x86)\thingsboard\logs” in our case).

The thingsboard.log file should contain following line:

YYYY-MM-DD HH:mm:ss,sss [main] INFO  o.t.s.ThingsboardServerApplication - Started ThingsboardServerApplication in x.xxx seconds (JVM running for x.xxx)

In case of any unclear errors, use general troubleshooting guide or contact us.

Windows firewall settings

In order to have external access to ThingsBoard Web UI and device connectivity (HTTP, MQTT, CoAP) you need to create a new inbound rule with Windows Firewall with Advanced Security.

  • Open “Windows Firewall” from “Control Panel”:

image

  • Click “Advanced settings” on the left panel:

image

  • Select “Inbound Rules” on the left panel, then click “New Rule…” on the right “Actions” panel:

image

  • Now new “New Inbound Rule Wizard” window will open. On the first step “Rule Type” select “Port” option:

image

  • On the “Protocol and Ports” step select “TCP” protocol and enter port list 8080, 1883, 5683 in the “Specific local ports” field:

image

  • On the “Action” step leave “Allow the connection” option selected:

image

  • On the “Profile” step select Windows network profiles when to apply this rule:

image

  • Finally, give the name to this rule (for ex. “ThingsBoard Service Networking”) and click “Finish”.

image

Next steps

  • 入门指南 - 这些指南提供了ThingsBoard主要功能的快速概述。

  • 设备连接 - 了解如何根据您的连接方式或解决方案连接设备。

  • 数据看板 - 这些指南包含有关如何配置复杂的ThingsBoard仪表板的说明。

  • 数据处理 - 了解如何使用ThingsBoard规则引擎。

  • 数据分析 - 了解如何使用规则引擎执行基本的分析任务。

  • 硬件样品 - 了解如何将各种硬件平台连接到ThingsBoard。

  • 高级功能 - 了解高级ThingsBoard功能。

  • 开发指南 - 了解ThingsBoard中的贡献和开发。