Connect 系统,包括 OPC UA IoT Agent、Orion Context Broker。使用 Postgres 的 Cygnus 和历史数据
Connect system which includes OPC UA IoT Agent, Orion Context Broker. Cygnus and Historic data with Postgres
我正在尝试建立一个系统来保存历史数据,流程如下:
Prosys OPC-UA 服务器模拟 -> OPC-UA FIWARE 物联网代理 -> Orion 上下文代理 -> FIWARE Cygnus 连接器 -> PostgreSQL 数据库。
这是我用来编写 docker-compose
文件的文档:
这是我使用的 docker-compose
和 .env
文件
docker-compose.yml
version: "3"
#secrets:
# age_idm_auth:
# file: age_idm_auth.txt
services:
iotage:
hostname: iotage
image: iotagent4fiware/iotagent-opcua:1.3.4
networks:
- hostnet
- iotnet
ports:
- "${AGENT_SERVER_PORT}:${AGENT_SERVER_PORT}"
- "4081:8080"
extra_hosts:
- "iotcarsrv:192.168.50.167"
- "HP:192.168.50.167"
depends_on:
- iotmongo
- orion
volumes:
- ./AGECONF:/opt/iotagent-opcua/conf
- ./certificates/charm:/opt/iotagent-opcua/certificates
command: /usr/bin/tail -f /var/log/lastlog
iotmongo:
hostname: iotmongo
image: mongo:3.4
networks:
- iotnet
volumes:
- iotmongo_data:/data/db
- iotmongo_conf:/data/configdb
################ OCB ################
orion:
hostname: orion
image: fiware/orion:latest
networks:
- hostnet
- ocbnet
ports:
- "${ORION_PORT}:${ORION_PORT}"
depends_on:
- orion_mongo
#command: -dbhost mongo
entrypoint: /usr/bin/contextBroker -fg -multiservice -ngsiv1Autocast -statCounters -dbhost mongo -logForHumans -logLevel DEBUG -t 255
orion_mongo:
hostname: orion_mongo
image: mongo:3.4
networks:
ocbnet:
aliases:
- mongo
volumes:
- orion_mongo_data:/data/db
- orion_mongo_conf:/data/configdb
command: --nojournal
############### CYGNUS ###############
cygnus:
image: fiware/cygnus-ngsi:${CYGNUS_VERSION}
hostname: cygnus
container_name: fiware-cygnus
networks:
- hostnet
depends_on:
- postgres-db
expose:
- "${CYGNUS_POSTGRESQL_SERVICE_PORT}" # 5055
- "${CYGNUS_API_PORT}" # 5080
ports:
- "${CYGNUS_POSTGRESQL_SERVICE_PORT}:${CYGNUS_POSTGRESQL_SERVICE_PORT}"
- "${CYGNUS_API_PORT}:${CYGNUS_API_PORT}"
environment:
- "CYGNUS_POSTGRESQL_SERVICE_PORT=${CYGNUS_POSTGRESQL_SERVICE_PORT}"
- "CYGNUS_POSTGRESQL_HOST=postgres-db" # Hostname of the PostgreSQL server used to persist historical contex
- "CYGNUS_POSTGRESQL_PORT=${POSTGRES_DB_PORT}" # Port that the PostgreSQL server uses to listen to commands
- "CYGNUS_POSTGRESQL_DATABASE=postgres"
- "CYGNUS_POSTGRESQL_USER=postgres" # Username for the PostgreSQL database user
- "CYGNUS_POSTGRESQL_PASS=password" # Password for the PostgreSQL database user
- "CYGNUS_POSTGRESQL_ENABLE_CACHE=true" # Switch to enable caching within the PostgreSQL configuration
- "CYGNUS_SERVICE_PORT=${CYGNUS_POSTGRESQL_SERVICE_PORT}" # Notification Port that Cygnus listens when subcr
- "CYGNUS_API_PORT=${CYGNUS_API_PORT}" # Port that Cygnus listens on for operational reasons
- "CYGNUS_LOG_LEVEL=DEBUG" # The logging level for Cygnus
postgres-db:
image: postgres
hostname: postgres-db
expose:
- "${POSTGRES_DB_PORT}"
ports:
- "${POSTGRES_DB_PORT}:${POSTGRES_DB_PORT}"
networks:
- hostnet
environment:
- "POSTGRES_PASSWORD=password"
- "POSTGRES_USER=postgres"
- "POSTGRES_DB=postgres"
volumes:
- postgres-db:/var/lib/postgresql/data
volumes:
iotmongo_data:
iotmongo_conf:
orion_mongo_data:
orion_mongo_conf:
postgres-db:
networks:
hostnet:
iotnet:
ocbnet:
.env
# Orion
ORION_PORT=1026
# PostgreSQL
POSTGRES_DB_PORT=5432
# OPCUA IoT Agent
AGENT_SERVER_PORT=4001
# Cygnus
CYGNUS_VERSION=2.10.0
CYGNUS_API_PORT=5080
CYGNUS_MYSQL_SERVICE_PORT=5050
CYGNUS_MONGO_SERVICE_PORT=5051
CYGNUS_CKAN_SERVICE_PORT=5052
CYGNUS_HDFS_SERVICE_PORT=5053
CYGNUS_CARTO_SERVICE_PORT=5054
CYGNUS_POSTGRESQL_SERVICE_PORT=5055
CYGNUS_ORION_SERVICE_PORT=5056
CYGNUS_POSTGIS_SERVICE_PORT=5057
CYGNUS_ELASTICSEARCH_SERVICE_PORT=5058
CYGNUS_ARCGIS_SERVICE_PORT=5059
我可以看到系统已启动并且没有从 docker 通知的错误
docker ps -a
result
但是,当我使用 pgAdmin 或 docker exec
检查 postgres 数据库时,里面什么也没有。
\dt
psql 命令给了我 Did not find any relation
这意味着没有任何内容登录到数据库中。
请帮助结合 FIWARE 的这两个组件(物联网 OPCUA 代理和 Cygnus)。我也不清楚 Cygnus 连接器是否会为我们创建数据库。
[编辑]
该组件似乎正在工作:
模拟服务器
所有服务
Cynus 仅通知我 'Configuration has no change',当我使用 docker exec
进入容器时,从 Cygnus 我能够 ping orion 和 postgresql 数据库容器
在 postgresql 中:我没有看到所需的数据库或 table
我的模拟服务器 -> OPCUA IoT 代理 -> Orion 系统运行良好,因为从 docker logs
我仍然能够获得模拟服务器的更新值:
这里有一个复杂的场景,由 5 个组件的端到端链组成:
- Prosys OPC-UA 服务器模拟
- OPC-UA FIWARE物联网代理
- Orion 上下文代理
- FIWARE Cygnus 连接器
- PostgreSQL 数据库
我在这里的建议是检查链中的每个步骤(查看日志等)以确保在检查下一步之前一切正确。
我正在尝试建立一个系统来保存历史数据,流程如下: Prosys OPC-UA 服务器模拟 -> OPC-UA FIWARE 物联网代理 -> Orion 上下文代理 -> FIWARE Cygnus 连接器 -> PostgreSQL 数据库。
这是我用来编写 docker-compose
文件的文档:
这是我使用的 docker-compose
和 .env
文件
docker-compose.yml
version: "3"
#secrets:
# age_idm_auth:
# file: age_idm_auth.txt
services:
iotage:
hostname: iotage
image: iotagent4fiware/iotagent-opcua:1.3.4
networks:
- hostnet
- iotnet
ports:
- "${AGENT_SERVER_PORT}:${AGENT_SERVER_PORT}"
- "4081:8080"
extra_hosts:
- "iotcarsrv:192.168.50.167"
- "HP:192.168.50.167"
depends_on:
- iotmongo
- orion
volumes:
- ./AGECONF:/opt/iotagent-opcua/conf
- ./certificates/charm:/opt/iotagent-opcua/certificates
command: /usr/bin/tail -f /var/log/lastlog
iotmongo:
hostname: iotmongo
image: mongo:3.4
networks:
- iotnet
volumes:
- iotmongo_data:/data/db
- iotmongo_conf:/data/configdb
################ OCB ################
orion:
hostname: orion
image: fiware/orion:latest
networks:
- hostnet
- ocbnet
ports:
- "${ORION_PORT}:${ORION_PORT}"
depends_on:
- orion_mongo
#command: -dbhost mongo
entrypoint: /usr/bin/contextBroker -fg -multiservice -ngsiv1Autocast -statCounters -dbhost mongo -logForHumans -logLevel DEBUG -t 255
orion_mongo:
hostname: orion_mongo
image: mongo:3.4
networks:
ocbnet:
aliases:
- mongo
volumes:
- orion_mongo_data:/data/db
- orion_mongo_conf:/data/configdb
command: --nojournal
############### CYGNUS ###############
cygnus:
image: fiware/cygnus-ngsi:${CYGNUS_VERSION}
hostname: cygnus
container_name: fiware-cygnus
networks:
- hostnet
depends_on:
- postgres-db
expose:
- "${CYGNUS_POSTGRESQL_SERVICE_PORT}" # 5055
- "${CYGNUS_API_PORT}" # 5080
ports:
- "${CYGNUS_POSTGRESQL_SERVICE_PORT}:${CYGNUS_POSTGRESQL_SERVICE_PORT}"
- "${CYGNUS_API_PORT}:${CYGNUS_API_PORT}"
environment:
- "CYGNUS_POSTGRESQL_SERVICE_PORT=${CYGNUS_POSTGRESQL_SERVICE_PORT}"
- "CYGNUS_POSTGRESQL_HOST=postgres-db" # Hostname of the PostgreSQL server used to persist historical contex
- "CYGNUS_POSTGRESQL_PORT=${POSTGRES_DB_PORT}" # Port that the PostgreSQL server uses to listen to commands
- "CYGNUS_POSTGRESQL_DATABASE=postgres"
- "CYGNUS_POSTGRESQL_USER=postgres" # Username for the PostgreSQL database user
- "CYGNUS_POSTGRESQL_PASS=password" # Password for the PostgreSQL database user
- "CYGNUS_POSTGRESQL_ENABLE_CACHE=true" # Switch to enable caching within the PostgreSQL configuration
- "CYGNUS_SERVICE_PORT=${CYGNUS_POSTGRESQL_SERVICE_PORT}" # Notification Port that Cygnus listens when subcr
- "CYGNUS_API_PORT=${CYGNUS_API_PORT}" # Port that Cygnus listens on for operational reasons
- "CYGNUS_LOG_LEVEL=DEBUG" # The logging level for Cygnus
postgres-db:
image: postgres
hostname: postgres-db
expose:
- "${POSTGRES_DB_PORT}"
ports:
- "${POSTGRES_DB_PORT}:${POSTGRES_DB_PORT}"
networks:
- hostnet
environment:
- "POSTGRES_PASSWORD=password"
- "POSTGRES_USER=postgres"
- "POSTGRES_DB=postgres"
volumes:
- postgres-db:/var/lib/postgresql/data
volumes:
iotmongo_data:
iotmongo_conf:
orion_mongo_data:
orion_mongo_conf:
postgres-db:
networks:
hostnet:
iotnet:
ocbnet:
.env
# Orion
ORION_PORT=1026
# PostgreSQL
POSTGRES_DB_PORT=5432
# OPCUA IoT Agent
AGENT_SERVER_PORT=4001
# Cygnus
CYGNUS_VERSION=2.10.0
CYGNUS_API_PORT=5080
CYGNUS_MYSQL_SERVICE_PORT=5050
CYGNUS_MONGO_SERVICE_PORT=5051
CYGNUS_CKAN_SERVICE_PORT=5052
CYGNUS_HDFS_SERVICE_PORT=5053
CYGNUS_CARTO_SERVICE_PORT=5054
CYGNUS_POSTGRESQL_SERVICE_PORT=5055
CYGNUS_ORION_SERVICE_PORT=5056
CYGNUS_POSTGIS_SERVICE_PORT=5057
CYGNUS_ELASTICSEARCH_SERVICE_PORT=5058
CYGNUS_ARCGIS_SERVICE_PORT=5059
我可以看到系统已启动并且没有从 docker 通知的错误
docker ps -a
result
但是,当我使用 pgAdmin 或 docker exec
检查 postgres 数据库时,里面什么也没有。
\dt
psql 命令给了我 Did not find any relation
这意味着没有任何内容登录到数据库中。
请帮助结合 FIWARE 的这两个组件(物联网 OPCUA 代理和 Cygnus)。我也不清楚 Cygnus 连接器是否会为我们创建数据库。
[编辑]
该组件似乎正在工作:
模拟服务器
所有服务
Cynus 仅通知我 'Configuration has no change',当我使用 docker exec
进入容器时,从 Cygnus 我能够 ping orion 和 postgresql 数据库容器
在 postgresql 中:我没有看到所需的数据库或 table
我的模拟服务器 -> OPCUA IoT 代理 -> Orion 系统运行良好,因为从 docker logs
我仍然能够获得模拟服务器的更新值:
这里有一个复杂的场景,由 5 个组件的端到端链组成:
- Prosys OPC-UA 服务器模拟
- OPC-UA FIWARE物联网代理
- Orion 上下文代理
- FIWARE Cygnus 连接器
- PostgreSQL 数据库
我在这里的建议是检查链中的每个步骤(查看日志等)以确保在检查下一步之前一切正确。