Stand with Ukraine flag
Try it now Pricing
Trendz Analytics
Installation > On premise > CentOS/RHEL Server
Getting Started Documentation Guides
On this page

Installing ThingsBoard Trendz Analytics on CentOS/RHEL

Prerequisites

This guide describes how to install Trendz Analytics on RHEL/CentOS 7/8.

Hardware requirements depend on amount of analyzed data and amount of devices connected to the system. To run Trendz Analytics on a single machine you will need at least 1Gb of free RAM.

In small and medium installations Trendz can be installed on the same server with ThingsBoard.

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 17 (OpenJDK)

ThingsBoard service is running on Java 17. Follow this instructions to install OpenJDK 17:

1
sudo dnf install java-17-openjdk

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 (build ...)

Step 2. Trendz Analytics service installation

Download installation package.

1
wget https://dist.thingsboard.io/trendz-1.11.0.rpm

Install Trendz Analytics as a service

1
sudo rpm -Uvh trendz-1.11.0.rpm

Step 3. Obtain and configure license key

We assume you have already chosen subscription plan for Trendz and have license key. If not, please get your Free Trial license before you proceed. See How-to get pay-as-you-go subscription for more details.

Once you get the license secret, you should put it to the trendz configuration file. Open the file for editing using the following command:

1
sudo nano /etc/trendz/conf/trendz.conf

Add the following lines to the configuration file and put your license secret:

1
2
# License secret obtained from ThingsBoard License Portal (https://license.thingsboard.io)
export TRENDZ_LICENSE_SECRET=YOUR_LICENSE_SECRET_HERE

Step 4. Configure connection with ThingsBoard Platform

You can connect Trendz Analytics to the ThingsBoard Community Edition or ThingsBoard Professional Edition.

Edit ThingsBoard configuration file

1
sudo nano /etc/trendz/conf/trendz.conf

Add ThingsBoard REST API URL that would be used for communicating with ThingsBoard Platform. In most cases, when Trendz installed in the same server with ThingsBoard, API_URL would be http://localhost:8080. Otherwise you should use ThingsBoard domain name.

1
2
# ThingsBoard URL that will be used by Trendz
export TB_API_URL=http://localhost:8080

Step 5. Configure Trendz database

Trendz uses PostgreSQL as a database. You can install PostgreSQL on the same serverfor Trendz or use managed PostgreSQL service from your cloud vendor.

PostgreSQL Installation

Instructions listed below will help you to install PostgreSQL.

1
2
# Update your system
sudo dnf update

Install the repository.

For CentOS/RHEL 8:

1
2
# Install the repository RPM:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

For CentOS/RHEL 9:

1
2
# Install the repository RPM:
sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm

Install the package.

1
2
3
4
5
6
7
8
# Install packages
sudo dnf -qy module disable postgresql
sudo dnf -y install postgresql16 postgresql16-server postgresql16-contrib
# Initialize your PostgreSQL DB
sudo /usr/pgsql-16/bin/postgresql-16-setup initdb
sudo systemctl start postgresql-16
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable --now postgresql-16

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:

1
sudo su - postgres

To be able to interact with the PostgreSQL database, enter:

1
psql

You will connect to the database as the main PostgreSQL user. To set the password, enter the following command after postgres=# :

1
\password

Enter and confirm the password. 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 the pg_hba.conf file:

1
sudo nano /var/lib/pgsql/16/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
sudo systemctl restart postgresql-16.service

Create Database for Trendz

Connect to the database to create trendz DB:

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

Execute create database statement

1
CREATE DATABASE trendz;

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

Configure database connection for Trendz

Edit Trendz configuration file

1
sudo nano /etc/trendz/conf/trendz.conf

Add the following lines to the configuration file. Don’t forget to replace “PUT_YOUR_POSTGRESQL_PASSWORD_HERE” with your real postgres user password:

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

Step 6. Run installation script

Once Trendz service is installed and DB configuration is updated, you can execute the following script:

1
sudo /usr/share/trendz/bin/install/install.sh

Step 7. Start Trendz service

Execute the following command to start Trendz Analytics:

1
sudo service trendz start

Once started, you will be able to open Web UI using the following link:

1
http://localhost:8888/trendz

Note: If Trendz installed on a remote server, you have to replace localhost with the public IP address of the server or with a domain name. Also, check that port 8888 opened for public access.

Authentication

For first authentication you need to use Tenant Administrator credentials from your ThingsBoard

Trendz uses ThingsBoard as an authentication service. During first sign in ThingsBoard service should be also available to validate credentials.

Step 8. Install Trendz Python executor

For writing custom Python models and transformation script you need to install Python libraries on the server where Trendz is installed. Alternative option is to run executor as a docker container, you can find how to do that in install instructions for Docker. But in this section we will write how to install Python libraries directly on the server with Trendz.

  • Install Python3
    1
    2
    3
    
    sudo apt update
    sudo apt install python3
    sudo apt install python3-pip
    
  • Install required python packages
    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    echo "flask == 2.3.2" > requirements.txt
    echo "numpy == 1.24.1" >> requirements.txt
    echo "statsmodels == 0.13.5" >> requirements.txt
    echo "pandas == 1.5.3" >> requirements.txt
    echo "scikit-learn == 1.2.2" >> requirements.txt
    echo "prophet == 1.1.3" >> requirements.txt
    echo "seaborn == 0.12.2" >> requirements.txt
    echo "pmdarima == 2.0.3" >> requirements.txt
    sudo -u trendz pip3 install --user --no-cache-dir -r requirements.txt
    

Step 9. HTTPS configuration

You may want to configure HTTPS access using HAProxy. This is possible in case you are hosting Trendz in the cloud and have a valid DNS name assigned to your instance.

Trendz and ThingsBoard hosted on same server

Use this section if HAProxy/Let’s Encrypt already installed in the server and HTTPS enabled for ThingsBoard.

Open HAProxy configuration file

1
sudo nano /etc/haproxy/haproxy.cfg

Locate frontend https_in section, add new access list that will match traffic by domain name and redirect this traffic to Trendz backend:

1
2
acl trendz_http hdr(host) -i new-trendz-domain.com
use_backend tb-trendz if trendz_http

In the same file register Trendz backend:

1
2
3
4
5
6
backend tb-trendz
  balance leastconn
  option tcp-check
  option log-health-checks
  server tbTrendz1 127.0.0.1:8888 check inter 5s
  http-request set-header X-Forwarded-Port %[dst_port]

Generate SSL certificates for new domain:

1
sudo certbot-certonly --domain new-trendz-domain.com --email some@email.io

Refresh HAProxy configuration:

1
sudo haproxy-refresh

That’s it, HTTPS for Trendz UI configured and now you can access it via: https://new-trendz-domain.com

Fresh installation on new server

Please follow this guide to install HAProxy and generate valid SSL certificate using Let’s Encrypt.

Step 10. Host ThingsBoard and Trendz on the same domain

ThingsBoard and Trendz can share same domain name. In this case ThingsBoard web page would be loaded using following link:

1
https://{my-domain}/

and Trendz web page would be loaded using following link

1
https://{my-domain}/trendz

For enabling such configuration we have to update HAProxy config to route specific requests to Trendz service. Open HAProxy configuration file

1
sudo nano /etc/haproxy/haproxy.cfg

Locate frontend https_in section, add new access list that will match traffic by URL path and redirect this traffic to Trendz backend:

1
2
3
4
...
acl trendz_acl path_beg /trendz path_beg /apiTrendz
....
use_backend tb-trendz if trendz_acl

Troubleshooting

Trendz logs are stored in the following directory:

1
/var/log/trendz

You can issue the following command in order to check if there are any errors on the backend side:

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

Next steps

  • Getting started guide - These guide provide quick overview of main Trendz features.

  • Calculated Fields - Learn about Calculated fields and how to use them.

  • States - Learn how to define and analyse states for assets based on raw telemetry.

  • Prediction - Learn how to make forecasts and predict telemetry behavior.

  • Filters - Learn how filter dataset during analysis.

  • Available Visualizations - Learn about visualization widgets available in Trendz and how to configure them.

  • Share and embed Visualizations - Learn how to add Trendz visualizations on ThingsBoard dashboard or 3rd party web pages.