偶然间听闻物联网砰砰砰,狂战几天几夜...因而乎就有了如今写博客的我,本文是基于centos7.6系统环境搭建,旨为与对开源的物联网平台(thingsboard)感兴趣的同窗一块儿研究,欢迎指正交流!html
话很少说,开码→.→java
github地址:https://github.com/thingsboard/thingsboardnode
github docs网址:https://thingsboard.io/docs/getting-started-guides/helloworld/linux
github demo:https://demo.thingsboard.io/logingit
git(码云): https://gitee.com/mirrors/ThingsBoardgithub
CSDN大佬1: http://www.javashuo.com/article/p-znprxwty-z.htmlweb
博客园大佬1: https://www.cnblogs.com/danny-djy/p/9051714.htmlredis
segmentfault大佬: https://segmentfault.com/a/1190000019755315?utm_source=tag-newestspring
Xsheel: 连接:https://pan.baidu.com/s/1x8a66d1dwrUbaClRaJUMRw 提取码:c7t9sql
Xftp: 连接:https://pan.baidu.com/s/1zAvh1Gupx-G1ZKhYOefcTw 提取码:ox6g
VMware12: 连接:https://pan.baidu.com/s/1PQ4GiblqmWhDADjpGxwK-Q 提取码:h1ku
CentOS-7-x86_64-DVD-1810.iso: 连接:https://pan.baidu.com/s/1Zp_gmfCk78nggrEIqxdoQA 提取码:chmo
下载 : jdk-8u211-linux-x64.tar.gz(网上处处都是...),用Xftp传到Linux端的 /usr/local/temp
解压&配置环境变量 :
cd /usr/local/temp
tar vzxf jdk-8u211-linux-x64.tar.gz
mv jdk-8u211-linux-x64 /usr/local/jdk8
vi /etc/profile
添加
export JAVA_HOME=/usr/local/jdk-1.8.0
export PATH=$PATH:$JAVA_HOME/bin
source /etc/profile
java -version
如图为安装成功:
下载 : apache-maven-3.6.1-bin.tar.gz,用Xftp传到Linux端的 /usr/local/temp
解压&配置环境变量 :
cd /usr/local/temp
tar vzxf apache-maven-3.6.1-bin.tar.gz
mv apache-maven-3.6.1-bin /usr/local/apache-maven-3.6.1
vi /etc/profile
添加
export M2_HOME=/usr/local/apache-maven-3.6.1
export PATH=$PATH:${M2_HOME}/bin
source /etc/profile
mvn -version
如图为安装成功:
注意修改配置文件:加粗字体部分
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.conf}/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ${user.home}/.m2/repository <localRepository>/path/to/local/repo</localRepository> --> <!--修改localRepository开始--!> <localRepository>/usr/local/.m2/repository</localRepository> <!--修改localRepository开始--!> <!-- interactiveMode | This will determine whether maven prompts you when it needs input. If set to false, | maven will use a sensible default value, perhaps based on some other setting, for | the parameter in question. | | Default: true <interactiveMode>true</interactiveMode> --> <!-- offline | Determines whether maven should attempt to connect to the network when executing a build. | This will have an effect on artifact downloads, artifact deployment, and others. | | Default: false <offline>false</offline> --> <!-- pluginGroups | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e. | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list. |--> <pluginGroups> <!-- pluginGroup | Specifies a further group identifier to use for plugin lookup. <pluginGroup>com.your.plugins</pluginGroup> --> </pluginGroups> <!-- proxies | This is a list of proxies which can be used on this machine to connect to the network. | Unless otherwise specified (by system property or command-line switch), the first proxy | specification in this list marked as active will be used. |--> <proxies> <!-- proxy | Specification for one proxy, to be used in connecting to the network. | <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.host.net</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies> <!-- servers | This is a list of authentication profiles, keyed by the server-id used within the system. | Authentication profiles can be used whenever maven must make a connection to a remote server. |--> <servers> <!-- server | Specifies the authentication information to use when connecting to a particular server, identified by | a unique name within the system (referred to by the 'id' attribute below). | | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are | used together. | <server> <id>deploymentRepo</id> <username>repouser</username> <password>repopwd</password> </server> --> <!-- Another sample, using keys to authenticate. <server> <id>siteServer</id> <privateKey>/path/to/private/key</privateKey> <passphrase>optional; leave empty if not used.</passphrase> </server> --> </servers> <!-- mirrors | This is a list of mirrors to be used in downloading artifacts from remote repositories. | | It works like this: a POM may declare a repository to use in resolving certain artifacts. | However, this repository may have problems with heavy traffic at times, so people have mirrored | it to several places. | | That repository definition will have a unique id, so we can create a mirror reference for that | repository, to be used as an alternate download site. The mirror site will be the preferred | server for that repository. |--> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | <mirror> <id>mirrorId</id> <mirrorOf>repositoryId</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://my.repository.com/repo/path</url> </mirror> --> <!--修改mirror开始--!> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </mirror> <!--修改mirror结束--!> </mirrors> <!-- profiles | This is a list of profiles which can be activated in a variety of ways, and which can modify | the build process. Profiles provided in the settings.xml are intended to provide local machine- | specific paths and repository locations which allow the build to work in the local environment. | | For example, if you have an integration testing plugin - like cactus - that needs to know where | your Tomcat instance is installed, you can provide a variable here such that the variable is | dereferenced during the build process to configure the cactus plugin. | | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles | section of this document (settings.xml) - will be discussed later. Another way essentially | relies on the detection of a system property, either matching a particular value for the property, | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. | Finally, the list of active profiles can be specified directly from the command line. | | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact | repositories, plugin repositories, and free-form properties to be used as configuration | variables for plugins in the POM. | |--> <profiles> <!-- profile | Specifies a set of introductions to the build process, to be activated using one or more of the | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> | or the command line, profiles have to have an ID that is unique. | | An encouraged best practice for profile identification is to use a consistent naming convention | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. | This will make it more intuitive to understand what the set of introduced profiles is attempting | to accomplish, particularly when you only have a list of profile id's for debug. | | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. <profile> <id>jdk-1.4</id> <activation> <jdk>1.4</jdk> </activation> <repositories> <repository> <id>jdk14</id> <name>Repository for JDK 1.4 builds</name> <url>http://www.myhost.com/maven/jdk14</url> <layout>default</layout> <snapshotPolicy>always</snapshotPolicy> </repository> </repositories> </profile> --> <!-- | Here is another profile, activated by the system property 'target-env' with a value of 'dev', | which provides a specific path to the Tomcat instance. To use this, your plugin configuration | might hypothetically look like: | | ... | <plugin> | <groupId>org.myco.myplugins</groupId> | <artifactId>myplugin</artifactId> | | <configuration> | <tomcatLocation>${tomcatPath}</tomcatLocation> | </configuration> | </plugin> | ... | | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to | anything, you could just leave off the <value/> inside the activation-property. | <profile> <id>env-dev</id> <activation> <property> <name>target-env</name> <value>dev</value> </property> </activation> <properties> <tomcatPath>/path/to/tomcat/instance</tomcatPath> </properties> </profile> --> </profiles> <!-- activeProfiles | List of profiles that are active for all builds. | <activeProfiles> <activeProfile>alwaysActiveProfile</activeProfile> <activeProfile>anotherAlwaysActiveProfile</activeProfile> </activeProfiles> --> </settings>
下载 : node-v10.15.1-linux-x64.tar.gz,用Xftp传到Linux端的 /usr/local/temp
解压&配置环境变量 :
cd /usr/local/temp
tar vzxf node-v10.15.1-linux-x64.tar.gz
mv node-v10.15.1-linux-x64 /usr/local/node-v10.15.1
vi /etc/profile
添加
export NODE_HOME=/opt/software/node-v10.15.1-linux-x64
export PATH=$PATH:${NODE_HOME}/bin
source /etc/profile
node -v
npm -v
如图为安装成功:
下载 : git-2.8.6.tar.gz,用Xftp传到Linux端的 /usr/local/temp
解压 :
cd /usr/local/temp
tar vzxf git-2.8.6.tar.gz
mv git-2.8.6 /usr/local/git-2.8.6
编译安装 :
cd /usr/local/git-2.8.6
make configure
./configure --prefix=/usr/git ##配置目录
make profix=/usr/git
make install
配置环境变量 :
vi /etc/profile
添加
export PATH="/usr/local/git/bin:$PATH"
source /etc/profile
git --version
如图为安装成功:
推荐大佬安装操做:https://www.cnblogs.com/netonline/p/7657810.html
万事俱备只欠源码~~~
cd ~
git clone git@github.com:thingsboard/thingsboard.git
或者
更加简单粗暴将码云上的release-2.3以zip下载的方式下载下来,在用xftp传到Linux安装目录(次例直接放置root下) <font color="red">[推荐此方法]</font>
强烈建议和我同样的小白们利用Xftp和notpad++在Windows操做!
1. 修改thingsboard-release-2.3的pom.xml(绕过License选项)
注释如下代码:
<!-->约275行<--!> <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId> <version>3.0</version> <configuration> .... </plugin>
2. 修改thingsboard-release-2.3下的application/src/main/resources/thingsboard.yml文件
注释HSQLDB,开启PostgreSQL
# HSQLDB DAO Configuration #spring: # data: # jpa: # repositories: # enabled: "true" # jpa: # hibernate: # ddl-auto: "validate" # database-platform: "${SPRING_JPA_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_si#ze=false;hsqldb.log_size=5}" # username: "${SPRING_DATASOURCE_USERNAME:sa}" # password: "${SPRING_DATASOURCE_PASSWORD:}" # PostgreSQL DAO Configuration spring: data: sql: repositories: enabled: "true" sql: hibernate: ddl-auto: "validate" 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}"//只前安装PostgreSQL时设置的 password: "${SPRING_DATASOURCE_PASSWORD:postgres}"//用户名和密码
注释如下部分 :
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.0.0</version> <configuration> <finalName>${pkg.name}</finalName> <descriptors> <descriptor>src/main/assembly/windows.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
进入源码thingsboard-release-2.3
cd ~/thingsboard-release-2.3
mvn clean install -DskipTests -X
<font color="red">注意编译时间较长,还可鞥须要屡次编译,各类坑等着你呢...如下是我遇到的几个坑:</font>
1. ui部分报错 :
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.0.....................(没截上图...翻得百度搜索记录)
解决:
百度半天没啥luan用,仍是的本身看ERROR...分析到是npm install的时候出问题,结合报错看出node_modules某个module没有下载下来,而后在Xftp根据报错提示查看modules的位置确实没有报错模块文件夹及文件(高兴地一批嘻嘻终于有点儿眉目),再而后手动在win环境npm install module名 -g (一次没能行垃圾网络,第二次成功下载),在到node全局modules文件夹中把下载的相关模块文件夹copy到报错模块路径中,在编译
2. java报错 :
编译ui时报错:Failed to create assembly: Error creating assembly archive windows: Problem.................(同上)
解决:
糟心半天,灵光一现以前不是删过pom.xml中的maven-assembly-plugin配置吗,抱着试试的心...,修改了ui/pom.xml文件,注释了如下配置:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.0.0</version> <configuration> <finalName>${pkg.name}</finalName> <descriptors> <descriptor>src/main/assembly/windows.xml</descriptor> </descriptors> </configuration> <executions> <execution> <id>assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>
再次编译:OK 如图:
找到编译好的安装文件
[root@localhost thingsboard-release-2.3]# cd application/target
运行安装
[root@localhost thingsboard-release-2.3]# cd application/target
[root@localhost thingsboard-release-2.3]# sudo rpm -Uvh thingsboard.rpm
此时,出现一个问题:依赖检测失败
缘由:
咱们安装的jdk问题!须要的是OpenJDK(JDK与OpenJDK的区别)
解决:卸载以前的jdk(记得注释环境变量),安装openjdk
[root@localhost thingsboard-release-2.3]# sudo yum install java-1.8.0-openjdk -y
[root@localhost thingsboard-release-2.3]# sudo yum install java-1.8.0-openjdk-devel -y
[root@localhost thingsboard-release-2.3]# java -version
[root[@localhost](https://my.oschina.net/u/570656) thingsboard-release-2.3]# openjdk version "1.8.0_181" OpenJDK Runtime Environment (build 1.8.0_181-b13) OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
再次运行安装ok,继续下一步
[root@localhost thingsboard-release-2.3]# cd /usr/share/thingsboard/bin/install
[root@localhost thingsboard-release-2.3]# ll
[root@localhost thingsboard-release-2.3]#./install.sh --loadDemo
启动服务
[root@localhost thingsboard-release-2.3]#service thingsboard start
完成
可是在thingsboard-release-2.3出现个问题服务正常开启!!!数据库正常链接!!!各项配置ok!!!测试http:localhost:8080报出404
再次更换thingsboard v2.1版本进行前面第三步的编译!!!
直接到:
鉴于上一次的失败,此次我选择江编译好的项目导入IDEA进行run as:
前提:
1 . 数据库:用navicat链接postgreSQL,导入数据(导入数据为dao包下的sql):
方便测试这里直接修改默认后台的系统管理员帐号 用户名:sysadmin@thingsboard.org 密码:sysadmin为:
用户名:admin@thingsboard.org 密码:sysadmin
2 . redis(windows端)
注意:链接测试(在redis目录下在起一个cmd):
D:\soft\Redis-x64-3.2.100> redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1:6379> set myKey abc
OK
127.0.0.1:6379> get myKey
"abc"
127.0.0.1:6379>
Run as "ThingsboardServerApplication"
浏览器打开"http://127.0.0.1:8080"
用户名:admin@thingsboard.org 密码:sysadmin登陆
完成!告辞~~~