ThingsBoard requires Java 17. Start by updating the package index and installing the OpenJDK.
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
You can verify the active Java version using the following command. If multiple versions are present, use update-alternatives to select version 17.
java -version
Expected output should reflect OpenJDK version 17.
2. ThingsBoard Installation
Navigate to your home directory and download the ThingsBoard Debian package. For this guide, we use version 3.7.
cd ~
wget https://github.com/thingsboard/thingsboard/releases/download/v3.7/thingsboard-3.7.deb
If the download is slow, you may download the file via a browser and upload it to the server manually using SFTP tools like FileZilla or electerm.
Once the file is on the server, install it using dpkg.
sudo dpkg -i thingsboard-3.7.deb
3. PostgreSQL Database Setup
For projects handling fewer than 5,000 messages per second, PostgreSQL is the recommended data storage solution.
First, import the PostgreSQL signing key and add the repository.
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
Update the package list and install PostgreSQL 15.
sudo apt-get update
sudo apt-get install -y postgresql-15
Start the PostgreSQL service.
sudo systemctl start postgresql
Switch to the postgres user to configure the database.
sudo su - postgres
psql
Inside the PostgreSQL shell, set a password for the postgres user and create the database. Replace YOUR_PASSWORD with a strong password.
\password
# Enter your new password twice
CREATE DATABASE thingsboard;
\q
Exit the postgres user session to return to your normal terminal.
exit
4. Configuring ThingsBoard Database Connection
Edit the ThingsBoard configuration file to connect to PostgreSQL.
sudo nano /etc/thingsboard/conf/thingsboard.conf
Append the following lines to the end of the file. Ensure you input the password you created in the previous step.
# Database Configuration
export DATABASE_TS_TYPE=sql
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/thingsboard
export SPRING_DATASOURCE_USERNAME=postgres
export SPRING_DATASOURCE_PASSWORD=YOUR_PASSWORD
export SQL_POSTGRES_TS_KV_PARTITIONING=MONTHS
Save the file and exit the editor.
5. Message Queue Configuration (Optional)
By default, ThingsBoard uses an in-memory queue, which is suitable for development or small deployments. For production environments, RabbitMQ is recommended. Its advisable to install RabbitMQ on a separate server if possible to avoid resoruce contention.
To install RabbitMQ on the current server:
sudo apt-get update
sudo apt-get install -y erlang rabbitmq-server
sudo systemctl enable rabbitmq-server
sudo systemctl start rabbitmq-server
Create a dedicated administrator user in RabbitMQ (replace placeholders with your credentials).
sudo rabbitmqctl add_user admin_user strong_password
sudo rabbitmqctl set_user_tags admin_user administrator
sudo rabbitmqctl set_permissions -p / admin_user ".*" ".*" ".*"
Update the ThingsBoard configuration file again to integrate RabbitMQ.
sudo nano /etc/thingsboard/conf/thingsboard.conf
Add the RabbitMQ settings:
export TB_QUEUE_TYPE=rabbitmq
export TB_QUEUE_RABBIT_MQ_USERNAME=admin_user
export TB_QUEUE_RABBIT_MQ_PASSWORD=strong_password
export TB_QUEUE_RABBIT_MQ_HOST=localhost
export TB_QUEUE_RABBIT_MQ_PORT=5672
6. Running the Installation Script
Execute the installation script to initialize the database schema. The --loadDemo flag will add sample data and users.
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
7. Starting the Service
Finally, start the ThingsBoard service.
sudo service thingsboard start
Allow up to 90 seconds for the service to initialize. You can verify the status using sudo service thingsboard status.
Access the ThingsBoard web interface via your browser at http://YOUR_SERVER_IP:8080.
Default credentials for the demo data are:
- System Administrator: sysadmin@thingsboard.org / sysadmin
- Tenant Administrator: tenant@thingsboard.org / tenant
- Customer User: customer@thingsboard.org / customer