Fiware チュートリアルをやってみる(コア・コンテキスト管理: 履歴管理)
こちらの続きです。
301. Persisting Context Data using Apache Flume (MongoDB, MySQL, PostgreSQL)
データ永続化コンポーネント FIWARE Cygnus
元々 Orion から MongoDB への接続を行なっているところに、Cygnus からの接続も追加する。
docker-compose の構成が変わった。
├── docker-compose
│ ├── ckan.yml
│ ├── cygnus-only.yml
│ ├── elasticsearch.yml
│ ├── hdfs.yml
│ ├── mongodb.yml
│ ├── multiple.yml
│ ├── mysql.yml
│ └── postgres.yml
./services postgres
の場合は、
docker-compose --log-level ERROR -f docker-compose/postgres.yml -p fiware up -d --remove-orphans
を呼び出す、というように引数によりファイルを切り替えている。
それぞれで、Cygnusのイメージの環境変数を切り替えている。
何が、FLUME なんだ??
302. Persisting Context Data using Apache NIFI (MongoDB, MySQL, PostgreSQL)
今度は、APACHE NIFI。
Apache NIFI を使用してコンテキスト・データを サードパーティのデータベースに永続化してコンテキストの履歴ビューを作成するために 使用される Generic Enabler が、FIWARE Draco 。
MongoDBで起動してみます。
./services mongodb
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7a0b50cbbe6b fiware/iotagent-ul:1.16.2-distroless "/nodejs/bin/node ./…" 58 seconds ago Up 45 seconds (unhealthy) 0.0.0.0:4041->4041/tcp, :::4041->4041/tcp, 0.0.0.0:7896->7896/tcp, :::7896->7896/tcp, 4061/tcp fiware-iot-agent
d4a0daf33242 fiware/orion:3.1.0 "/usr/bin/contextBro…" 58 seconds ago Up 49 seconds (healthy) 0.0.0.0:1026->1026/tcp, :::1026->1026/tcp fiware-orion
7d7d78be8af6 ging/fiware-draco:1.3.6 "../scripts/start.sh" About a minute ago Up 53 seconds (health: starting) 8000/tcp, 8080/tcp, 0.0.0.0:5050->5050/tcp, :::5050->5050/tcp, 8443/tcp, 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp, 10000/tcp fiware-draco
1dc48a3e50a9 fiware/tutorials.context-provider "/nodejs/bin/node ./…" About a minute ago Up 56 seconds (health: starting) 0.0.0.0:3000-3001->3000-3001/tcp, :::3000-3001->3000-3001/tcp fiware-tutorial
97a67f199ce7 mongo:4.4 "docker-entrypoint.s…" About a minute ago Up 57 seconds (healthy) 0.0.0.0:27017->27017/tcp, :::27017->27017/tcp db-mongo
ポート9090は、起動しているように見えるが、レスポンスが返ってこない。
一度再起動したら、OK。
ヴィジュアルツールが提供されているのは面白い。
Google Cloud 最低限の環境(f1-micro(vCPU x 1、メモリ 0.6 GB) ディスク20GB)で、マルチ・エージェントで起動できるか。
./services create
ERROR: for draco write /var/lib/docker/tmp/GetImageBlob754515464: no space left on device
ERROR: for postgres-db failed to register layer: Error processing tar file(exit status 1): write /usr/lib/x86_64-linux-gnu/perl/5.28.1/auto/Encode/CN/CN.so: no space left on device
ERROR: for mysql-db failed to register layer: Error processing tar file(exit status 1): write /usr/bin/mysqldump: no space left on device
ERROR: failed to register layer: Error processing tar file(exit status 1): write /usr/bin/mysqldump: no space left on device
まじか・・・
docker image 整理
記憶のないものがたくさん・・・
docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mongo 4.4 3d97b76ddd76 2 weeks ago 437MB
curlimages/curl latest b920a0fc25ef 4 weeks ago 8.3MB
fiware/tutorials.context-provider latest 4c6eb22691e9 5 weeks ago 157MB
fiware/orion 3.1.0 ed8c1a9ef0d4 2 months ago 686MB
fiware/iotagent-ul 1.16.2-distroless ed2cf26d7d8a 4 months ago 125MB
jrcs/letsencrypt-nginx-proxy-companion latest 890c9ade6c79 15 months ago 93.8MB
<none> <none> f74ea36fabb2 2 years ago 564MB
mysql 5.7 a1aa4f76fab9 2 years ago 373MB
python 3.6-alpine 35bb01a3d284 2 years ago 79.1MB
app_app latest b466c70b871d 2 years ago 198MB
<none> <none> 8c53b9a4bc07 2 years ago 172MB
<none> <none> 7b32ccd64950 2 years ago 172MB
<none> <none> 6f29f2b75d72 2 years ago 77.6MB
<none> <none> b66982e70e90 2 years ago 77.6MB
<none> <none> 3528d23162bd 2 years ago 77.6MB
node 12.1.0-alpine 4acd7c5129dc 2 years ago 77.6MB
kusanagi-php7 latest 2fc10ebcd40a 2 years ago 84.3MB
jwilder/nginx-proxy latest 1e3c23efda58 2 years ago 148MB
jrcs/letsencrypt-nginx-proxy-companion <none> ea7851c844f8 2 years ago 84.5MB
busybox latest 59788edf1f3e 2 years ago 1.15MB
hello-world latest 4ab4c602aa5e 2 years ago 1.84kB
phpmyadmin/phpmyadmin latest 126b8717cebb 2 years ago 166MB
node 10.8.0-stretch 383051761be5 3 years ago 892MB
lambci/lambda python3.6 967e6126baee 3 years ago 1.1GB
lambci/lambda python2.7 90dfb97cdf37 3 years ago 972MB
lambci/lambda nodejs6.10 ef2ecfc76dc5 3 years ago 1.02GB
lambci/lambda nodejs4.3 56e236ebed53 3 years ago 967MB
php 7.0.16-fpm-alpine 8c52af6828a9 4 years ago 68MB
mariadb 10.1.21 56741a13bbb9 4 years ago 393MB
orion は意外と大きい。
過去のイメージは一旦削除。
docker rm ・・・
docker rmi ・・・
ging/fiware-draco 1.3.6 3ce4db682b5c 5 months ago 1.98GB
でかい。
さて、どうか。
./services multiple
ERROR: for iot-agent UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).
厳しい・・・
VM再起動して、改めて実施したら、苦しみながらなんとか立ち上がったという感じがしたけど、
Draco HTTP state: 000 (waiting for 200)
Draco HTTP state: 000 (waiting for 200)
Draco HTTP state: 000 (waiting for 200)
延々続いている。無理っぽい
./services mysql
もだめ
./services mongodb
もだめ
あきらめる。
draco 消さないと後ができない。
303. Querying Time Series Data (MongoDB)
時系列データのクエリ (MONGO-DB)
今度は、STH-Comet というGE。Mong-DB に永続化された時系列データの永続化と解釈 の問題に特化。
最小モードだと、STH-Comet でデータの読み書きをしてしまいますが、正規モードだと、書き込みはCygnusで行う。
304. Querying Time Series Data (CrateDB)
時系列データのクエリ (CRATE-DB)
結果は、グラフまたは Grafana 時系列分析ツールを介して視覚化されます。
という点に期待。
しかし、もう一つDB立ち上げるのはキツそう・・・
と思ったら、これは起動するんだ。かなり時間かかるけど。
curl -iX POST \
'http://localhost:1026/v2/subscriptions/' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"description": "description": "Notify QuantumLeap of count changes of any Motion Sensor",
"subject": {
"entities": [
{
"idPattern": "Motion.*"
}
],
"condition": {
"attrs": [
"count"
]
}
},
"notification": {
"http": {
"url": "http://quantumleap:8668/v2/notify"
},
"attrs": [
"count"
],
"metadata": ["dateCreated", "dateModified"]
},
"throttling": 1
}'
HTTP/1.1 400 Bad Request
Connection: Keep-Alive
Content-Length: 75
Content-Type: application/json
Fiware-Correlator: 5e022964-0169-11ec-b3eb-0242ac120105
Date: Fri, 20 Aug 2021 03:47:40 GMT
{"error":"ParseError","description":"Errors found in incoming JSON buffer"}
あら、エラー
descriptionの部分の記述がおかしい。
curl -iX POST \
'http://localhost:1026/v2/subscriptions/' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"description": "Notify QuantumLeap of count changes of any Motion Sensor",
"subject": {
"entities": [
{
"idPattern": "Motion.*"
}
],
"condition": {
"attrs": [
"count"
]
}
},
"notification": {
"http": {
"url": "http://quantumleap:8668/v2/notify"
},
"attrs": [
"count"
],
"metadata": ["dateCreated", "dateModified"]
},
"throttling": 1
}'
OK。プルリク送ってみました。
永続化したデータを色々な条件で取得。
Grafana Dashboard かっこいい
305. Big Data Analysis (Flink)
最も 人気のあるビッグデータ・プラットフォームの1つである Apache Flink
最も人気のある BigData プラットフォームの1つである Apache Spark
Apache ふたつも作ったの?
後半は流し読み・・・
Discussion