务必保证至少需要给 docker 分配:1 核 CPU 以及 4G 以上的运行内存!
JDK : 推荐使用 Oracle JDK 1.8
或者 OpenJDK8
,理论来说其他版本也行;
Maven : 推荐使用 Maven 3.8
,理论来说其他版本也行;
IDE : IntelliJ IDEA
或者 Eclipse
,理论来说其他 Java IDE 也行;
Docker : 需要提供 docker
和 docker-compose
指令,至少需要给 docker
分配 4G
的运行内存,建议配置国内镜像加速,下载镜像速度会快一些。
# Added by DC3
127.0.0.1 dc3-mysql
127.0.0.1 dc3-redis
127.0.0.1 dc3-mongo
127.0.0.1 dc3-opentsdb
127.0.0.1 dc3-elasticsearch
127.0.0.1 dc3-rabbitmq
127.0.0.1 dc3-emqx
127.0.0.1 dc3-nginx
127.0.0.1 dc3-influx
# dev
127.0.0.1 dc3-center-register
127.0.0.1 dc3-center-auth
127.0.0.1 dc3-center-manager
127.0.0.1 dc3-center-data
127.0.0.1 dc3-gateway
# End DC3
cd iot-dc3/dc3
#创建并启动 MySQL、MongoDB、Redis、RabbitMQ、Nacos 服务
docker-compose -f docker-compose-dev.yml up -d mysql mongo redis rabbitmq register
#停止 MySQL、MongoDB、Redis、RabbitMQ、Nacos 服务
docker-compose stop mysql mongo redis rabbitmq register
# 下载iot-dc3源码
git clone https://gitee.com/pnoker/iot-dc3.git
cd iot-dc3/dc3/demo
在 Idea 中依次启动:
dc3-center-auth
dc3-center-manager
dc3-center-data
dc3-center-gateway
注意:以下步骤均在iot-dc3目录下完成
1.首先拉取iot-dc3
mkdir iot-dc3
cd iot-dc3
git clone https://gitee.com/pnoker/iot-dc3.git
git checkout main
2.拉取公共模块dc3-common
git clone https://gitee.com/pnoker/dc3-common.git
3.拉取API模块dc3-api
git clone https://gitee.com/pnoker/dc3-api.git
4.拉取驱动SDK模块dc3-driver-sdk
git clone https://gitee.com/pnoker/dc3-driver-sdk.git
5.添加依赖模块
在 iot-dc3 的 pom.xml 中添加 dc3-common、dc3-api、dc3-driver-sdk 即可。
dc3-gateway
dc3-center
dc3-driver
dc3-api
dc3-common
dc3-driver-sdk
以上步骤完成后iot-dc3目录结构如下
.
├── dc3 资源文件,如sh,sql等
├── dc3-api gRpc定义的接口结构
├── dc3-center 平台中心模块
├── dc3-common 平台公共模块
├── dc3-driver 平台驱动模块
├── dc3-driver-sdk 平台驱动SDK模块
└── dc3-gateway 平台网关模块
注意: 以上配置是开启MQTT SSL认证的配置,如果你的MQTT Broker没有开启SSL认证,请将auth-type
设置为NONE
或者注释掉,同时将url设置为普通的tcp://dc3-rabbitmq:1883
这里要改为: auth-type: username
。因为配置了用户名
driver:
schedule:
# 定时读数据
read:
corn: '0/5 * * * * ?'
mqtt:
# url: ${MQTT_BROKER_URL:ssl://dc3-rabbitmq:8883}
# auth-type: X509
url: ${MQTT_BROKER_URL:tcp://dc3-rabbitmq:1883}
auth-type: username
username: dc3
password: dc3
receive-topics:
- qos: 1
name: data
default-send-topic:
qos: 1
name: command
keep-alive: 15
completion-timeout: 3000
batch:
speed: ${MQTT_BATCH_SPEED:100}
interval: ${MQTT_BATCH_INTERVAL:5}
点击安装(opens new window)
记得按图填写json qos:1
topic: dc3/default/dc3-driver-mqtt/data
deviceId: 设备ID, 不是设备名, pointId:位号
{
"id":"1014",
"deviceId":"1694223265544900609",
"pointId":"1694223118807175169",
"value": 263.0,
"createTime": "2022-08-19 14:34:36.111"
}
data:
git clone https://github.com/pnoker/iot-dc3-web.git
cd iot-dc3-web
#这步至关重要, 推荐使用 yarn
npm install -g yarn --registry=https://registry.npm.taobao.org
yarn
yarn serve
3 新增设备:
数据: { “deviceId”: “1694223265544900609”, “pointId”: “1694223118807175169”, “value”: “63.0”}
Caused by: java.nio.charset.MalformedInputException: Input length = 1
at java.nio.charset.CoderResult.throwException(CoderResult.java:281)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:339)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at org.yaml.snakeyaml.reader.UnicodeReader.read(UnicodeReader.java:118)
at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:179)
... 43 common frames omitted
修改yml: auth-type: username
找不到yarn命令。
要配置环境变量: path: 安装时带有的路径:
yarn serve
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.