简体   繁体   English

连接系统,其中包括 OPC UA IoT Agent、Orion Context Broker。 Cygnus 和 Postgres 的历史数据

[英]Connect system which includes OPC UA IoT Agent, Orion Context Broker. Cygnus and Historic data with Postgres

I am trying to set up a system to save historic data with the flow like this: Prosys OPC-UA Server Simulation -> OPC-UA FIWARE IoT Agent -> Orion Context Broker -> FIWARE Cygnus Connector -> PostgreSQL database.我正在尝试建立一个系统来保存历史数据,流程如下:Prosys OPC-UA 服务器模拟 -> OPC-UA FIWARE IoT Agent -> Orion Context Broker -> FIWARE Cygnus Connector -> PostgreSQL 数据库。

Here is the document I used to compose the docker-compose file:这是我用来编写docker-compose文件的文档:

Historic-Context-Flume 历史上下文水槽

OPC-UA IoT Agent OPC-UA 物联网代理

Here is the docker-compose and .env file I used这是我使用的.env 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

I can see the system is up and no error informed from docker docker ps -a result我可以看到系统已启动并且没有从 docker docker ps -a result通知错误

However, when I use pgAdmin or docker exec to examine the postgres database there was nothing in it.但是,当我使用 pgAdmin 或docker exec检查 postgres 数据库时,其中没有任何内容。 \\dt command of psql gave me Did not find any relation which means there was nothing logged into the database. psql 的\\dt命令给了我Did not find any relation ,这意味着没有任何内容登录到数据库中。

Please provide help to combine these two components of FIWARE (the IoT OPCUA agent and the Cygnus).请提供帮助以组合 FIWARE 的这两个组件(IoT OPCUA 代理和 Cygnus)。 It was also not clear for me if the Cygnus connector would create the database for us.我也不清楚 Cygnus 连接器是否会为我们创建数据库。

[EDIT] The component seems to be working: Simulation Server [编辑] 该组件似乎正在工作:模拟服务器在此处输入图片说明

All services所有服务在此处输入图片说明

Cynus only infor me that 'Configuration has no change', when I used docker exec to get into the container, from Cygnus I was able to ping both orion, postgresql database containers Cynus 只告诉我“配置没有变化”,当我使用docker exec进入容器时,从 Cygnus 我能够 ping 两个 orion,postgresql 数据库容器在此处输入图片说明

在此处输入图片说明

In postgresql: I don't see the desired database or table在 postgresql 中:我没有看到所需的数据库或表在此处输入图片说明

My system from the Simulation Server -> OPCUA IoT Agent -> Orion was working well because from docker logs I was still able to get the updated value of Simulation Server:我的系统从 Simulation Server -> OPCUA IoT Agent -> Orion 运行良好,因为从docker logs我仍然能够获得 Simulation Server 的更新值: 在此处输入图片说明 在此处输入图片说明

You have a complex scenario here, composed of an end-to-end chain of 5 components:这里有一个复杂的场景,由 5 个组件的端到端链组成:

  • Prosys OPC-UA Server Simulation Prosys OPC-UA 服务器模拟
  • OPC-UA FIWARE IoT Agent OPC-UA FIWARE 物联网代理
  • Orion Context Broker Orion 上下文代理
  • FIWARE Cygnus Connector FIWARE Cygnus 连接器
  • PostgreSQL database PostgreSQL 数据库

My recomendation here would be to check every step in the chain (looking in logs, etc.) to ensure everything is correct before of checking the next step.我的建议是在检查下一步之前检查链中的每一步(查看日志等)以确保一切正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM