thingsboard安装及配置
thingsboard使⽤了
actor模型:akka
⽤作服务调度:zookeeper
远程调⽤:gRPC,thrift
2:sudo rpm -Uvh thingsboard-1.3.rpm,报错:java-1.8.0 is needed by thingsboard-0:1.arch。猜测跟jdk的某些配置有关sudo alternatives --config java
sudo alternatives --install /usr/bin/java java /usr/jdk1.8.0_60/bin/java 1,错误继续.删除配置
sudo alternatives --remove java /usr/jdk1.8.0_60/bin/java
下载rpm版的jdk安装⽂件(jdk-8u144-linux-x64.rpm)。
创办
sudo rpm -Uvh jdk-8u144-linux-x64.rpm.sudo rpm -Uvh thingsboard-1.3.rpm执⾏成功
使⽤postgres数据库
# Install packages
sudo yum install postgresql-rver postgresql-contrib
# Initialize your PostgreSQL DB
sudo postgresql-tup initdb
sudo systemctl start postgresql
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable postgresql
anonymous proxy
修改/var/lib/pgsql/f
listen_address = '*'
修改f
host all all /32 md5。允许某个ip地址登录
yasuda
host all all 127.0.0.1/32 trust.允许本机其他⽤户名登录
修改postgres密码.
修改l为postgres连接.注释掉默认数据库,放开postgres
cad是什么启动postgres。systemctl start postgresql
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
sudo systemctl start thingsboard.rvice.
git checkout relea-1.3
mvn clean package
视个⼈情况安装nodejs,Mosquitto-client,curl。
npm install coap-cli -g
npm install mqtt -g
aroundthecorner创建po源
[home_oojah_mqtt]
name=mqtt (CentOS_CentOS-7)
type=rpm-md
baurl=download.opensu/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/
gpgcheck=1
gpgkey=download.opensu/repositories/home:/oojah:/mqtt/CentOS_CentOS-7//l.key
enabled=1
yum arch all mosquitto
==== Matched: mosquitto ================================================================ mosquitto-clien
ts.x86_64 : Mosquitto command line publish/subscribe clients
mosquitto-debuginfo.x86_64 : Debug information for package mosquitto
libmosquitto-devel.x86_64 : MQTT C client library development files
libmosquitto1.x86_64 : MQTT C client library
libmosquittopp-devel.x86_64 : MQTT C++ client library development files
libmosquittopp1.x86_64 : MQTT C++ client library
mosquitto.x86_64 : MQTT version 3.1/3.1.1 compatible message broker
yum install mosquitto-clients
lifestyle
mqtt.js/publish.js:模拟mqtt
#!/bin/sh
# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"
export THINGSBOARD_HOST=demo.thingsboard.io
# Replace YOUR_ACCESS_TOKEN with one from Device credentials window.
export ACCESS_TOKEN=YOUR_ACCESS_TOKEN
# Read rial number and firmware version attributes
ATTRIBUTES=$( cat attributes-data.json )
export ATTRIBUTES
steam是什么
# Read timeries data as an object without timestamp (rver-side timestamp will be ud)
TELEMETRY=$( cat telemetry-data.json )
export TELEMETRY
# publish attributes and telemetry data via mqtt client
node publish.js
var mqtt = require('mqtt');
console.log('Connecting to: %s using access token: %s', v.THINGSBOARD_HOST, v.ACCESS_TOKEN);
var client = t('mqtt://'+ v.THINGSBOARD_HOST,{
urname: v.ACCESS_TOKEN
});
<('connect', function () {
console.log('Client connected!');
client.publish('v1/devices/me/attributes', v.ATTRIBUTES);
console.log('Attributes published!');
client.publish('v1/devices/me/telemetry', v.TELEMETRY);
console.log('Telemetry published!');
});
Mosquitto-client:模拟mqtt
#!/bin/sh
# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"
沉甸甸读音
THINGSBOARD_HOST="demo.thingsboard.io"
# Replace YOUR_ACCESS_TOKEN with one from Device credentials window.
ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
# Publish rial number and firmware version attributes
mosquitto_pub -d -h "$THINGSBOARD_HOST" -t "v1/devices/me/attributes" -u "$ACCESS_TOKEN" -f "attributes-data.json"
# Publish timeries data as an object without timestamp (rver-side timestamp will be ud)
mosquitto_pub -d -h "$THINGSBOARD_HOST" -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -f "telemetry-data.json"
coap.js:模拟coap
# Publish rial number and firmware version attributes
cat attributes-data.json | coap post coap://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes雅思报名
# Publish timeries data as an object without timestamp (rver-side timestamp will be ud)
cat telemetry-data.json | coap post coap://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/telemetry
curl:模拟curl
# Publish rial number and firmware version attributes
# replace $THINGSBOARD_PORT with 8080 (in ca of local installation) or 80 (in ca of live-demo).
curl -v -X POST -d @attributes-data.json $THINGSBOARD_HOST:$THINGSBOARD_PORT/api/v1/$ACCESS_TOKEN/attributes --header "Content-Type:ap # Publish timeries data as an object without timestamp (rver-side timestamp will be ud)
# replace $THINGSBOARD_PORT with 8080 (in ca of local installation) or 80 (in ca of live-demo).
curl -v -X POST -d @telemetry-data.json $THINGSBOARD_HOST:$THINGSBOARD_PORT/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:ap
模拟数据
软科中国大学排名attributes-data.json:
{"firmware_version":"1.0.1", "rial_number":"SN-001"}
telemetry-data.json
{"temperature":21, "humidity":55.0, "active": fal}
export THINGSBOARD_x.xxx export ACCESS_TOKEN=xxxxxxx
export THINGSBOARD_PORT=xxxx
执⾏./coap-js.sh
或者./curl.sh
或者./mqtt-js.sh
或者./mosquitto.sh
在dashboard上可以看到刚才设备发送的消息及时间