【问题标题】:Is Orion compatible with AWS DocumentDBOrion 是否与 AWS DocumentDB 兼容
【发布时间】:2021-04-12 22:59:26
【问题描述】:

我正在尝试将 Orion 与 AWS DocumentDB 连接,但没有连接。但是我用 DocumentDB 尝试了另外两个 FIWARE 组件 IoTAgent 和 Sth-Comet,它们都工作正常。

相同的主机名和凭据适用于 IoTAgent 和 Sth-Comet。我还检查了连接,这很好,因为 IoTAgent 和 Sth-Comet 在同一个网络中。我还从同一网络中的不同 mongo 主机进行了检查,这也有效。以下是我为 Orion 得到的错误。

time=2021-02-18T07:03:46.293Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=mongoConnectionPool.cpp[180]:mongoConnect | msg=Database Startup Error (cannot connect to mongo - doing 100 retries with a 1000 millisecond interval)

Orion 是否有可能与 AWS DocumentDB 不兼容?

更新1:

bash-4.2$ ps ax | grep contextBroker
    1 ?        Ss     0:00 /usr/bin/contextBroker -fg -multiservice -ngsiv1Autocast -disableFileLog -dbhost xxxxxxxxxxxxxxxxxx.docdb.amazonaws.com -db admin -dbuser test -dbpwd xxxxxxxxxx

更新2:

之前,我通过直接从 dockerhub 拉取来使用 Orion docker 图像,但那不起作用。所以这一次,我通过构建2.4.2和2.5.2版本的源码来构建两个docker镜像。现在,我能够使用这些 docker 映像与 AWS DocuemntDB 连接,但得到如下不同的错误。

time=2021-02-23T06:10:41.982Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=safeMongo.cpp[360]:getField | msg=Runtime Error (field '_id' is missing in BSONObj <{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported" }> from caller mongoSubCacheItemInsert:83)
time=2021-02-23T06:10:41.982Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=AlarmManager.cpp[211]:dbError | msg=Raising alarm DatabaseError: error retrieving _id field in doc: '{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported" }'

以下是猎户座版本

contextBroker --version
2.5.0-next (git version: 3984f9fc30e90fa04682131ca4516b4d277eb27e)

curl -X GET 'http://localhost:1026/version'
    {
    "orion" : {
      "version" : "2.5.0-next",
      "uptime" : "0 d, 0 h, 4 m, 56 s",
      "git_hash" : "3984f9fc30e90fa04682131ca4516b4d277eb27e",
      "compile_time" : "Mon Feb 22 17:39:30 UTC 2021",
      "compiled_by" : "root",
      "compiled_in" : "4c7575c7c27f",
      "release_date" : "Mon Feb 22 17:39:30 UTC 2021",
      "doc" : "https://fiware-orion.rtfd.io/",
      "libversions": {
         "boost": "1_53",
         "libcurl": "libcurl/7.29.0 NSS/3.53.1 zlib/1.2.7 libidn/1.28 libssh2/1.8.0",
         "libmicrohttpd": "0.9.70",
         "openssl": "1.0.2k",
         "rapidjson": "1.1.0",
         "mongodriver": "legacy-1.1.2"
      }
    }
    }

我还可以使用 Mongo Shell 从 Orion Pod 连接到 DocumentDB。

mongo --host xxxxxxxxxxxxxxxxxx.docdb.amazonaws.com:27017 --username xxxx --password xxxx
rs0:PRIMARY> show dbs;
rs0:PRIMARY>

我还可以使用以下命令创建条目,它会在 DocumentDB 中创建一个数据库和集合:

curl localhost:1026/v2/entities -s -S --header 'Content-Type: application/json' \
>     -X POST -d @- <<EOF
> {
>   "id": "Room2",
>   "type": "Room",
>   "temperature": {
>     "value": 23,
>     "type": "Number"
>   },
>   "pressure": {
>     "value": 720,
>     "type": "Number"
>   }
> }
> EOF

rs0:PRIMARY> show dbs;
orion  0.000GB

但我无法使用 orion API 获取该数据,并且在执行此命令后,它会以空响应从容器中退出。我已经检查了 Orion 版本 2.4.2 和 2.5.2 以及 DocumentDB 4.0 和 3.6。

[root@orion-docdb-7748fd9c85-gbjz7 /]# curl localhost:1026/v2/entities/Room2 -s -S --header 'Accept: application/json' | python -mjson.tool
curl: (52) Empty reply from server
command terminated with exit code 137

最后,日志中仍然出现同样的错误。

time=2021-02-23T06:16:04.564Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=safeMongo.cpp[360]:getField | msg=Runtime Error (field '_id' is missing in BSONObj <{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported" }> from caller mongoSubCacheItemInsert:83)
time=2021-02-23T06:16:04.564Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=AlarmManager.cpp[211]:dbError | msg=Raising alarm DatabaseError: error retrieving _id field in doc: '{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported" }'

更新3:

我已添加-noCache 并再次部署。以下是命令输出和日志供您参考。

流程检查:

#ps ax | grep contextBroker
1 ?        Ssl    0:00 /usr/bin/contextBroker -fg -multiservice -ngsiv1Autocast -disableFileLog -dbhost xxxxxxxxxxxxxxxxxx.docdb.amazonaws.com -dbuser xxxxxxxx -dbpwd xxxxxxxx -logLevel DEBUG -noCache

数据库中的条目:

rs0:PRIMARY> show dbs
orion  0.000GB
rs0:PRIMARY> use orion
switched to db orion
rs0:PRIMARY> show collections
entities
rs0:PRIMARY> db.entities.find()
{ "_id" : { "id" : "Room2", "type" : "Room", "servicePath" : "/" }, "attrNames" : [ "temperature", "pressure" ], "attrs" : { "temperature" : { "type" : "Number", "creDate" : 1614323032.671698, "modDate" : 1614323032.671698, "value" : 23, "mdNames" : [ ] }, "pressure" : { "type" : "Number", "creDate" : 1614323032.671698, "modDate" : 1614323032.671698, "value" : 720, "mdNames" : [ ] } }, "creDate" : 1614323032.671698, "modDate" : 1614323032.671698, "lastCorrelator" : "c8a73f40-7800-11eb-bd9b-bea9c419835d" }

Orion Pod 日志:

time=2021-02-26T06:46:33.966Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=contextBroker.cpp[1008]:main | msg=start command line </usr/bin/contextBroker -fg -multiservice -ngsiv1Autocast -disableFileLog -dbhost -dbhost xxxxxxxxxxxxxxxxxx.docdb.amazonaws.com -dbuser xxxxxxxx -dbpwd xxxxxxxx -logLevel DEBUG -noCache>
time=2021-02-26T06:46:33.966Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=contextBroker.cpp[1076]:main | msg=Orion Context Broker is running
time=2021-02-26T06:46:34.280Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=MongoGlobal.cpp[243]:mongoInit | msg=Connected to mongo at xxxxxxxxxxxxxxxxxx.docdb.amazonaws.com/orion, as user 'xxxxxxx' (poolsize: 10)
time=2021-02-26T06:46:34.282Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=contextBroker.cpp[1202]:main | msg=Startup completed
time=2021-02-26T07:03:24.546Z | lvl=INFO | corr=b7e44e5a-7800-11eb-9531-bea9c419835d | trans=1614321993-966-00000000001 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=logTracing.cpp[79]:logInfoRequestWithoutPayload | msg=Request received: GET /version, response code: 200
time=2021-02-26T07:03:52.672Z | lvl=ERROR | corr=c8a73f40-7800-11eb-bd9b-bea9c419835d | trans=1614321993-966-00000000002 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=safeMongo.cpp[360]:getField | msg=Runtime Error (field '_id' is missing in BSONObj <{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported", operationTime: Timestamp 1614323032|1 }> from caller processContextElement:3493)
time=2021-02-26T07:03:52.672Z | lvl=ERROR | corr=c8a73f40-7800-11eb-bd9b-bea9c419835d | trans=1614321993-966-00000000002 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=AlarmManager.cpp[211]:dbError | msg=Raising alarm DatabaseError: error retrieving _id field in doc: '{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported", operationTime: Timestamp 1614323032|1 }'
time=2021-02-26T07:03:52.782Z | lvl=ERROR | corr=c8a73f40-7800-11eb-bd9b-bea9c419835d | trans=1614321993-966-00000000002 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=AlarmManager.cpp[235]:dbErrorReset | msg=Releasing alarm DatabaseError
time=2021-02-26T07:03:52.790Z | lvl=ERROR | corr=c8a73f40-7800-11eb-bd9b-bea9c419835d | trans=1614321993-966-00000000002 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=safeMongo.cpp[360]:getField | msg=Runtime Error (field '_id' is missing in BSONObj <{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported", operationTime: Timestamp 1614323032|1 }> from caller addTriggeredSubscriptions_noCache:1408)
time=2021-02-26T07:03:52.790Z | lvl=ERROR | corr=c8a73f40-7800-11eb-bd9b-bea9c419835d | trans=1614321993-966-00000000002 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=AlarmManager.cpp[211]:dbError | msg=Raising alarm DatabaseError: error retrieving _id field in doc: '{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported", operationTime: Timestamp 1614323032|1 }'
time=2021-02-26T07:03:52.791Z | lvl=INFO | corr=c8a73f40-7800-11eb-bd9b-bea9c419835d | trans=1614321993-966-00000000002 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=logTracing.cpp[130]:logInfoRequestWithPayload | msg=Request received: POST /v2/entities, request payload (148 bytes): {  "id": "Room2",  "type": "Room",  "temperature": {    "value": 23,    "type": "Number"  },  "pressure": {    "value": 720,    "type": "Number"  }}, response code: 201
time=2021-02-26T07:03:58.479Z | lvl=ERROR | corr=cc1d5934-7800-11eb-a28d-bea9c419835d | trans=1614321993-966-00000000003 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=AlarmManager.cpp[235]:dbErrorReset | msg=Releasing alarm DatabaseError
time=2021-02-26T07:03:58.479Z | lvl=ERROR | corr=cc1d5934-7800-11eb-a28d-bea9c419835d | trans=1614321993-966-00000000003 | from=127.0.0.1 | srv=<none> | subsrv=<none> | comp=Orion | op=safeMongo.cpp[360]:getField | msg=Runtime Error (field '_id' is missing in BSONObj <{ ok: 0.0, code: 303, errmsg: "Legacy opcodes are not supported", operationTime: Timestamp 1614323038|1 }> from caller ContextElementResponse:109)
terminate called after throwing an instance of 'mongo::AssertionException'
  what():  assertion src/mongo/bson/bsonelement.cpp:392

在 API 调用期间 Pod 退出并重新启动:

curl localhost:1026/v2/entities/Room2 -s -S --header 'Accept: application/json' | python -mjson.tool
command terminated with exit code 137

【问题讨论】:

  • 您能否编辑您的问题帖子以包含 Orion 的运行方式?即ps ax | grep contextBroker 的结果。
  • 相关(但不确定是否完全相同):stackoverflow.com/questions/63842042/…
  • @fgalan 感谢您的回复。我也更新了。
  • 如果您尝试使用相同的凭据(例如使用mongo shell)从运行 CB 的同一主机访问位于 xxxxxxxxxxxxxxxxxx.docdb.amazonaws.com 的 DocumentDB,它是否有效?

标签: fiware fiware-orion aws-documentdb aws-documentdb-mongoapi


【解决方案1】:

日志跟踪中显示的以下消息非常重要

"Legacy opcodes are not supported"

虽然 Orion 2.5.2 和之前使用的 MongoDB 驱动程序可与 4.4 及以下的官方 MongoDB 版本一起使用,但对于像 AWS DocumentDB 这样的 MongoDB“克隆”可能并非如此。

我们在the process to change the legacy driver used by Orion to a new one。一旦此更改登陆 Orion 主分支,我建议对其进行测试(使用 :latest dockerhub 标签)。同时,作为一种解决方法,我建议使用官方的 MongoDB 数据库。

编辑: 更改 MongoDB 驱动程序的过程已完成,Orion 正在使用自 3.0.0 版以来的新驱动程序。我认为用这个新版本进行测试并看看效果如何是个好主意。如果您向我提供访问信息(请参阅here),我可以帮助测试。

【讨论】:

  • 已编辑答案以添加新信息
猜你喜欢
  • 1970-01-01
  • 2022-08-22
  • 2020-08-13
  • 2013-09-18
  • 1970-01-01
  • 2022-12-12
  • 2017-06-07
  • 2011-05-23
  • 2011-10-22
相关资源
最近更新 更多