- Prerequisites
- Step 1. Install Java 17 (OpenJDK)
- Step 2. ThingsBoard service installation
- Step 3. Obtain and configure license key
- Step 4. Configure ThingsBoard database
- Step 5. Choose ThingsBoard queue service
- Step 6. [Optional] Memory update for slow machines (4GB of RAM)
- Step 7. Run installation script
- Step 8. Start ThingsBoard service
- Step 9. Install ThingsBoard WebReport component
- Post-installation steps
- Troubleshooting
- Next steps
Prerequisites
This guide describes how to install ThingsBoard on Ubuntu 20.04 LTS / 22.04 LTS / 24.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 4Gb of RAM. To run ThingsBoard and Cassandra on a single machine you will need at least 8Gb of RAM.
Step 1. Install Java 17 (OpenJDK)
ThingsBoard service is running on Java 17. Follow this instructions to install OpenJDK 17:
1
2
sudo apt update
sudo apt install openjdk-17-jdk
Please don’t forget to configure your operating system to use OpenJDK 17 by default. You can configure which version is the default using the following command:
1
sudo update-alternatives --config java
You can check the installation using the following command:
1
java -version
Expected command output is:
1
2
3
openjdk version "17.x.xx"
OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (...)
Step 2. ThingsBoard service installation
Download installation package.
1
wget https://dist.thingsboard.io/thingsboard-3.8.1pe.deb
Install ThingsBoard as a service
1
sudo dpkg -i thingsboard-3.8.1pe.deb
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 is able to use SQL or hybrid database approach. See corresponding architecture page for more details.
PostgreSQL InstallationInstructions listed below will help you to install PostgreSQL.
Once PostgreSQL is installed you may want to create a new user or set the password for the main user. The instructions below will help to set the password for main PostgreSQL user. To switch your current user context to the postgres user, execute the following script:
To be able to interact with the PostgreSQL database, enter:
You will connect to the database as the main PostgreSQL user. To set the password, enter the following command after postgres=# :
Enter and confirm the password. Then, press “Ctrl+D” to return to main user console. Then, connect to the “postgres” database as the “postgres” user:
Create the ThingsBoard database named “thingsboard” :
Press “Ctrl+D” twice to exit PostgreSQL. ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “PUT_YOUR_POSTGRESQL_PASSWORD_HERE” with your real postgres user password:
|
PostgreSQL InstallationInstructions listed below will help you to install PostgreSQL.
Once PostgreSQL is installed you may want to create a new user or set the password for the main user. The instructions below will help to set the password for main PostgreSQL user. To switch your current user context to the postgres user, execute the following script:
To be able to interact with the PostgreSQL database, enter:
You will connect to the database as the main PostgreSQL user. To set the password, enter the following command after postgres=# :
Enter and confirm the password. Then, press “Ctrl+D” to return to main user console. Then, connect to the “postgres” database as the “postgres” user:
Create the ThingsBoard database named “thingsboard” :
Press “Ctrl+D” twice to exit PostgreSQL. Cassandra InstallationInstructions listed below will help you to install Cassandra.
In order to run Cassandra, you will need to install Java 11. Install the package.
Set Java 17 as the default version (required for ThingsBoard).
Edit Cassandra config.
Find the following line.
And replace it as follows:
Then, restart Cassandra.
You can use Astra DB cloud instead installing your own Cassandra. See how to connect ThingsBoard to Astra DB ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “PUT_YOUR_POSTGRESQL_PASSWORD_HERE” with your real postgres user password:
You can optionally add the following parameters to reconfigure your ThingsBoard instance to connect to external Cassandra nodes:
|
Step 5. Choose ThingsBoard queue service
ThingsBoard is able to use various messaging systems/brokers for storing the messages and communication between ThingsBoard services. How to choose the right queue implementation?
-
In Memory queue implementation is built-in and default. It is useful for development(PoC) environments and is not suitable for production deployments or any sort of cluster deployments.
-
Kafka is recommended for production deployments. This queue is used on the most of ThingsBoard production environments now. It is useful for both on-prem and private cloud deployments. It is also useful if you like to stay independent from your cloud provider. However, some providers also have managed services for Kafka. See AWS MSK for example.
-
RabbitMQ is recommended if you don’t have much load and you already have experience with this messaging system.
-
AWS SQS is a fully managed message queuing service from AWS. Useful if you plan to deploy ThingsBoard on AWS.
-
Google Pub/Sub is a fully managed message queuing service from Google. Useful if you plan to deploy ThingsBoard on Google Cloud.
-
Azure Service Bus is a fully managed message queuing service from Azure. Useful if you plan to deploy ThingsBoard on Azure.
-
Confluent Cloud is a fully managed streaming platform based on Kafka. Useful for a cloud agnostic deployments.
See corresponding architecture page and rule engine page for more details.
In Memory queue is built-in and enabled by default. No additional configuration steps required. |
Kafka InstallationApache Kafka is an open-source stream-processing software platform. Install ZooKeeperKafka uses ZooKeeper so you need to first install ZooKeeper server:
Setup ZooKeeper Systemd Unit fileCreate systemd unit file for Zookeeper:
Add below content:
Enable and start ZooKeeper:
Install Kafka
Setup Kafka Systemd Unit fileCreate systemd unit file for Kafka:
Add the below content. Make sure to replace “PUT_YOUR_JAVA_PATH” with your real JAVA_HOME path as per the Java installed on your system, by default like “/usr/lib/jvm/java-11-openjdk-xxx”:
Enable and start Kafka:
ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following line to the configuration file. Don’t forget to replace “localhost:9092” with your real Kafka bootstrap servers:
|
Kafka InstallationApache Kafka is an open-source stream-processing software platform. Install KafkaUse the instructions below for installing Kafka in a Docker container.
Add the following lines to the docker-compose-kafka.yml file:
Start the container:
ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following line to the configuration file. Don’t forget to replace “localhost:9092” with your real Kafka bootstrap servers:
|
AWS SQS ConfigurationTo access AWS SQS service, you first need to create an AWS account. To work with AWS SQS service you will need to create your next credentials using this instruction:
ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “YOUR_KEY”, “YOUR_SECRET” with your real AWS SQS IAM user credentials and “YOUR_REGION” with your real AWS SQS account region:
You can update default Rule Engine queues configuration (poll interval and partitions) using UI. More about ThingsBoard Rule Engine queues see in documentation. |
Google Pub/Sub ConfigurationTo access Pub/Sub service, you first need to create an Google cloud account. To work with Pub/Sub service you will need to create a project using this instruction. Create service account credentials with the role “Editor” or “Admin” using this instruction, and save json file with your service account credentials step 9 here. ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “YOUR_PROJECT_ID”, “YOUR_SERVICE_ACCOUNT” with your real Pub/Sub project id, and service account (it is whole data from json file):
You can update default Rule Engine queues configuration (poll interval and partitions) using UI. More about ThingsBoard Rule Engine queues see in documentation. |
Azure Service Bus ConfigurationTo access Azure Service Bus, you first need to create an Azure account. To work with Service Bus service you will need to create a Service Bus Namespace using this instruction. Create Shared Access Signature using this instruction. ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “YOUR_NAMESPACE_NAME” with your real Service Bus namespace name, and “YOUR_SAS_KEY_NAME”, “YOUR_SAS_KEY” with your real Service Bus credentials. Note: “YOUR_SAS_KEY_NAME” it is “SAS Policy”, “YOUR_SAS_KEY” it is “SAS Policy Primary Key”:
You can update default Rule Engine queues configuration (poll interval and partitions) using UI. More about ThingsBoard Rule Engine queues see in documentation. |
RabbitMQ InstallationFor installation RabbitMQ you can use official docs, or our instruction bellow: Since RabbitMQ is written in Erlang, you need to install Erlang before you can use RabbitMQ:
Install the rabbitmq-server package:
Start the Server:
By default, RabbitMQ creates a user named “guest” with a password “guest”. You can also create your own administrator account on RabbitMQ server using following commands. Don’t forget to replace “PUT_YOUR_USER_NAME” like: “admin” and “PUT_YOUR_PASSWORD” with your own user name and password:
ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “YOUR_USERNAME” and “YOUR_PASSWORD” with your real user credentials, “localhost” and “5672” with your real RabbitMQ host and port:
|
Confluent Cloud ConfigurationTo access Confluent Cloud you should first create an account, then create a Kafka cluster and get your API Key. ThingsBoard ConfigurationEdit ThingsBoard configuration file
Add the following lines to the configuration file. Don’t forget to replace “CLUSTER_API_KEY”, “CLUSTER_API_SECRET” and “localhost:9092” with your real Confluent Cloud bootstrap servers:**
You can update default Rule Engine queues configuration using UI. More about ThingsBoard Rule Engine queues see in documentation. |
Step 6. [Optional] Memory update for slow machines (4GB of RAM)
Edit ThingsBoard configuration file
1
sudo nano /etc/thingsboard/conf/thingsboard.conf
Add the following lines to the configuration file.
1
2
# Update ThingsBoard memory usage and restrict it to 2G in /etc/thingsboard/conf/thingsboard.conf
export JAVA_OPTS="$JAVA_OPTS -Xms2G -Xmx2G"
We recommend adjusting these parameters depending on your server resources. It should be set to at least 2G (gigabytes), and increased accordingly if there is additional RAM space available. Usually, you need to set it to 1/2 of your total RAM if you do not run any other memory-intensive processes (e.g. Cassandra), or to 1/3 otherwise.
Step 7. Run installation script
Once ThingsBoard service is installed and DB configuration is updated, you can execute the following script:
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
Execute the following command to start ThingsBoard:
1
sudo service thingsboard start
Once started, you will be able to open Web UI using the following link:
1
http://localhost:8080/
The following default credentials are available if you have specified –loadDemo during execution of the installation script:
- System Administrator: [email protected] / sysadmin
- Tenant Administrator: [email protected] / tenant
- Customer User: [email protected] / customer
You can always change passwords for each account in account profile page.
Step 9. Install ThingsBoard WebReport component
PrerequisitesInstall Docker for Ubuntu. Create docker compose file
Create .env file for tb-web-report container
Start WebReport service in docker
Troubleshoot containerRead logs from the container
|
Download installation package for the Reports Server component:
Install third-party libraries:
Install Roboto fonts:
Install Noto fonts (Japanese, Chinese, etc.):
Install and start Web Report service:
|
Post-installation steps
Configure HAProxy to enable HTTPS
You may want to configure HTTPS access using HAProxy. This is possible in case you are hosting ThingsBoard in the cloud and have a valid DNS name assigned to your instance. Please follow this guide to install HAProxy and generate valid SSL certificate using Let’s Encrypt.
Troubleshooting
ThingsBoard logs are stored in the following directory:
1
/var/log/thingsboard
You can issue the following command in order to check if there are any errors on the backend side:
1
cat /var/log/thingsboard/thingsboard.log | grep ERROR
Next steps
-
Getting started guides - These guides provide quick overview of main ThingsBoard features. Designed to be completed in 15-30 minutes.
-
Connect your device - Learn how to connect devices based on your connectivity technology or solution.
-
Data visualization - These guides contain instructions on how to configure complex ThingsBoard dashboards.
-
Data processing & actions - Learn how to use ThingsBoard Rule Engine.
-
IoT Data analytics - Learn how to use rule engine to perform basic analytics tasks.
-
Hardware samples - Learn how to connect various hardware platforms to ThingsBoard.
-
Advanced features - Learn about advanced ThingsBoard features.
-
Contribution and Development - Learn about contribution and development in ThingsBoard.