立即试用 商务报价
Trendz分析
Installation > 本地环境 > Docker (Windows)

本页目录

Installing ThingsBoard Trendz Analytics using Docker (Windows)

This guide will help you to install and start Trendz Analytics using Docker on Windows.

Prerequisites

Step 1. Obtain the 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.

Note: We will reference the license key you have obtained during this step as PUT_YOUR_LICENSE_SECRET_HERE guide.

Step 2. Checkout Trendz Analytics image on Docker Hub

Open official Trendz Analytics Docker Hub page and proceed to checkout. Populate basic information about yourself and click “Get Content”

Step 3. Running Trendz service

Docker Compose setup

Make sure your have logged in to docker hub using command line.

Create docker compose file for Trendz Analytics service:

1
docker-compose.yml

Add the following line to the yml file. Don’t forget to replace “PUT_YOUR_LICENSE_SECRET_HERE” with your license secret obtained on the first step

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
33
34
35
version: '3.0'
services:
  mytrendz:
    restart: always
    image: "thingsboard/trendz:1.9.2-HF2"
    ports:
      - "8888:8888"
    environment:
      TB_API_URL: http://10.0.0.101:8080
      TRENDZ_LICENSE_SECRET: PUT_YOUR_LICENSE_SECRET_HERE
      TRENDZ_LICENSE_INSTANCE_DATA_FILE: /data/license.data
      SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/trendz
      SPRING_DATASOURCE_USERNAME: postgres
      SPRING_DATASOURCE_PASSWORD: postgres
    volumes:
      - mytrendz-data:/data
      - mytrendz-logs:/var/log/trendz
  postgres:
    restart: always
    image: "postgres:12"
    ports:
      - "5432"
    environment:
      POSTGRES_DB: trendz
      POSTGRES_PASSWORD: postgres
    volumes:
      - mytrendz-data/db:/var/lib/postgresql/data
volumes:
  mytrendz-data:
    external: true
  mytrendz-logs:
    external: true
  mytrendz-data-db:
    external: true

Where:

  • TB_API_URL - url for connecting to ThingsBoard Rest API (for example http://10.5.0.11:8080). Note that ThingsBoard IP address should be resolvable from Trendz docker container
  • PUT_YOUR_LICENSE_SECRET_HERE - placeholder for your license secret obtained on the first step
  • 8888:8888 - connect local port 8888 to exposed internal HTTP port 8888
  • mytrendz-data:/data - mounts the volume mytrendz-data to Trendz data directory
  • mytrendz-data/db:/var/lib/postgresql/datad - mounts the volume mytrendz-data/db to Postgres data directory
  • mytrendz-logs:/var/log/trendz - mounts the volume mytrendz-logs to Trendz logs directory
  • mytrendz - friendly local name of this machine
  • --restart always - automatically start Trendz in case of system reboot and restart in case of failure.
  • thingsboard/trendz:1.9.2-HF2 - docker image
Setup Docker volumes

Windows users should use docker managed volume for Trendz DataBase. Create docker volume (for ex. mytrendz-data) before executing docker run command: Open “Docker Quickstart Terminal”. Execute the following command to create docker volume:

1
2
3
docker volume create mytrendz-data
docker volume create mytrendz-data-db
docker volume create mytrendz-logs

NOTE: replace directory ~/.mytrendz-data and ~/.mytrendz-logs with directories you’re planning to used in docker-compose.yml.

Running service

在包含该文件的目录终端中执行以下命令启动此docker compos:docker-compose.yml

1
2
3
docker compose pull
docker compose up -d
docker compose logs -f mytrendz

ThingsBoard3.4.2版本开始支持Docker Compose V2(Docker Desktop或Compose插件)因为Docker不再支持docker-compose作为独立设置。

我们强烈建议更新到Docker Compose V2 使用它。

更新最新镜像docker-compose命令:
docker-compose pull
docker-compose up -d
docker-compose logs -f mytrendz

In order to get access to necessary resources from external IP/Host on Windows machine, please execute the following commands:

1
2
set PATH=%PATH%;"C:\Program Files\Oracle\VirtualBox"
VBoxManage controlvm "default" natpf1 "tcp-port8888,tcp,,8888,,8888"  

Where

  • C:\Program Files\Oracle\VirtualBox - path to your VirtualBox installation directory

After executing this command you can open http://{your-host-ip}:8888 in you browser (for ex. http://localhost:8888). You should see Trendz login page.

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.

Detaching, stop and start commands

你可以使用Ctrl-p Ctrl-q与会话终端分离容器将继续在后台运行。

如果出现任何问题可以检查服务日志中的错误例如:要查看ThingsBoard容器日志。
请执行以下命令:

1
docker compose logs -f mytrendz

停止容器:

1
docker compose stop mytrendz

启动容器:

1
docker compose start mytrendz

Docker Compose已被弃用建议使用Docker Compose V2
更新最新镜像docker-compose命令:
docker-compose logs -f mytrendz
docker-compose stop mytrendz
docker-compose start mytrendz

Troubleshooting

DNS issues

注意:如果你发现与DNS问题相关的错误,例如

1
127.0.1.1:53: cannot unmarshal DNS message

你可以配置系统以使用Google公用DNS服务

Next steps