Installing ThingsBoard PE on Ubuntu
Prerequisites
This guide describes how to install ThingsBoard on Ubuntu Server 18.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 8 (OpenJDK)
ThingsBoard服务运行在Java 8上。请按照以下说明安装OpenJDK 8。
sudo apt update
sudo apt install openjdk-8-jdk
请不要忘记将操作系统配置为默认使用OpenJDK 8。
您可以使用以下命令配置哪个版本是默认版本:
sudo update-alternatives --config java
您可以使用以下命令检查安装:
命令输出结果:
openjdk version "1.8.0_xxx"
OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (build ...)
Step 2. ThingsBoard service installation
Download installation package.
wget https://dist.thingsboard.io/thingsboard-3.1.1pe.deb
Install ThingsBoard as a service
sudo dpkg -i thingsboard-3.1.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:
sudo nano /etc/thingsboard/conf/thingsboard.conf
Locate the following configuration block:
# 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:
# 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数据库方式。
有关更多详细信息请参见相应的体系结构页面 。
将PostgreSQL用于开发和生产环境ThingsBoard团队建议负载(<5000消息/秒)。
使用托管的PostgreSQL服务器对于ThingsBoard实例而言都是一种经济高效的解决方案。
PostgreSQL安装
下面列出的说明将帮助您安装PostgreSQL。
# 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
一旦安装了PostgreSQL您可能想要创建一个新用户或为主要用户设置密码。
以下说明帮助你设置PostgreSQL用户密码
sudo su - postgres
psql
\password
\q
然后,按“Ctrl+D”返回主用户控制台并连接到数据库以创建Thingsboard DB:
psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
将“PUT_YOUR_POSTGRESQL_PASSWORD_HERE”替换postgres用户真实密码
# DB Configuration
export DATABASE_ENTITIES_TYPE=sql
export DATABASE_TS_TYPE=sql
export SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect
export SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE
export SPRING_DATASOURCE_MAXIMUM_POOL_SIZE=5
# Specify partitioning size for timestamp key-value storage. Allowed values: DAYS, MONTHS, YEARS, INDEFINITE.
export SQL_POSTGRES_TS_KV_PARTITIONING=MONTHS
|
如果生产环境超过100万个数据采集频率(>5000消息/秒)建议使用Hybrid数据库方式。
建议使用Cassandra存储时间序列数据同时将PostgreSQL用于主要实体(设备/资产/仪表板/客户)存储。
PostgreSQL安装
下面列出的说明将帮助您安装PostgreSQL。
# 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
一旦安装了PostgreSQL您可能想要创建一个新用户或为主要用户设置密码。
以下说明帮助你设置PostgreSQL用户密码
sudo su - postgres
psql
\password
\q
然后,按“Ctrl+D”返回主用户控制台并连接到数据库以创建Thingsboard DB:
psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
Cassandra配置
下面列出的说明将帮助您安装Cassandra。
# Add cassandra repository
echo 'deb http://www.apache.org/dist/cassandra/debian 311x main' | sudo tee --append /etc/apt/sources.list.d/cassandra.list > /dev/null
curl https://www.apache.org/dist/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
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
将“PUT_YOUR_POSTGRESQL_PASSWORD_HERE”替换postgres用户真实密码
# DB Configuration
export DATABASE_ENTITIES_TYPE=sql
export DATABASE_TS_TYPE=cassandra
export SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect
export SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE
export SPRING_DATASOURCE_MAXIMUM_POOL_SIZE=5
您可以选择添加以下参数来重新配置ThingsBoard实例以连接到外部Cassandra节点:
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=
|
建议已经在生产环境中使用TimescaleDB的场景使用Timescale方式。
这种情况下使用TimescaleDB Hypertable存储时间序列数据同时将PostgreSQL用于主要实体(设备/资产/仪表板/客户)存储。
PostgreSQL安装
下面列出的说明将帮助您安装PostgreSQL。
# 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
一旦安装了PostgreSQL您可能想要创建一个新用户或为主要用户设置密码。
以下说明帮助你设置PostgreSQL用户密码
sudo su - postgres
psql
\password
\q
然后,按“Ctrl+D”返回主用户控制台并连接到数据库以创建Thingsboard DB:
psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
TimescaleDB安装
请参考CentOS发行版的官方TimescaleDB安装页面并按照说明进行操作已安装PostgreSQL版本。
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置内容使用真正的postgres用户密码替换”PUT_YOUR_POSTGRESQL_PASSWORD_HERE”:
# DB Configuration
export DATABASE_ENTITIES_TYPE=sql
export DATABASE_TS_TYPE=timescale
export SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect
export SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE
export SPRING_DATASOURCE_MAXIMUM_POOL_SIZE=5
# 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
选择下面消息中间件代理服务之前的通信。
-
内存 默认队列适用于开发环境很有用请勿用于生产环境。
-
Kafka 对于本地和私有云部署可以独立于云服务供应商生产环境中使用。
-
RabbitMQ 如果没有太多负载并且已经具备一定的使用经验建议使用此方式。
-
AWS SQS 如是你打算在AWS上使用ThingsBoard则可以使用此消息队列。
-
Google发布/订阅 如果你打算在Google Cloud上部署ThingsBoard则可以使用此消息队列。
-
Azure服务总线 如果你打算在Azure上部署ThingsBoard则可以使用此消息队列。
-
Confluent云 基于Kafka的完全托管的事件流平台。
参见相应的架构页面和规则引擎页面以获取更多详细信息。
Kafka
Apache Kafka是一个开放源代码的流处理软件平台。
安装ZooKeeper
Kafka使用ZooKeeper因此你需要首先安装ZooKeeper服务器:
sudo apt-get install zookeeper
安装Kafka
wget http://www-us.apache.org/dist/kafka/2.3.0/kafka_2.12-2.3.0.tgz
tar xzf kafka_2.12-2.3.0.tgz
sudo mv kafka_2.12-2.3.0 /usr/local/kafka
设置ZooKeeper启动服务
创建一个Zookeeper系统文件:
sudo nano /etc/systemd/system/zookeeper.service
添加以下内容:
[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系统文件:
sudo nano /etc/systemd/system/kafka.service
用你系统中安装的Java环境变量替换”PUT_YOUR_JAVA_PATH”默认路径是”/usr/lib/jvm/java-1.8.0-openjdk-xxx”:
[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:
sudo systemctl start zookeeper
sudo systemctl start kafka
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置文件并将”localhost:9092”替换成真实的Kafka服务器地址:
export TB_QUEUE_TYPE=kafka
export TB_KAFKA_SERVERS=localhost:9092
|
Kafka
Apache Kafka是一个开放源代码的流处理软件平台。
安装Kafka
使用此说明在Docker容器中安装Kafka。
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置文件并将”localhost:9092”替换成真实的Kafka服务器地址:
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配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加配置文件将”YOUR_KEY”和”YOUR_SECRET”替换为真实的AWS用户凭证并将”YOUR_REGION”替换成AWS SQS帐户区域:
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.
# 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_RE_MAIN_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_MAIN_PARTITIONS=2
export TB_QUEUE_RE_HP_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_HP_PARTITIONS=1
export TB_QUEUE_RE_SQ_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_SQ_PARTITIONS=1
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
|
Google发布/订阅配置
创建一个Google云帐户并访问发布/订阅服务。
使用此说明创建一个项目并使用发布/订阅服务。
使用此说明创建服务帐户凭据并编辑角色或管理员后保存json凭据步骤9的文件此处。
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置内容使用真正用户密码替换“YOUR_PROJECT_ID”, “YOUR_SERVICE_ACCOUNT”:
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!!!
export TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_CORE_POLL_INTERVAL_MS=1000
export REMOTE_JS_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_MAIN_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_HP_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_SQ_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS=1000
# 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.
# 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_RE_MAIN_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_MAIN_PARTITIONS=2
export TB_QUEUE_RE_HP_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_HP_PARTITIONS=1
export TB_QUEUE_RE_SQ_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_SQ_PARTITIONS=1
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
|
Azure服务总线配置
创建一个Azure帐户并访问Azure服务总线。
通过使用说明了解并使用总线服务。
使用说明创建共享访问签名。
ThingsBoard配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置内容使用真正的服务总线名称空间替换”YOUR_NAMESPACE_NAME”和”YOUR_SAS_KEY_NAME”及”YOUR_SAS_KEY”:
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!!!
export TB_QUEUE_TRANSPORT_REQUEST_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_CORE_POLL_INTERVAL_MS=1000
export REMOTE_JS_RESPONSE_POLL_INTERVAL_MS=1000
export TB_QUEUE_RULE_ENGINE_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_MAIN_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_HP_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_SQ_POLL_INTERVAL_MS=1000
export TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS=1000
# 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.
# 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_RE_MAIN_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_MAIN_PARTITIONS=2
export TB_QUEUE_RE_HP_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_HP_PARTITIONS=1
export TB_QUEUE_RE_SQ_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_SQ_PARTITIONS=1
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
|
RabbitMQ安装
你可以使用官方文档安装RabbitMQ或按照以下说明:
由于RabbitMQ是用Erlang编写的因此您需要先安装Erlang才能使用RabbitMQ:
sudo apt-get install erlang
Install the rabbitmq-server package:
sudo apt-get install rabbitmq-server
启动服务:
sudo systemctl start rabbitmq-server.service
sudo systemctl enable rabbitmq-server.service
RabbitMQ会默认创建一个名为”guest”的用户密码为”guest”。
你还可以使用以下命令在RabbitMQ服务器上创建自己的管理员帐户。
请求创建的用户名和密码替换管理员的”PUT_YOUR_USER_NAME”和”PUT_YOUR_PASSWORD”:
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配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置内容使用真正的用户凭据替换”YOUR_USERNAME”和”YOUR_PASSWORD”以及”localhost”、”5672”:
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配置
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
添加下面配置内容使用真正的Confluent云服务器地址替换”CLUSTER_API_KEY”, “CLUSTER_API_SECRET”和”localhost:9092”:
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.
# 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_RE_MAIN_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_MAIN_PARTITIONS=2
export TB_QUEUE_RE_HP_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_HP_PARTITIONS=1
export TB_QUEUE_RE_SQ_POLL_INTERVAL_MS=1000
export TB_QUEUE_RE_SQ_PARTITIONS=1
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
|
Step 6. [Optional] Memory update for slow machines (1GB of RAM)
编辑ThingsBoard配置文件
sudo nano /etc/thingsboard/conf/thingsboard.conf
将以下行添加到配置文件。
# 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服务并更新数据库配置后,您可以执行以下脚本:
# --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:
sudo service thingsboard start
启动后,您将可以使用以下链接打开Web UI:
如果在安装脚本的执行过程中指定了-loadDemo则可以使用以下默认凭据:
- 系统管理员: sysadmin@thingsboard.org / sysadmin
- 租户管理员: tenant@thingsboard.org / tenant
- 客户: customer@thingsboard.org / customer
您始终可以在帐户详情页面中更改每个帐户的密码。
如果是1-2核CPU或1-2G内存的计算机请等待90秒后启动界面。
Step 9. Install ThingsBoard WebReport component
Download installation package for the Reports Server component:
wget https://dist.thingsboard.io/tb-web-report-3.1.1pe.deb
Install third-party libraries:
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:
sudo apt install fonts-roboto
Install Noto fonts (Japanese, Chinese, etc.):
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:
sudo dpkg -i tb-web-report-3.1.1pe.deb
sudo service tb-web-report start
Post-installation steps
配置HAProxy以启用HTTPS
您可能要使用HAProxy配置HTTPS访问。
如果您在云端托管ThingsBoard并为您的实例分配了有效的DNS名称,则可以这样做。
请按照此指南安装HAProxy并使用有效的SSL证书。
Troubleshooting
ThingsBoard日志存储在以下目录中:
执行如下命令检查后面是否有错误:
cat /var/log/thingsboard/thingsboard.log | grep ERROR
Next steps
-
入门指南 - 这些指南提供了ThingsBoard主要功能的快速概述。
-
设备连接 - 了解如何根据您的连接方式或解决方案连接设备。
-
数据看板 - 这些指南包含有关如何配置复杂的ThingsBoard仪表板的说明。
-
数据处理 - 了解如何使用ThingsBoard规则引擎。
-
数据分析 - 了解如何使用规则引擎执行基本的分析任务。
-
硬件样品 - 了解如何将各种硬件平台连接到ThingsBoard。
-
高级功能 - 了解高级ThingsBoard功能。
-
开发指南 - 了解ThingsBoard中的贡献和开发。