国外开源IoT平台Thingsboard社区版本(V3.3.2)在Win10环境下进⾏源码。。
。
国外开源IoT平台Thingsboard社区版本源码编译及运⾏指南
Thingsboard⽀持的协议有:
MQTT
COAP
HTTP
1 下载
使⽤git进⾏下载Thingsboard最新源码
git clone git@github:thingsboard/thingsboard.git
2 软件环境及版本
2.1 系统环境
OS:Windows10
JDK:OpenJDK11(必须使⽤该版本,其它容易出错误)
从其镜像的Docker命令中可以看到其运⾏的版本
/bin/sh -c ln -svT "/usr/lib/jvm/java-11-openjdk-$(dpkg --print-architecture)" /docker-java-home
2.2 数据库环境
Postgresql:11(默认⽤户名为:postgres,密码为:postgres)
附,操作系统对应的Postgresql版本各不相同,请下载相应版本。安装完成后,创建数据库thingsboard。
2.3 前端环境
ndoe:v14.15.5
yarn:1.22.10
2.4 编译环境
Maven:3.6.3
2.5 应⽤环境
Thingsboard:3.3.2-SNAPSHOT
3 编译
对于刚下载的源码直接跳过监测进⾏安装即可
mvn install -DskipTests
安装时间稍长,笔者⽤了约12mins,耐⼼等待即可。
编译完成后的⽂件结构为:
详细⽬录树状结构为:
├─conf 项⽬配置⽂件
│├─i18n
│└─templates
├─data 项⽬数据⽂件,内含规则链相关数据库数据,执⾏安装时会⽤到
│├─cassandra
│├─certs
││└─azure
│├─json
││├─demo
│││└─dashboards
││├─system 系统⽂件夹
│││├─oauth2_config_templates
│││└─widget_bundles
││└─tenant 租户⽂件夹
││├─device_profile
││├─edge_management
│││└─rule_chains
││└─rule_chains
│├─sql postgresql数据库⽂件,初始化数据库使⽤
│└─upgrade postgresql数据库⽂件,升级数据库使⽤(笔者还没体验过)│├─1.3.0
│├─1.3.1
│├─1.4.0
│├─2.0.0
│├─2.1.1
│├─2.1.2
│├─2.2.0
│├─2.3.1
│├─2.4.0
│├─2.4.2
│├─2.4.3
│├─3.0.1
│├─3.1.0
│├─3.1.1
│├─3.2.1
│└─3.2.2
├─install 安装项⽬时⽇志配置⽂件
├─lib 项⽬jar包
└─logs 各种⽇志⽂件
4 运⾏
1. 双击上图中序号为1的批处理⽂件,执⾏Thingsboard软件的安装及数据库的初始化,本质就是将其注册为⼀个服务,
详细指令如下所⽰。
@ECHO OFF
setlocal ENABLEEXTENSIONS
@ECHO Detecting Java version installed.
:CHECK_JAVA
for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do set "jver=%%j%%k"
@ECHO CurrentVersion %jver%
if %jver% NEQ 110 GOTO JAVA_NOT_INSTALLED
:JAVA_INSTALLED
@ECHO Java 11 found!
@ECHO Installing thingsboard ...
SET loadDemo=false
if "%1" == "--loadDemo" (
SET loadDemo=true
)
SET BASE=%~dp0
SET LOADER_PATH=%BASE%\conf,%BASE%\extensions
SET SQL_DATA_FOLDER=%BASE%\data\sql
SET jarfile=%BASE%\lib\thingsboard.jar
SET installDir=%BASE%\data
PUSHD "%BASE%\conf"
java -cp "%jarfile%" -Dloader.main=org.thingsboard.server.ThingsboardInstallApplication^
-Dinstall.data_dir="%installDir%"^
-Dinstall.load_demo=%loadDemo%^
-Dspring.jpa.hibernate.ddl-auto=none^
-Dinstall.upgrade=false^
-fig="%BASE%\l"^
org.springframework.boot.loader.PropertiesLauncher
if errorlevel 1 (
@echo ThingsBoard installation failed!
POPD
exit /b %errorlevel%
)
POPD
"%BASE%" install
@ECHO ThingsBoard installed successfully!
GOTO END
:
JAVA_NOT_INSTALLED
@ECHO Java 11 is not installed. Only Java 11 is supported
@ECHO Please go to adoptopenjdk/index.html and install Java 11. Then retry installation.
PAUSE
GOTO END
:END
数据库结果为:共计40个表
2. 上图中序号为3的批处理⽂件作⽤是将服务删除,但是数据库没有删掉,所以要想再次安装程序时,需要将数据库删掉,否则会
报错。
3. 通过命令⾏启动服务时,发现出错,如下图所⽰,
原因是不到类路径。(TODO:后续解决)源代码下载开源社区
因此就是⽤java命令进⾏运⾏,去掉不能识别的参数-Dinstall.data_dir=F:\respository\thingsboard\application\target\thingsboard-windows\thingsboard\data,命令是:
java -Dplatform=windows -Xlog:gc*,heap*,age*,safepoint=debug:file=F:\respository\thingsboard\application\target\thingsboard-windows\thingsboard\ logs\gc.log:time,uptime,level,tags:filecount=10,filesize=10M -XX:+HeapDump
OnOutOfMemoryError -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+Re sizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark -XX:+UseG1GC -XX:MaxGCPauseMillis=500 -XX:+UseStringDeduplication -XX:+Pa rallelRefProcEnabled -XX:MaxTenuringThreshold=10 -Xms512m -Xmx1024m -jar F:\respository\thingsboard\application\target\thingsboard-windows\
thingsboard\lib\thingsboard.jar
运⾏⽇志部分为;
2021-09-30 17:21:13.524 INFO 41488 --- [ main] o.t.s.a.service.DefaultActorService : Initializing actor system.
2021-09-30 17:21:13.576 INFO 41488 --- [ main] o.t.s.a.service.DefaultActorService : Actor system initialized.
2021-09-30 17:21:13.976 INFO 41488 --- [ main] o.adaptor.JsonConverterConfig : JSON type cast enabled =true
2021-09-30 17:21:13.977 INFO 41488 --- [ main] o.adaptor.JsonConverterConfig : JSON max string value length = 0
2021-09-30 17:21:14.059 INFO 41488 --- [ main] o.qtt.MqttTransportService : Setting resource leak detector level to DISABLED
2021-09-30 17:21:14.060 INFO 41488 --- [ main] o.qtt.MqttTransportService : Starting
2021-09-30 17:21:15.141 INFO 41488 --- [ main] o.qtt.MqttTransportService : Mqtt transport started!
2021-09-30 17:21:15.197 INFO 41488 --- [ main] work.RandomTokenGenerator : using tokens of 8 bytes in length
2021-09-30 17:21:15.217 INFO 41488 --- [ main] work.CoapEndpoint : coap CoapEndpoint uses udp plain
2021-09-30 17:21:15.229 INFO 41488 --- [ main] work.stack.BlockwiseLayer : BlockwiseLayer uses MAX_MESSAGE_SIZE=1024, PR EFERRED_BLOCK_SIZE=1024, BLOCKWISE_STATUS_LIFETIME=300000, MAX_RESOURCE_BODY_SIZE=268435456, BLOCKWISE_STRICT_BLOCK 2_OPTION=true
2021-09-30 17:21:15.233 INFO 41488 --- [ main] work.stack.ReliabilityLayer : ReliabilityLayer uses ACK_TIMEOUT=2000, ACK_RANDO M_FACTOR=1.5, and ACK_TIMEOUT_SCALE=2.0 as default
2021-09-30 17:21:15.239 INFO 41488 --- [ main] CoapServer : Starting server
2021-09-30 17:21:15.254 INFO 41488 --- [ main] o.e.californium.elements.UDPConnector : UDPConnector starts up 8 sender threads and 8 recei ver threads
2021-09-30 17:21:15.260 INFO 41488 --- [ main] o.e.californium.elements.UDPConnector : UDPConnector listening on 0.0.0.0/0.0.0.0:5683, recv buf = 65536, send buf = 65536, recv packet size = 2048
2021-09-30 17:21:15.260 INFO 41488 --- [ main] work.CoapEndpoint : coap Started endpoint at coap://0.0.0.0:5683
2021-09-30 17:21:15.282 INFO 41488 --- [ main] o.ap.CoapTransportService : Starting
2021-09-30 17:21:15.290 INFO 41488 --- [ main] o.ap.CoapTransportService : CoAP transport started!
2021-09-30 17:21:15.454 INFO 41488 --- [ main] l.b.LwM2MTransportBootstrapService : Starting LwM2M transport
2021-09-30 17:21:16.004 INFO 41488 --- [ main] work.RandomTokenGenerator : using tokens of 8 bytes in length
2021-09-30 17:21:16.005 INFO 41488 --- [ main] work.CoapEndpoint :[LWM2M BS Server-coap://] CoapEndpoint uses udp plai n
2021-09-30 17:21:16.007 INFO 41488 --- [ main] work.stack.BlockwiseLayer : BlockwiseLayer uses MAX_MESSAGE_SIZE=1024, PR EFERRED_BLOCK_SIZE=1024, BLOCKWISE_STATUS_LIFETIME=300000, MAX_RESOURCE_BODY_SIZE=268435456, BLOCKWISE_STRICT_BLOCK 2_OPTION=true
2021-09-30 17:21:16.007 INFO 41488 --- [ main] work.stack.ReliabilityLayer : ReliabilityLayer uses ACK_TIMEOUT=2000, ACK_RANDO M_FACTOR=1.5, and ACK_TIMEOUT_SCALE=2.0 as default
2021-09-30 17:21:16.036 INFO 41488 --- [ main] s.dtls.InMemoryConnectionStore : Created new InMemoryConnectionStore [capacity: 150 000, connection expiration threshold: 600s]
2021-09-30 17:21:16.040 INFO 41488 --- [ main] work.RandomTokenGenerator : using tokens of 8 bytes in length
2021-09-30 17:21:16.040 INFO 41488 --- [ main] work.CoapEndpoint :[LWM2M BS Server-coaps://] CoapEndpoint uses lwm2m correlation
2021-09-30 17:21:16.041 INFO 41488 --- [ main] work.stack.BlockwiseLayer : BlockwiseLayer uses MAX_MESSAGE_SIZE=1024, PR EFERRED_BLOCK_SIZE=1024, BLOCKWISE_STATUS_LIFETIME=300000, MAX_RESOURCE_BODY_SIZE=268435456, BLOCKWISE_STRICT_BLOCK 2_OPTION=true
2021-09-30 17:21:16.041 INFO 41488 --- [ main] work.stack.ReliabilityLayer : ReliabilityLayer uses ACK_TIMEOUT=2000, ACK_RANDO M_FACTOR=1.5, and ACK_TIMEOUT_SCALE=2.0 as default
2021-09-30 17:21:16.057 INFO 41488 --- [ main] CoapServer : Starting server
2021-09-30 17:21:16.059 INFO 41488 --- [ main] o.e.californium.elements.UDPConnector : UDPConnector starts up 1 sender threads and 1 recei ver threads
2021-09-30 17:21:16.059 INFO 41488 --- [ main] o.e.californium.elements.UDPConnector : UDPConnector listening on 0.0.0.0/0.0.0.0:5687, recv buf = 65536, send buf = 65536, recv packet size = 2048
2021-09-30 17:21:16.060 INFO 41488 --- [ main] work.CoapEndpoint :[LWM2M BS Server-coap://] Started endpoint at coap://0.
0.0.0:5687
2021-09-30 17:21:16.706 INFO 41488 --- [ main] o.e.californium.scandium.DTLSConnector : multiple network interfaces, using smallest MTU [IPv4 1400, IPv6 1400]
2021-09-30 17:21:16.708 INFO 41488 --- [ main] o.e.californium.scandium.DTLSConnector : DTLSConnector listening on 0.0.0.0/0.0.0.0:5688, rec v buf = 65536, send buf = 65536, recv packet size = 16490, MTU = IPv4 1400 / IPv6 1400
2021-09-30 17:21:16.708 INFO 41488 --- [.0/0.0.0.0:5688] o.e.californium.scandium.DTLSConnecto
r : Starting worker thread [DTLS-Receiver-0-0.0.0.0/ 0.0.0.0:5688]
2021-09-30 17:21:16.708 INFO 41488 --- [ main] work.CoapEndpoint :[LWM2M BS Server-coaps://] Started endpoint at coaps:// 0.0.0.0:5688
2021-09-30 17:21:16.708 INFO 41488 --- [.0/0.0.0.0:5688] o.e.californium.scandium.DTLSConnector : Starting worker thread [DTLS-Receiver-2-0.0.0.0/ 0.0.0.0:5688]
2021-09-30 17:21:16.708 INFO 41488 --- [.0/0.0.0.0:5688] o.e.californium.scandium.DTLSConnector : Starting worker thread [DTLS-Receiver-1-0.0.0.0/ 0.0.0.0:5688]
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论