lot物联网开源平台thingsboard和postgresql安装配置

thingsboard和postgresql安装配置

Java环境安装

oracle原生环境

sudo apt-get update
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo update-alternatives --config java
sudo vi /etc/environment
# 底部增加一行
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
source /etc/environment

openJava环境

sudo apt-get update
sudo apt-get install openjdk-8-jre
sudo apt-get -f install
java -version

PostgreSQL安装

PostgreSQ

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib
sudo service postgresql start

修改默认密码

sudo -u postgres psql postgres
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q

创建thingsboard表

sudo -u postgres psql postgres
postgres=# CREATE DATABASE thingsboard;
postgres=# \q

thingsboard安装

下载thingsboard安装包

wget https://github.com/thingsboard/thingsboard/releases/download/v2.1/thingsboard-2.1.deb

安装thingsboard

sudo dpkg -i thingsboard-2.1.deb

修改yaml配置PostgreSQL

sudo vi /etc/thingsboard/conf/thingsboard.yml
# 注释掉文档中HSQLDB DAO默认的配置;
# 打开PostgreSQL部分配置,同时修改最后两行数据库的用户名密码;

运行安装脚本

sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
sudo service thingsboard start

使用thingsboard

访问地址

http://localhost:8080/

默认用户名密码

sysadmin@thingsboard.org
sysadmin

tenant@thingsboard.org
tenant

日志文件

vi /var/log/thingsboard
# err
cat /var/log/thingsboard/thingsboard.log | grep ERROR

配置文件

/etc/thingsboard/conf -> /usr/share/thingsboard/conf/
# thingsboard.yml
# thingsboard.conf

修改端口号

# 停止服务:
sudo service thingsboard stop
# 修改配置文件thingsboard.yml中的port端口号
# 启动服务:
sudo service thingsboard start

发送模拟数据

curl -v -X POST -d "{\"temperature\": 25}" http://localhost:8080/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"

产生模拟数据脚本

var msg = { temperature: +(Math.random()*5 + 25).toFixed(1)};
var metadata = {};
var msgType = "POST_TELEMETRY_REQUEST";
return { msg: msg, metadata: metadata, msgType: msgType };
    原文作者:fangqi179
    原文地址: https://www.jianshu.com/p/3b9f71f631b3
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞