PM2M Docker: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(11 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
2) Installer les clients Mosquitto pour souscrire et publier sur les sujets (ie topics) |
2) Installer les clients Mosquitto pour souscrire et publier sur les sujets (ie topics) |
||
<pre> |
<pre> |
||
sudo apt install -y mosquitto-clients |
sudo apt install -y mosquitto-clients |
||
⚫ | |||
BROKER=test.mosquitto.org |
|||
⚫ | |||
⚫ | |||
⚫ | |||
mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m 'deveui=fridge123;temp=20.0;hum=10;open=true' |
|||
mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m '{"deveui":"fridge123","temp":20.0,"hum":10,"open":true}' |
|||
BROKER=localhost |
|||
mosquitto_sub -h $BROKER -t "iot_pm2m/1718/groupe1/#" -v |
|||
mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1/fridge123" -v -m 'temp=20.0;hum=10;open=true' |
|||
mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m 'deveui=fridge123;temp=20.0;hum=10;open=true' |
|||
mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m '{"deveui":"fridge123","temp":20.0,"hum":10,"open":true}' |
|||
</pre> |
</pre> |
||
Lancer le client Web MQTT [http://www.hivemq.com/demos/websocket-client/ HiveMQ] ou [https://www.hivemq.com/blog/mqtt-toolbox-mqtt-lens MQTT Lens]. |
|||
Line 34: | Line 47: | ||
LOCAL_HOST=$(name_to_ipaddress localhost) |
LOCAL_HOST=$(name_to_ipaddress localhost) |
||
echo $LOCAL_HOST |
echo $LOCAL_HOST |
||
Line 41: | Line 53: | ||
# ------------------------------- |
# ------------------------------- |
||
docker rm -f mosquitto_for_iot |
|||
docker rm -f influxdb_for_iot |
docker rm -f influxdb_for_iot |
||
docker rm -f mongodb_for_iot |
docker rm -f mongodb_for_iot |
||
Line 49: | Line 62: | ||
rm -fr influxdb mongo grafana chronograf |
rm -fr influxdb mongo grafana chronograf |
||
rm -f lib/flows/* |
rm -f lib/flows/* |
||
# ------------------------------- |
|||
# Mosquitto |
|||
# ------------------------------- |
|||
docker pull eclipse-mosquitto |
|||
docker run -d --name nodered_for_iot \ |
|||
-p 1883:1883 -p 9001:9001 \ |
|||
mosquitto_for_iot |
|||
# ------------------------------- |
# ------------------------------- |
||
Line 69: | Line 93: | ||
# ------------------------------- |
# ------------------------------- |
||
# NodeRED |
|||
# Influx DB |
|||
# ------------------------------- |
# ------------------------------- |
||
docker pull nodered/node-red-docker |
docker pull nodered/node-red-docker |
||
Line 77: | Line 101: | ||
-v $LOCALDIR:/data \ |
-v $LOCALDIR:/data \ |
||
-p $NODERED_WEB_PORT:1880 \ |
-p $NODERED_WEB_PORT:1880 \ |
||
-p 1680:1680/udp \ |
|||
-p 7080:8080 \ |
|||
--add-host=influxdb-1:$LOCAL_HOST \ |
--add-host=influxdb-1:$LOCAL_HOST \ |
||
--add-host=mongodb-1:$LOCAL_HOST \ |
--add-host=mongodb-1:$LOCAL_HOST \ |
||
Line 89: | Line 115: | ||
npm install node-red-contrib-kafka-node |
npm install node-red-contrib-kafka-node |
||
npm install node-red-contrib-web-worldmap |
npm install node-red-contrib-web-worldmap |
||
npm install node-red/node-red-dashboard |
|||
npm install -g node-red-admin |
npm install -g node-red-admin |
||
Line 116: | Line 144: | ||
-v chronograf:/var/lib/chronograf \ |
-v chronograf:/var/lib/chronograf \ |
||
chronograf |
chronograf |
||
# ------------------------------- |
|||
# Huginn https://github.com/huginn/huginn |
|||
# ------------------------------- |
|||
echo Browse http://localhost:3000 |
|||
echo Log in to your Huginn instance using the username admin and password password |
|||
docker run -d --name huginn_for_iot \ |
|||
--hostname huginn \ |
|||
-p 3000:3000 \ |
|||
huginn/huginn |
|||
docker logs --follow huginn_for_iot |
|||
^C |
|||
# ------------------------------- |
|||
# Nifi https://nifi.apache.org/ |
|||
# ------------------------------- |
|||
docker run --name nifi_for_iot \ |
|||
-p 9090:9090 \ |
|||
-d \ |
|||
-e NIFI_WEB_HTTP_PORT='9090' \ |
|||
apache/nifi:latest |
|||
# ------------------------------- |
# ------------------------------- |
||
Line 127: | Line 180: | ||
# ------------------------------- |
# ------------------------------- |
||
docker stop mosquitto_for_iot |
|||
docker stop influxdb_for_iot |
docker stop influxdb_for_iot |
||
docker stop mongodb_for_iot |
docker stop mongodb_for_iot |
||
Line 132: | Line 186: | ||
docker stop grafana_for_iot |
docker stop grafana_for_iot |
||
docker stop chronograf_for_iot |
docker stop chronograf_for_iot |
||
docker stop huginn_for_iot |
|||
docker stop nifi_for_iot |
|||
docker start mosquitto_for_iot |
|||
docker start influxdb_for_iot |
docker start influxdb_for_iot |
||
docker start mongodb_for_iot |
docker start mongodb_for_iot |
||
Line 138: | Line 195: | ||
docker start grafana_for_iot |
docker start grafana_for_iot |
||
docker start chronograf_for_iot |
docker start chronograf_for_iot |
||
docker start huginn_for_iot |
|||
docker start nifi_for_iot |
|||
</pre> |
</pre> |
||
4) Visualiser |
|||
⚫ | |||
* http://localhost:1880 |
|||
* http://localhost:1880/worldmap |
|||
5) Ecrire et tester un fichier iot_mashup.yml pour [https://docs.docker.com/compose/ Docker Compose] |
|||
=Bonus track= |
|||
⚫ |
Latest revision as of 13:51, 20 March 2018
1) Installer Docker sur votre machine
2) Installer les clients Mosquitto pour souscrire et publier sur les sujets (ie topics)
sudo apt install -y mosquitto-clients BROKER=test.mosquitto.org mosquitto_sub -h $BROKER -t "iot_pm2m/1718/groupe1/#" -v mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1/fridge123" -v -m 'temp=20.0;hum=10;open=true' mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m 'deveui=fridge123;temp=20.0;hum=10;open=true' mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m '{"deveui":"fridge123","temp":20.0,"hum":10,"open":true}' BROKER=localhost mosquitto_sub -h $BROKER -t "iot_pm2m/1718/groupe1/#" -v mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1/fridge123" -v -m 'temp=20.0;hum=10;open=true' mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m 'deveui=fridge123;temp=20.0;hum=10;open=true' mosquitto_pub -h $BROKER -t "iot_pm2m/1718/groupe1" -v -m '{"deveui":"fridge123","temp":20.0,"hum":10,"open":true}'
Lancer le client Web MQTT HiveMQ ou MQTT Lens.
3) Lancer les containers Docker suivant
# NodeRED app for collect sensors data name_to_ipaddress(){ ifconfig | grep "inet " |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' | grep -v "127.0.0.1" | head -1 } NODERED_WEB_PORT=1880 NODERED_ADMIN_PASSWORD="MUST_BE_CHANGED" # Note : Password can be crypt and set into settings.js with node-red-admin hash-pw GF_PORT=3600 GF_PASSWORD="MUST_BE_CHANGED" MQTT_BROKER_1=mqtt01 MQTT_BROKER_2=mqtt02 MQTT_BROKER_1=test.mosquitto.org MQTT_BROKER_2=test.mosquitto.org LOCAL_HOST=$(name_to_ipaddress localhost) echo $LOCAL_HOST # ------------------------------- # Clean # ------------------------------- docker rm -f mosquitto_for_iot docker rm -f influxdb_for_iot docker rm -f mongodb_for_iot docker rm -f nodered_for_iot docker rm -f grafana_for_iot docker rm -f chronograf_for_iot rm -fr influxdb mongo grafana chronograf rm -f lib/flows/* # ------------------------------- # Mosquitto # ------------------------------- docker pull eclipse-mosquitto docker run -d --name nodered_for_iot \ -p 1883:1883 -p 9001:9001 \ mosquitto_for_iot # ------------------------------- # Influx DB # ------------------------------- mkdir influxdb docker pull influxdb docker run -d --name influxdb_for_iot \ -p 8086:8086 \ -p 8083:8083 \ -v influxdb:/var/lib/influxdb \ influxdb # ------------------------------- # MongoDB # ------------------------------- docker run -d --name mongodb_for_iot \ -p 27017:27017 \ mongo # ------------------------------- # NodeRED # ------------------------------- docker pull nodered/node-red-docker LOCALDIR=$(pwd) docker run -d --name nodered_for_iot \ -v $LOCALDIR:/data \ -p $NODERED_WEB_PORT:1880 \ -p 1680:1680/udp \ -p 7080:8080 \ --add-host=influxdb-1:$LOCAL_HOST \ --add-host=mongodb-1:$LOCAL_HOST \ -e FLOWS=lora.flow.json \ -e NODE_OPTIONS="--max_old_space_size=128" \ nodered/node-red-docker npm install node-red-contrib-influxdb npm install node-red-node-mongodb npm install node-red-contrib-pubnub npm install node-red-contrib-ifttt npm install node-red-contrib-kafka-node npm install node-red-contrib-web-worldmap npm install node-red/node-red-dashboard npm install -g node-red-admin node-red-admin target http://localhost:$PORT node-red-admin list node-red-admin install node-red-contrib-influxdb # ------------------------------- # Grafana # ------------------------------- docker run -d --name grafana_for_iot \ -p $GF_PORT:3000 \ --add-host=influxdb-1:$LOCAL_HOST \ -e "GF_SECURITY_ADMIN_PASSWORD=$GF_PASSWORD" \ grafana/grafana # ------------------------------- # Chronograf # ------------------------------- mkdir chronograf docker run -d --name chronograf_for_iot \ -p 18888:8888 \ --add-host=influxdb-1:$LOCAL_HOST \ -v chronograf:/var/lib/chronograf \ chronograf # ------------------------------- # Huginn https://github.com/huginn/huginn # ------------------------------- echo Browse http://localhost:3000 echo Log in to your Huginn instance using the username admin and password password docker run -d --name huginn_for_iot \ --hostname huginn \ -p 3000:3000 \ huginn/huginn docker logs --follow huginn_for_iot ^C # ------------------------------- # Nifi https://nifi.apache.org/ # ------------------------------- docker run --name nifi_for_iot \ -p 9090:9090 \ -d \ -e NIFI_WEB_HTTP_PORT='9090' \ apache/nifi:latest # ------------------------------- # Logs # ------------------------------- docker logs --follow nodered_for_iot tail -f logfile.txt # ------------------------------- # Stop then Start # ------------------------------- docker stop mosquitto_for_iot docker stop influxdb_for_iot docker stop mongodb_for_iot docker stop nodered_for_iot docker stop grafana_for_iot docker stop chronograf_for_iot docker stop huginn_for_iot docker stop nifi_for_iot docker start mosquitto_for_iot docker start influxdb_for_iot docker start mongodb_for_iot docker start nodered_for_iot docker start grafana_for_iot docker start chronograf_for_iot docker start huginn_for_iot docker start nifi_for_iot
4) Visualiser
5) Ecrire et tester un fichier iot_mashup.yml pour Docker Compose