Orion 上下文代理不会“动态”创建租户数据库

问题描述 投票:0回答:1

我在 docker 容器中创建并运行 fiware-iot-agent 以及 fiware-orion 上下文代理。我使用的 mongoDb 是一个具有 2 个分片且启用了身份验证的分片集群。我验证了 orion 正在连接到集群。 下面是我使用的 docker-compose.yml。

version: "3.8"
services:
  # Orion is the context broker
  orion:
    image: fiware/orion:${ORION_VERSION}
    hostname: orion
    container_name: fiware-orion-pms
    networks:
      - default
    expose:
      - "${ORION_PORT}"
    ports:
      - "${ORION_PORT}:${ORION_PORT}" # localhost:1026
    command: -dbhost 192.168.2.5:27030 -dbuser $DB_USER -dbpwd $DB_PWD -dbAuthDb admin  -db orion -logLevel DEBUG
    healthcheck:
      test: curl --fail -s http://orion:${ORION_PORT}/version || exit 1
      interval: 5s
    restart: always
    labels:
      maintainer: ino
      description: fiware-orion
      project: pms
      version: v1.0.0
      type: fiware

  # IoT-Agent is configured for the UltraLight Protocol
  #
  # This deliberately fixed to v1.7.0
  # see: https://github.com/telefonicaid/iotagent-ul/issues/320
  #
  # For v1.8 and v1.9 a dummy resource must be added when provisioning
  #
  iot-agent:
    image: fiware/iotagent-json
    hostname: iot-agent
    container_name: fiware-iot-agent-pms
    networks:
      - default
    expose:
      - "${IOTA_NORTH_PORT}"
    ports:
      - "${IOTA_NORTH_PORT}:${IOTA_NORTH_PORT}" # localhost:4041
    environment:
      - IOTA_CB_HOST=orion # name of the context broker to update context
      - IOTA_CB_PORT=1026 # port the context broker listens on to update context
      - IOTA_NORTH_PORT=4041
      - IOTA_REGISTRY_TYPE=mongodb #Whether to hold IoT device info in memory or in a database
      - IOTA_LOG_LEVEL=FATAL # The log level of the IoT Agent
      - IOTA_TIMESTAMP=true # Supply timestamp information with each measurement
      - IOTA_CB_NGSI_VERSION=v2 # use NGSIv2 when sending updates for active attributes
      - IOTA_AUTOCAST=true # Ensure Ultralight number values are read as numbers not strings
      - IOTA_MONGO_USER=$DB_USER 
      - IOTA_MONGO_PASSWORD=$DB_PWD
      - IOTA_MONGO_AUTH_SOURCE=admin  
      - IOTA_MONGO_HOST=192.168.2.5 # The host name of MongoDB
      - IOTA_MONGO_PORT=27030 # The port mongoDB is listening on
      - IOTA_MONGO_DB=iotagentul # The name of the database used in mongoDB
      - IOTA_MQTT_HOST=192.168.2.10 # The host name of the MQTT Broker
      - IOTA_MQTT_PORT=1883 # The port the MQTT Broker is listening on to receive topics
      - IOTA_DEFAULT_RESOURCE= # Default is blank. I'm using MQTT so I don't need a resource
      - IOTA_PROVIDER_URL=http://iot-agent:${IOTA_NORTH_PORT}
      - IOTA_DEFAULT_TRANSPORT=MQTT
    healthcheck:
      interval: 5s
    restart: always
    labels:
      maintainer: ino
      description: fiware-orion-agent-json
      project: pms
      version: v1.0.0
      type: fiware

networks:
  default:
    labels:
      org.fiware: 'fiware-networks-pms'
    ipam:
      config:
        - subnet: 172.50.1.0/24

我的问题是,当我使用端点

http://localhost:4041/iot/devices
将新设备添加到固件时,它会创建一个名为 iotagentul 的数据库,并在其中创建一个名为 devices 的集合。我添加的设备正在保存到该集合中。到目前为止,一切都很好。但我希望在添加新设备时创建另一个数据库。在 Orion 文档中这样说:

通常,Orion Context Broker 仅使用 MongoDB 级别的一个数据库(使用 -db 命令行选项指定的数据库,通常为“orion”)。但是,当使用多租户/多服务时,行为会有所不同,并且使用以下数据库(设为 -db 命令行选项的值): 默认租户的数据库(通常为 orion) 数据库 - 用于服务/租户(例如,如果租户名为tenantA并且使用默认的-db,则数据库将为orion-tenantA。当涉及租户数据的第一个请求由Orion处理时,每个服务/租户数据库是“动态”创建的。 最后,对于每个服务/租户数据库,所有集合和管理过程(备份、恢复等)都与每个特定服务/租户数据库相关联。

因此,根据此,应该有其他数据库来保存设备的实体。但他们没有出现。我未经授权尝试使用 mongo 但它仍然是一样的。我怎么解决这个问题?如有任何帮助,我们将不胜感激。

编辑:我的请求正文如下所示:

{ "devices": [ { "device_id": "PA_TALASLI1", "entity_name": "PA_TALASLI1", "entity_type": "power_analysis", "transport": "HTTP", "timezone": "Europe/Istanbul", "attributes": [ { "object_id": "Voltage_UL1_N", "name":"Voltage_UL1_N", "type":"Double"}, { "object_id": "Voltage_UL2_N", "name":"Voltage_UL2_N", "type":"Double"}, { "object_id": "Voltage_UL3_N", "name":"Voltage_UL3_N", "type":"Double"}, { "object_id": "Current_L1", "name":"Current_L1", "type":"Double"}, { "object_id": "Current_L2", "name":"Current_L2", "type":"Double"}, { "object_id": "Current_L3", "name":"Current_L3", "type":"Double"}, { "object_id": "Total_Active_Power", "name":"Total_Active_Power", "type":"Double"}, { "object_id": "Total_Reactive_Power", "name":"Total_Reactive_Power", "type":"Double"}, { "object_id": "Total_Power_Factor", "name":"Total_Power_Factor", "type":"Double"}, { "object_id": "Total_Active_Energy_IN_T1", "name":"Total_Active_Energy_IN_T1", "type":"Double"}, { "object_id": "Total_Active_Energy_IN_T2", "name":"Total_Active_Energy_IN_T2", "type":"Double"}, { "object_id": "Total_Active_Energy_EX_T1", "name":"Total_Active_Energy_EX_T1", "type":"Double"}, { "object_id": "Total_Active_Energy_EX_T2", "name":"Total_Active_Energy_EX_T2", "type":"Double"} ], "lazy":[ { "object_id": "Voltage_UL1_N", "name":"Voltage_UL1_N", "type":"Double"} ], "static_attributes": [ {"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:pa_talasli1:001"} ] } ] }
我尝试使用日志级别调试运行容器,但没有看到任何有关实体创建的信息。如果我向主体添加一个 

lazy 属性,它会创建一个名为 registerations 的表,但没有实体表。我专门通过 /v2/entities/

 创建了一个实体,但我需要的是在将新设备添加到 
/iot/devices
 后创建实体
    

mongodb fiware fiware-orion
1个回答
0
投票
Orion 默认不使用租户。您必须通过使用 CLI 参数

-multiservice

 来告诉它(至少前一段时间它是这样工作的)。

© www.soinside.com 2019 - 2024. All rights reserved.