在Windows系统中安装ThingsBoard

This guide describes how to install ThingsBoard on a Windows machine. Instructions below are provided for Windows 10/8.1/8/7 32-bit/64-bit.

本指南描述如何在Windows机器上安装ThingsBoard。以下为Windows 10/8/8/8/32位/64位的安装指南。

硬件需求

To run ThingsBoard and third-party components on a single machine you will need at least 2Gb of RAM (4Gb recommended).

要在一台机器上运行ThingsBoard和第三方组件,你至少需要2Gb的RAM(推荐4Gb)。

第三方组件安装

Java

ThingsBoard service is running on Java 8. If you don’t have Java installed, please download and install Java 8 using this link.

ThingsBoard在Java8环境中运行,如果您未安装Java,请通过此链接安装Java8

[非必要] 安装外部数据库

ThingsBoard is able to use SQL or NoSQL(Cassandra) database layer. By default, ThingsBoard uses embedded HSQLDB instance which is very convenient for evaluation or development purposes. If this is your first experience with ThingsBoard we recommend to skip this step and use the embedded database.

ThingsBoard可以使用SQL或NoSQL(Cassandra)数据库。默认情况下,ThingsBoard使用内置的HSQLDB,HSQLDB方便评估和开发。如果您是第一次接触ThingsBoard,我们建议您跳过这一步,先使用内置数据库进行体验。

Alternatively, you can configure your platform to use either scalable Cassandra DB cluster or various SQL databases. If you prefer to use an SQL database, we recommend PostgreSQL.

或者,您可以使用可扩展的Cassandra DB集群或SQL数据库。如果您选择使用SQL数据库,我们推荐您使用PostgreSQL。

SQL数据库: PostgreSQL

NOTE: This is an optional step. It is required only for production usage. You can use embedded HSQLDB for platform evaluation or development Download the installation file here and follow the installation instructions. Once PostgreSQL is installed you may want to create the new user or set the password for the main user. When it’s done, connect to the database and create thingsboard DB:

注意,此步骤仅供生产使用,可跳过。你可以使用HSQLDB来评估和开发。 请点击此链接下载PostgreSQL并根据安装说明进行安装。 PostgreSQL安装完成后,请创建新用户或者为主用户设置密码。 接下来,可以链接数据库创建Thingsboard DB了:

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

CREATE DATABASE thingsboard;
\q

NoSQL数据库: Cassandra

NOTE: This is an optional step. It is required only for production usage. You can use embedded HSQLDB for platform evaluation or development

注意,此步骤仅供生产使用,可跳过。你可以使用HSQLDB来评估和开发。

Instructions listed below will help you to install Cassandra.

请按照以下步骤安装Cassandra.

下载DataStax Community Edition v3.0.9

Run downloaded MSI package. You are first presented with an initial welcome panel that identifies your installation package:

下载MSI安装包。首先,您会看到一个初始的欢迎面板,它可以识别您的安装包:

  • Clicking next takes you to the end user license agreement:
  • 点击Next进入用户许可协议面板:

  • The next panel allows you to specify where the software is to be installed:
  • 点击Next选择安装路径:

  • Once the installation directory has been set, the installer will ask how you want to handle the service that will be installed:
  • 选择是否自动启动

  • The next panel initiates the installation process:
  • 点击Next启动安装程序:

  • The final panel asks if you would like to register to be updated when new versions of the software become available:
  • 选择是否注册更新新版本:

  • You can find installed interfaces in “DataStax Community Edition” program group that the installer creates for you:
  • 安装程序将安装接口创建在“DataStax Community Edition”程序组中。

  • The primary interface into Cassandra is the CQL (Cassandra Query Language) shell utility, which can be used to execute CQL commands for the new Cassandra server.

Cassandra的主要接口是CQL(Cassandra查询语言)shell实用程序,新的Cassandra服务器可使用该程序执行CQL命令。

安装ThingsBoard服务

  • Create working directory, for example “C:\thingsboard”.
  • Download installation archive or build it from source.
  • Unzip installation archive to the working directory. The working directory should look like this after installation:

  • Run windows shell (cmd) as Administrator. Change directory to your working dir.
  • Run install.bat script to install ThingsBoard as a Windows service (or run “install.bat –loadDemo” to install and add demo data). This means it will be automatically started on system startup. Similar, uninstall.bat will remove ThingsBoard from Windows services. The output should be like:
  • 运行Windows(cmd),将目录改为你的工作目录。
  • 运行install.bat脚本安装ThingsBoard作为Windows服务(或者运行“install.bat –loadDemo”安装并添加演示数据)。ThingsBoard将在系统启动时自动启动。同样的,运行uninstall.bat可从Widonws服务中移除ThingsBoard。输出显示如下:
  C:\thingsboard>install.bat --loadDemo
  Detecting Java version installed.
  Detecting if it is 64 bit machine
  CurrentVersion
  Detecting if it is 32 bit machine
  CurrentVersion 1.8
  Java 1.8 found!
  Installing thingsboard ...
   ===================================================
   :: ThingsBoard ::       (v1.3.0)
   ===================================================

  Starting ThingsBoard Installation...
  Installing DataBase schema...
  Installing Cassandra DataBase schema...
  Loading system data...
  Installation finished successfully!
  2017-07-23 21:47:12,079 INFO  - Starting ServiceWrapper in the CLI mode
  2017-07-23 21:47:12,317 INFO  - Completed. Exit code is 0
  ThingsBoard installed successfully!

[非必要] 配置ThingsBoard使用外部数据库

NOTE: This is an optional step. It is required only for production usage. You can use embedded HSQLDB for platform evaluation or development

注意,此步骤仅供生产使用,可跳过。你可以使用HSQLDB来评估和开发。

Edit ThingsBoard configuration file:

编辑ThingsBoard配置文件:

C:\thingsboard\conf\thingsboard.yml

Comment ‘# HSQLDB DAO Configuration’ block.

注释‘# HSQLDB DAO Configuration’

# HSQLDB DAO Configuration
#spring:
#  data:
#    jpa:
#      repositories:
#        enabled: "true"
#  jpa:
#    hibernate:
#      ddl-auto: "validate"
#    database-platform: "org.hibernate.dialect.HSQLDialect"
#  datasource:
#    driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.hsqldb.jdbc.JDBCDriver}"
#    url: "${SPRING_DATASOURCE_URL:jdbc:hsqldb:file:${SQL_DATA_FOLDER:/tmp}/thingsboardDb;sql.enforce_size=false}"
#    username: "${SPRING_DATASOURCE_USERNAME:sa}"
#    password: "${SPRING_DATASOURCE_PASSWORD:}"

For PostgreSQL:

PostgreSQL 去除 ‘# PostgreSQL DAO Configuration’ 的注释.

# PostgreSQL DAO Configuration
spring:
  data:
    jpa:
      repositories:
        enabled: "true"
  jpa:
    hibernate:
      ddl-auto: "validate"
    database-platform: "org.hibernate.dialect.PostgreSQLDialect"
  datasource:
    driverClassName: "${SPRING_DRIVER_CLASS_NAME:org.postgresql.Driver}"
    url: "${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/thingsboard}"
    username: "${SPRING_DATASOURCE_USERNAME:postgres}"
    password: "${SPRING_DATASOURCE_PASSWORD:postgres}"

Cassandra DB:

Locate and set database type configuration parameter to ‘cassandra’.

定位数据库类型参数并将该参数设置为‘cassandra’。

database:
  type: "${DATABASE_TYPE:cassandra}" # cassandra OR sql

slow machines内存更新(1GB of RAM)

We recommend to use embedded HSQLDB or PostgreSQL DB in this setup. We don’t recommend to use Cassandra on machines with less then 4GB of RAM. Go to your environment variables and set JAVA_OPTS variable:

在此设置中我们建议使用内置HSQLDB或者PostgreSQL DB。RAM少于4GB不建议使用Cassandra。 设置JAVA_OPT变量(换将变量中)

JAVA_OPTS=-Xms256M -Xmx256M

启动ThingsBoard服务

Now let’s start the ThingsBoard service! Open the command prompt as an Administrator and execute the following command:

现在我们可以开启ThingsBoard服务了!打开命令提示符执行以下命令:

net start thingsboard

Expected output:

期望输出如下:

The ThingsBoard Server Application service is starting.
The ThingsBoard Server Application service was started successfully.

In order to restart the ThingsBoard service you can execute following commands:

执行以下命令可以重启ThingsBoard服务:

net stop thingsboard
net start thingsboard

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

服务启动之后,使用如下链接进入Web页面:

http://localhost:8080/

NOTE: Please allow up to 90 seconds for the Web UI to start

注意:90秒可打开页面。

故障排除

The log files are located in logs folder (“C:\thingsboard\logs” in our case). The thingsboard.log file should contain following line:

日志文件保存在日志文件夹中(如:“C:\thingsboard\logs” )。 thingsboard.log文件应该包括如下内容:

YYYY-MM-DD HH:mm:ss,sss [main] INFO  o.t.s.ThingsboardServerApplication - Started ThingsboardServerApplication in x.xxx seconds (JVM running for x.xxx)

In case of any unclear errors, use general troubleshooting guide or contact us.

Windows防火墙设置

In order to have external access to ThingsBoard Web UI and device connectivity (HTTP, MQTT, CoAP) you need to create a new inbound rule with Windows Firewall with Advanced Security.

您需要使用具有高级安全性的Windows防火墙创建一个新的入站规则允许外部访问ThingsBoard Web页面以及连接(HTTP, MQTT, CoAP) 。

  • Open “Windows Firewall” from “Control Panel”:

打开控制面板中的Windows防火墙:

  • Click “Advanced settings” on the left panel:
  • 点击左部面板中的“Advanced settings” (高级设置):

  • Select “Inbound Rules” on the left panel, then click “New Rule…” on the right “Actions” panel:
  • 点击左部面板中的“Inbound Rules”,点击右部“Actions”面板中的“New Rule…”:

  • Now new “New Inbound Rule Wizard” window will open. On the first step “Rule Type” select “Port” option:

显示新的“New Inbound Rule Wizard”窗口。“Rule Type”中的选项选择“Port”:

  • On the “Protocol and Ports” step select “TCP” protocol and enter port list 8080, 1883, 5683 in the “Specific local ports” field:

“Protocol and Ports”选项选择“TCP” 协议进入8080, 1883, 5683端口:

  • On the “Action” step leave “Allow the connection” option selected:

“Action”步骤选择“Allow the connection”选项:

  • On the “Profile” step select Windows network profiles when to apply this rule:

“Profile”步骤,使用此规则时选择Windows network profiles

  • Finally, give the name to this rule (for ex. “ThingsBoard Service Networking”) and click “Finish”.

最后,为此规则命名。并点击“Finish”.

results matching ""

    No results matching ""