Prerequisites
This guide describes how to install ThingsBoard on Ubuntu 18.04 LTS / Ubuntu 20.04 LTS.
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.
Step 1. Install Java 11 (OpenJDK)
ThingsBoard服务运行在Java 11请按照以下说明安装OpenJDK 11:
1
2
| sudo apt update
sudo apt install openjdk-11-jdk
|
使用以下命令设置默认版本是OpenJDK 11:
1
| sudo update-alternatives --config java
|
可以使用以下命令检查安装:
命令输出结果:
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.deb
|
Install ThingsBoard as a service
1
| sudo dpkg -i thingsboard-3.5.1pe.deb
|
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
|
ThingsBoard能够使用SQL或hybrid数据库方式。
有关更多详细信息请参见相应的体系结构页面 。
ThingsBoard团队建议将PostgreSQL用于负载(<5000消息/秒)的开发和生产环境,使用公有云托管的PostgreSQL数据库服务对于某些ThingsBoard实例而言是一种经济高效的方式。
PostgreSQL安装
PostgreSQL安装说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # install **wget** if not already installed:
sudo apt install -y wget
# import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# add repository contents to your system:
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
# install and launch the postgresql service:
sudo apt update
sudo apt -y install postgresql-12
sudo service postgresql start
|
创建一个新用户或为主用户设置密码
1
2
3
4
| sudo su - postgres
psql
\password
\q
|
按“Ctrl+D”返回控制台并连接到数据库创建ThingsBoard数据库:
1
2
3
| psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
|
PostgreSQL配置
编辑配置文件
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团队建议使用混合数据库的方式在你的生产中使用1M+设备或高频数据采集(>5000消息/秒)使用Cassandra存储时间序列数据而PostgreSQL用于主要实体(设备/资产/仪表板/客户)。
PostgreSQL安装
PostgreSQL安装说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # install **wget** if not already installed:
sudo apt install -y wget
# import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# add repository contents to your system:
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
# install and launch the postgresql service:
sudo apt update
sudo apt -y install postgresql-12
sudo service postgresql start
|
创建一个新用户或为主用户设置密码
1
2
3
4
| sudo su - postgres
psql
\password
\q
|
按“Ctrl+D”返回控制台并连接到数据库创建ThingsBoard数据库:
1
2
3
| psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
|
Cassandra安装
Cassandra安装说明
1
2
3
4
5
6
7
8
| # Add cassandra repository
echo "deb http://downloads.apache.org/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add -
sudo apt-get update
## Cassandra installation
sudo apt-get install cassandra
## Tools installation
sudo apt-get install cassandra-tools
|
可以使用Astra DB云代替自己安装的Cassandra
See how to connect ThingsBoard to Astra DB
ThingsBoard配置
编辑配置文件
1
| sudo nano /etc/thingsboard/conf/thingsboard.conf
|
将下面内容添加到配置文件中并替换“PUT_YOUR_POSTGRESQL_PASSWORD_HERE”为postgres帐户密码:
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
|
将下面内容添加到配置文件中连接到Cassandra:
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安装
PostgreSQL安装说明
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| # install **wget** if not already installed:
sudo apt install -y wget
# import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# add repository contents to your system:
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
# install and launch the postgresql service:
sudo apt update
sudo apt -y install postgresql-12
sudo service postgresql start
|
创建一个新用户或为主用户设置密码
1
2
3
4
| sudo su - postgres
psql
\password
\q
|
按“Ctrl+D”返回控制台并连接到数据库创建ThingsBoard数据库:
1
2
3
| psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
|
TimescaleDB安装
请参考Ubuntu发行版上的官方TimescaleDB安装页面并根据安装的PostgreSQL版本按照说明进行操作。
软件包安装后需要在ThingsBoard数据库中创建TimescaleDB扩展:
1
2
3
| psql -U postgres -h localhost -d thingsboard
CREATE EXTENSION IF NOT EXISTS timescaledb;
\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=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安装
Apache Kafka是一个开源的流式数据处理平台。
ZooKeeper安装
Kafka基于ZooKeeper运行需要先安装 ZooKeeper 服务:
1
| sudo apt-get install zookeeper
|
Kafka安装
1
2
3
4
5
| wget https://archive.apache.org/dist/kafka/2.6.0/kafka_2.13-2.6.0.tgz
tar xzf kafka_2.13-2.6.0.tgz
sudo mv kafka_2.13-2.6.0 /usr/local/kafka
|
设置ZooKeeper启动服务
创建一个Zookeeper系统文件:
1
| sudo nano /etc/systemd/system/zookeeper.service
|
Add below contnet:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| [Unit]
Description=Apache Zookeeper server
Documentation=http://zookeeper.apache.org
Requires=network.target remote-fs.target
After=network.target remote-fs.target
[Service]
Type=simple
ExecStart=/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
ExecStop=/usr/local/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
|
设置Kafka启动服务
创建一个Kafka系统文件:
1
| sudo nano /etc/systemd/system/kafka.service
|
添加以下内容替换系统的“PUT_YOUR_JAVA_PATH”为实际的JAVA_HOME路径默认路径是“/usr/lib/jvm/java-11-openjdk-xxx”:
1
2
3
4
5
6
7
8
9
10
11
12
13
| [Unit]
Description=Apache Kafka Server
Documentation=http://kafka.apache.org/documentation.html
Requires=zookeeper.service
[Service]
Type=simple
Environment="JAVA_HOME=PUT_YOUR_JAVA_PATH"
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh
[Install]
WantedBy=multi-user.target
|
启动 ZooKeeper 和 Kafka:
1
2
3
| sudo systemctl start zookeeper
sudo systemctl start 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
|
|
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或按照以下说明:
由于RabbitMQ是用Erlang编写的因此需要先安装Erlang才能使用RabbitMQ:
1
| sudo apt-get install erlang
|
安装rabbitmq:
1
| sudo apt-get install rabbitmq-server
|
启动服务
1
2
| sudo systemctl start rabbitmq-server.service
sudo systemctl enable rabbitmq-server.service
|
RabbitMQ会默认创建一个名为”guest”的用户密码为”guest”。
你还可以使用以下命令在RabbitMQ服务器上创建自己的管理员帐户。
替换对应用户名和密码“PUT_YOUR_USER_NAME”和”PUT_YOUR_PASSWORD”:
1
2
3
| sudo rabbitmqctl add_user PUT_YOUR_USER_NAME PUT_YOUR_PASSWORD
sudo rabbitmqctl set_user_tags PUT_YOUR_USER_NAME administrator
sudo rabbitmqctl set_permissions -p / PUT_YOUR_USER_NAME ".*" ".*" ".*"
|
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:
1
| sudo service thingsboard start
|
启动后使用以下链接打开Web UI:
如果在安装脚本的执行过程中指定了-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.deb
|
Install third-party libraries:
1
2
3
4
5
| sudo apt install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils unzip wget libgbm-dev
|
Install Roboto fonts:
1
| sudo apt install fonts-roboto
|
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 dpkg -i tb-web-report-3.5.1pe.deb
sudo service tb-web-report start
|
Post-installation steps
配置HAProxy启用HTTPS
可能要使用HAProxy配置HTTPS访问。
如果在云端托管ThingsBoard并为实例分配了有效的DNS名称则这样做。
请按照此指南安装HAProxy并使用密钥生成的有效SSL证书。
Troubleshooting
ThingsBoard日志存储在以下目录中:
执行如下命令检查后面是否有错误:
1
| cat /var/log/thingsboard/thingsboard.log | grep ERROR
|
Next steps
-
入门指南 - 快速学习ThingsBoard相关功能。
-
连接设备 - 学习如何根据你的连接方式或解决方案连接设备。
-
可 视 化 - 学习如何配置复杂的ThingsBoard仪表板说明。
-
数据处理 - 学习如何使用ThingsBoard规则引擎。
-
数据分析 - 学习如何使用规则引擎执行基本的分析任务。
-
硬件样品 - 学习如何将各种硬件平台连接到ThingsBoard。
-
高级功能 - 学习高级ThingsBoard功能。
-
开发指南 - 学习ThingsBoard中的贡献和开发。