在CentOS/RHEL上安装ThingsBoard(社区版),官方文档地址:https://thingsboard.io/docs/user-guide/install/rhel/
在一台机器上运行ThingsBoard和PostgreSQL,至少需要1GB RAM;在一台机器上运行ThingsBoard和Cassandra,至少需要8GB RAM。开始安装之前需要先执行以下命令安装必要的工具。
sudo yum install -y nano wget
# Add latest EPEL release
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# 安装
sudo yum install java-1.8.0-openjdk
# 将操作系统配置为默认使用OpenJDK 8
sudo update-alternatives --config java
# 查看版本
java -version
# Update your system
sudo yum update
# Install the repository RPM:
sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Install packages
sudo yum install postgresql96-server postgresql96-contrib
# Initialize your PostgreSQL DB
sudo /usr/pgsql-9.6/bin/postgresql96-setup initdb
sudo systemctl start postgresql-9.6
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable postgresql-9.6
设置PostgreSQL密码
sudo su - postgres
psql
\password
\q
编辑pg_hba.conf对postgres用户使用MD5认证
sudo vim /var/lib/pgsql/9.6/data/pg_hba.conf
找到以下内容:
# IPv4 local connections:
host all all 127.0.0.1/32 ident
修改为:
host all all 127.0.0.1/32 md5
重启PostgreSQL服务
sudo systemctl restart postgresql-9.6.service
创建ThingsBoard DB
psql -U postgres -d postgres -h 127.0.0.1 -W
CREATE DATABASE thingsboard;
\q
下载安装包
wget https://github.com/thingsboard/thingsboard/releases/download/v2.4.1/thingsboard-2.4.1.rpm
安装
sudo rpm -Uvh thingsboard-2.4.1.rpm
本地进行源码编译,已安装JDK8、git、maven。GitHub地址:https://github.com/thingsboard/thingsboard.git代码结构如下图所示:
更改配置项,绕过License选项,将pom.xml中的这块代码注释掉
com.mycila
license-maven-plugin
3.0
....
修改数据库配置,配置文件路径:thingsboard/application/src/main/resources/thingsboard.yml
# SQL DAO Configuration
spring:
data:
jpa:
repositories:
enabled: "true"
jpa:
open-in-view: "false"
hibernate:
ddl-auto: "none"
database-platform: "${SPRING_JPA_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}"
hikari:
maximumPoolSize: "${SPRING_DATASOURCE_MAXIMUM_POOL_SIZE:50}"
将数据库密码设置为之前安装PostgreSQL设置的密码
password: "${SPRING_DATASOURCE_PASSWORD:postgres}"
进行编译
mvn clean install -DskipTests -X
rpm -Uvh thingsboard.rpm
# 运行脚本
/usr/share/thingsboard/bin/install/install.sh --loadDemo
# 启动服务
service thingsboard start
部署完成!
本文由博客一文多发平台 OpenWrite 发布!