立即试用 商务报价
专业版
安装 > 本地环境 > CentOS/RHEL

本页目录

Installing ThingsBoard PE on CentOS/RHEL

Prerequisites

This guide describes how to install ThingsBoard on RHEL/CentOS 7/8. 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 1Gb of RAM. To run ThingsBoard and Cassandra on a single machine you will need at least 8Gb of RAM.

Before continue to installation execute the following commands in order to install necessary tools:

For CentOS 7:

1
2
3
4
5
# Install wget
sudo yum install -y nano wget
# Add latest EPEL release for CentOS 7
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

For CentOS 8:

1
2
3
4
5
# Install wget
sudo yum install -y nano wget
# Add latest EPEL release for CentOS 8
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

Step 1. Install Java 11 (OpenJDK)

ThingsBoard服务运行在Java 11请按照以下说明安装OpenJDK 11:

1
sudo yum install java-11-openjdk

使用以下命令设置默认版本是OpenJDK 11:

1
sudo update-alternatives --config java

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

1
java -version

命令输出结果:

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

Step 2. ThingsBoard service installation

Download installation package.

1
wget https://dist.thingsboard.io/thingsboard-3.5.1pe.rpm

Install ThingsBoard as a service

1
sudo rpm -Uvh thingsboard-3.5.1pe.rpm

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 file for editing using the following command:

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

Locate the following configuration block:

1
2
3
# License secret obtained from ThingsBoard License Portal (https://license.thingsboard.io)
# UNCOMMENT NEXT LINE AND PUT YOUR LICENSE SECRET:
# export TB_LICENSE_SECRET=

and put your license secret. Please don’t forget to uncomment the export statement. See example below:

1
2
3
# License secret obtained from ThingsBoard License Portal (https://license.thingsboard.io)
# UNCOMMENT NEXT LINE AND PUT YOUR LICENSE SECRET:
export TB_LICENSE_SECRET=YOUR_LICENSE_SECRET_HERE

Step 4. Configure ThingsBoard database

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

ThingsBoard团队建议将PostgreSQL用于负载(<5000消息/秒)的开发和生产环境,使用公有云托管的PostgreSQL数据库服务对于某些ThingsBoard实例而言是一种经济高效的方式。

PostgreSQL安装

Instructions listed below will help you to install PostgreSQL.

1
2
# Update your system
sudo yum update

For CentOS 7:

1
2
3
4
5
6
7
8
9
10
11
12
# Install the repository RPM (for CentOS 7):
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo yum -y install epel-release yum-utils
sudo yum-config-manager --enable pgdg12
sudo yum install postgresql12-server postgresql12
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-12

For CentOS 8:

1
2
3
4
5
6
7
8
9
10
11
# Install the repository RPM (for CentOS 8):
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo dnf -qy module disable postgresql
sudo dnf -y install postgresql12 postgresql12-server
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-12

创建一个新用户或为主用户设置密码

1
2
3
4
sudo su - postgres
psql
\password
\q

Then, press “Ctrl+D” to return to main user console.

After configuring the password, edit the pg_hba.conf to use MD5 authentication with the postgres user.

Edit pg_hba.conf file:

1
2
sudo nano /var/lib/pgsql/12/data/pg_hba.conf

Locate the following lines:

1
2
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident

Replace ident with md5:

1
host    all             all             127.0.0.1/32            md5

Finally, you should restart the PostgreSQL service to initialize the new configuration:

1
2
sudo systemctl restart postgresql-12.service

Connect to the database to create thingsboard DB:

1
2
psql -U postgres -d postgres -h 127.0.0.1 -W

Execute create database statement

1
2
3
CREATE DATABASE thingsboard;
\q

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

将下面内容添加到配置文件中并替换“PUT_YOUR_POSTGRESQL_PASSWORD_HERE”为postgres帐户密码

1
2
3
4
5
6
7
# DB Configuration 
export DATABASE_TS_TYPE=sql
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE
# Specify partitioning size for timestamp key-value storage. Allowed values: DAYS, MONTHS, YEARS, INDEFINITE.
export SQL_POSTGRES_TS_KV_PARTITIONING=MONTHS

ThingsBoard team recommends to use Hybrid database approach if you do plan to have 1M+ devices in production or high data ingestion rate (> 5000 msg/sec). In this case, ThingsBoard will be storing timeseries data in Cassandra while continue to use PostgreSQL for main entities (devices/assets/dashboards/customers).

PostgreSQL Installation

Instructions listed below will help you to install PostgreSQL.

1
2
# Update your system
sudo yum update

For CentOS 7:

1
2
3
4
5
6
7
8
9
10
11
12
# Install the repository RPM (for CentOS 7):
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo yum -y install epel-release yum-utils
sudo yum-config-manager --enable pgdg12
sudo yum install postgresql12-server postgresql12
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-12

For CentOS 8:

1
2
3
4
5
6
7
8
9
10
11
# Install the repository RPM (for CentOS 8):
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo dnf -qy module disable postgresql
sudo dnf -y install postgresql12 postgresql12-server
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-12

创建一个新用户或为主用户设置密码

1
2
3
4
sudo su - postgres
psql
\password
\q

Then, press “Ctrl+D” to return to main user console.

After configuring the password, edit the pg_hba.conf to use MD5 authentication with the postgres user.

Edit pg_hba.conf file:

1
2
sudo nano /var/lib/pgsql/12/data/pg_hba.conf

Locate the following lines:

1
2
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident

Replace ident with md5:

1
host    all             all             127.0.0.1/32            md5

Finally, you should restart the PostgreSQL service to initialize the new configuration:

1
2
sudo systemctl restart postgresql-12.service

Connect to the database to create thingsboard DB:

1
2
psql -U postgres -d postgres -h 127.0.0.1 -W

Execute create database statement

1
2
3
CREATE DATABASE thingsboard;
\q

Cassandra Installation

Cassandra安装说明

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Add cassandra repository
sudo touch /etc/yum.repos.d/cassandra.repo
echo '[cassandra]' | sudo tee --append /etc/yum.repos.d/cassandra.repo > /dev/null
echo 'name=Apache Cassandra' | sudo tee --append /etc/yum.repos.d/cassandra.repo > /dev/null
echo 'baseurl=https://downloads.apache.org/cassandra/redhat/40x/' | sudo tee --append /etc/yum.repos.d/cassandra.repo > /dev/null
echo 'gpgcheck=1' | sudo tee --append /etc/yum.repos.d/cassandra.repo > /dev/null
echo 'repo_gpgcheck=1' | sudo tee --append /etc/yum.repos.d/cassandra.repo > /dev/null
echo 'gpgkey=https://downloads.apache.org/cassandra/KEYS' | sudo tee --append /etc/yum.repos.d/cassandra.repo > /dev/null

# Cassandra installation
sudo yum install cassandra
# Tools installation
sudo yum install cassandra-tools
# Start Cassandra
sudo service cassandra start
# Configure the database to start automatically when OS starts.
sudo chkconfig cassandra on

可以使用Astra DB云代替自己安装的Cassandra了解如何将ThingsBoard连接到Astra DB

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

将以下行添加到配置文件 Don’t forget to replace “PUT_YOUR_POSTGRESQL_PASSWORD_HERE” with your real postgres user password:

1
2
3
4
5
# DB Configuration 
export DATABASE_TS_TYPE=cassandra
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE

You can optionally add the following parameters to reconfigure your ThingsBoard instance to connect to external Cassandra nodes:

1
2
3
4
5
6
export CASSANDRA_CLUSTER_NAME=Thingsboard Cluster
export CASSANDRA_KEYSPACE_NAME=thingsboard
export CASSANDRA_URL=127.0.0.1:9042
export CASSANDRA_USE_CREDENTIALS=false
export CASSANDRA_USERNAME=
export CASSANDRA_PASSWORD=

ThingsBoard团队建议具有在生产环境使用TimescaleDB经验的公司使用Timescale数据库把时间序列数据存储在TimescaleDB Hypertable中并将PostgreSQL用于主要实体(设备/资产/仪表板/客户)。

PostgreSQL安装

Instructions listed below will help you to install PostgreSQL.

1
2
# Update your system
sudo yum update

For CentOS 7:

1
2
3
4
5
6
7
8
9
10
11
12
# Install the repository RPM (for CentOS 7):
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo yum -y install epel-release yum-utils
sudo yum-config-manager --enable pgdg12
sudo yum install postgresql12-server postgresql12
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-12

For CentOS 8:

1
2
3
4
5
6
7
8
9
10
11
# Install the repository RPM (for CentOS 8):
sudo yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo dnf -qy module disable postgresql
sudo dnf -y install postgresql12 postgresql12-server
# Initialize your PostgreSQL DB
sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
sudo systemctl start postgresql-12
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-12

创建一个新用户或为主用户设置密码

1
2
3
4
sudo su - postgres
psql
\password
\q

Then, press “Ctrl+D” to return to main user console.

After configuring the password, edit the pg_hba.conf to use MD5 authentication with the postgres user.

Edit pg_hba.conf file:

1
2
sudo nano /var/lib/pgsql/12/data/pg_hba.conf

Locate the following lines:

1
2
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident

Replace ident with md5:

1
host    all             all             127.0.0.1/32            md5

Finally, you should restart the PostgreSQL service to initialize the new configuration:

1
2
sudo systemctl restart postgresql-12.service

Connect to the database to create thingsboard DB:

1
2
psql -U postgres -d postgres -h 127.0.0.1 -W

Execute create database statement

1
2
3
CREATE DATABASE thingsboard;
\q

TimescaleDB安装

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

软件包安装后需要在ThingsBoard数据库中创建TimescaleDB扩展:

1
2
3
4
5
sudo su - postgres
psql -d thingsboard
CREATE EXTENSION IF NOT EXISTS timescaledb;
\q
#Then, press “Ctrl+D” to return to main user console.
ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

将下面内容添加到配置文件中并替换“PUT_YOUR_POSTGRESQL_PASSWORD_HERE”为postgres帐户密码

1
2
3
4
5
6
7
# DB Configuration 
export DATABASE_TS_TYPE=timescale
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE
# Specify Interval size for data chunks storage. Please note that this value can be set only once.
export SQL_TIMESCALE_CHUNK_TIME_INTERVAL=604800000 # Number of miliseconds. The current value corresponds to one week.

Step 5. Choose ThingsBoard queue service

ThingsBoard使用消息系统存储服务之间的通信,请正确选择队列?

  • 内存 适用于开发环境(开发)

  • Kafka 适用于生产环境(集群)

  • RabbitMQ 适用生产环境(单体)

  • AWS SQS 适用生产环境(AWS公有云)

  • Google发布/订阅 适用生产环境(Google公有云)

  • Azure服务总线 适用生产环境(Azure公有云)

  • Confluent云 适用于生产环境(托管)

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

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

Kafka安装

Apache Kafka是一个开源的流式数据处理平台。

Kafka安装

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

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

添加下面配置并将”localhost:9092”替换成真实的Kafka服务器地址:

1
2
export TB_QUEUE_TYPE=kafka
export TB_KAFKA_SERVERS=localhost:9092

AWS SQS配置

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

使用此说明创建AWS SQS服务凭证。

  • Access key ID
  • Secret access key
ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

添加配置将”YOUR_KEY”和”YOUR_SECRET”替换为真实的AWS用户凭证并将”YOUR_REGION”替换成AWS SQS帐户区域:

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
export TB_QUEUE_TYPE=aws-sqs
export TB_QUEUE_AWS_SQS_ACCESS_KEY_ID=YOUR_KEY
export TB_QUEUE_AWS_SQS_SECRET_ACCESS_KEY=YOUR_SECRET
export 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 is 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.
# By UI set the parameters - interval (1000) and partitions (1) for Rule Engine queues.
# Sample parameters to fit into 10 requests per second on a "monolith" deployment: 

export TB_QUEUE_CORE_POLL_INTERVAL_MS=1000
export TB_QUEUE_CORE_PARTITIONS=2
export TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS=1000
export TB_QUEUE_VC_INTERVAL_MS=1000
export TB_QUEUE_VC_PARTITIONS=1

可以使用UI更新默认规则引擎队列配置(轮询间隔和分区)有关ThingsBoard规则引擎队列的更多信息请参阅文档

Google发布/订阅配置

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

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

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

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

添加下面配置内容使用真正用户密码替换“YOUR_PROJECT_ID”, “YOUR_SERVICE_ACCOUNT”:

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
export TB_QUEUE_TYPE=pubsub
export TB_QUEUE_PUBSUB_PROJECT_ID=YOUR_PROJECT_ID
export TB_QUEUE_PUBSUB_SERVICE_ACCOUNT=YOUR_SERVICE_ACCOUNT

# These params affect the number of requests per second from each partitions per each queue.
# Number of requests to particular Message Queue is 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.
# By UI set the parameters - interval (1000) and partitions (1) for Rule Engine queues.
# Sample parameters to fit into 10 requests per second on a "monolith" deployment: 

export TB_QUEUE_CORE_POLL_INTERVAL_MS=1000
export TB_QUEUE_CORE_PARTITIONS=2
export TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS=1000
export TB_QUEUE_VC_INTERVAL_MS=1000
export TB_QUEUE_VC_PARTITIONS=1

可以使用UI更新默认规则引擎队列配置(轮询间隔和分区)有关ThingsBoard规则引擎队列的更多信息请参阅文档

Azure服务总线配置

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

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

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

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

添加下面配置内容使用真正的服务总线名称空间替换”YOUR_NAMESPACE_NAME”和”YOUR_SAS_KEY_NAME”及”YOUR_SAS_KEY”:

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
export TB_QUEUE_TYPE=service-bus
export TB_QUEUE_SERVICE_BUS_NAMESPACE_NAME=YOUR_NAMESPACE_NAME
export TB_QUEUE_SERVICE_BUS_SAS_KEY_NAME=YOUR_SAS_KEY_NAME
export TB_QUEUE_SERVICE_BUS_SAS_KEY=YOUR_SAS_KEY

# These params affect the number of requests per second from each partitions per each queue.
# Number of requests to particular Message Queue is 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.
# By UI set the parameters - interval (1000) and partitions (1) for Rule Engine queues.
# Sample parameters to fit into 10 requests per second on a "monolith" deployment: 

export TB_QUEUE_CORE_POLL_INTERVAL_MS=1000
export TB_QUEUE_CORE_PARTITIONS=2
export TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS=1000
export TB_QUEUE_VC_INTERVAL_MS=1000
export TB_QUEUE_VC_PARTITIONS=1

可以使用UI更新默认规则引擎队列配置(轮询间隔和分区)有关ThingsBoard规则引擎队列的更多信息请参阅文档

RabbitMQ安装

你可以使用官方文档安装RabbitMQ或按照以下说明:

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

将以下行添加到配置文件将“YOUR_USERNAME”和“YOUR_PASSWORD”替换为真实的信息将“localhost”和“5672”替换为真实的RabbitMQ主机和端口

1
2
3
4
5
export TB_QUEUE_TYPE=rabbitmq
export TB_QUEUE_RABBIT_MQ_USERNAME=YOUR_USERNAME
export TB_QUEUE_RABBIT_MQ_PASSWORD=YOUR_PASSWORD
export TB_QUEUE_RABBIT_MQ_HOST=localhost
export TB_QUEUE_RABBIT_MQ_PORT=5672

Confluent配置

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

ThingsBoard配置

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

添加下面配置内容使用真正的Confluent云服务器地址替换”CLUSTER_API_KEY”, “CLUSTER_API_SECRET”和”localhost:9092”:

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
export TB_QUEUE_TYPE=kafka
export TB_QUEUE_KAFKA_USE_CONFLUENT_CLOUD=true
export TB_KAFKA_SERVERS=localhost:9092
export TB_QUEUE_KAFKA_REPLICATION_FACTOR=3
export TB_QUEUE_KAFKA_CONFLUENT_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="CLUSTER_API_KEY" password="CLUSTER_API_SECRET";}

# These params affect the number of requests per second from each partitions per each queue.
# Number of requests to particular Message Queue is 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.
# By UI set the parameters - interval (1000) and partitions (1) for Rule Engine queues.
# Sample parameters to fit into 10 requests per second on a "monolith" deployment: 

export TB_QUEUE_CORE_POLL_INTERVAL_MS=1000
export TB_QUEUE_CORE_PARTITIONS=2
export TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS=1000
export TB_QUEUE_VC_INTERVAL_MS=1000
export TB_QUEUE_VC_PARTITIONS=1

可以使用UI更新默认规则引擎队列配置(轮询间隔和分区)有关ThingsBoard规则引擎队列的更多信息请参阅文档

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

编辑配置文件

1
sudo nano /etc/thingsboard/conf/thingsboard.conf

将以下行添加到配置文件

1
2
# Update ThingsBoard memory usage and restrict it to 256MB in /etc/thingsboard/conf/thingsboard.conf
export JAVA_OPTS="$JAVA_OPTS -Xms256M -Xmx256M"

Step 7. Run installation script

执行以下脚本安装ThingsBoard服务并初始化演示数据:

1
2
# --loadDemo option will load demo data: users, devices, assets, rules, widgets.
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo

Step 8. Start ThingsBoard service

ThingsBoard UI is accessible on 8080 port by default. Make sure that your 8080 port is accessible via firewall. In order to open 8080 port execute the following command:

1
2
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent
sudo firewall-cmd --reload

执行以下命令以启动ThingsBoard:

1
sudo service thingsboard start

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

1
http://localhost:8080/

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

  • System Administrator: sysadmin@thingsboard.org / sysadmin
  • Tenant Administrator: tenant@thingsboard.org / tenant
  • Customer User: customer@thingsboard.org / customer

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

Please allow up to 90 seconds for the Web UI to start. This is applicable only for slow machines with 1-2 CPUs or 1-2 GB RAM.

Step 9. Install ThingsBoard WebReport component

Download installation package for the Reports Server component:

1
wget https://dist.thingsboard.io/tb-web-report-3.5.1pe.rpm

Install third-party libraries:

1
2
3
4
sudo yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 \
     libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 \
     alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi \
     xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc unzip nss -y

Install Roboto fonts:

1
sudo yum install google-roboto-fonts -y

Install Noto fonts (Japanese, Chinese, etc.):

1
2
3
4
5
6
7
8
9
10
mkdir ~/noto
cd ~/noto
wget https://noto-website.storage.googleapis.com/pkgs/NotoSansCJKjp-hinted.zip
unzip NotoSansCJKjp-hinted.zip
sudo mkdir -p /usr/share/fonts/noto
sudo cp *.otf /usr/share/fonts/noto
sudo chmod 655 -R /usr/share/fonts/noto/
sudo fc-cache -fv
cd ..
rm -rf ~/noto

Install and start Web Report service:

1
2
sudo rpm -Uvh tb-web-report-3.5.1pe.rpm
sudo service tb-web-report start

Post-installation steps

配置HAProxy启用HTTPS

可能要使用HAProxy配置HTTPS访问。
如果在云端托管ThingsBoard并为实例分配了有效的DNS名称则这样做。
请按照此指南安装HAProxy并使用有效的SSL证书。

Troubleshooting

ThingsBoard日志存储在以下目录中:

1
/var/log/thingsboard

执行如下命令检查后面是否有错误:

1
cat /var/log/thingsboard/thingsboard.log | grep ERROR

Next steps

  • 入门指南 - 快速学习ThingsBoard相关功能。

  • 连接设备 - 学习如何根据你的连接方式或解决方案连接设备。

  • 可 视 化 - 学习如何配置复杂的ThingsBoard仪表板说明。

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

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

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

  • 高级功能 - 学习高级ThingsBoard功能。

  • 开发指南 - 学习ThingsBoard中的贡献和开发。