微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 azure cosmos db mongo api 中使用 fiware orion

如何解决在 azure cosmos db mongo api 中使用 fiware orion

我们目前正在 Kubernetes 集群中的 docker 容器上使用 fiware Orion 和 Mongo DB,一切正常,但是一旦我尝试将它与 Azure CosmosDB mongo API 一起使用,事情就会崩溃。

下面是yaml

apiVersion: v1
kind: Namespace
Metadata:
  name: fiware
---
apiVersion: apps/v1
kind: Deployment
Metadata:
  name: orion
  namespace: fiware
spec:
  replicas: 1
  selector:
    matchLabels:
      app: orion
  template:
    Metadata:
      labels:
        app: orion
    spec:
      containers:
      - name: orion
        image: fiware/orion:2.5.2
        ports:
        - containerPort: 1026
          name: http
          protocol: TCP
        args: ["-dbhost","<<HOST HERE>>:<<PORT>>","-db","<<DB>>","-dbuser","<<USER>>","-dbpwd","<<PWD>>","-dbSSL","-rplSet","globaldb","-dbAuthDb","admin","-httpTimeout","15000","-logLevel","INFO"]
---
apiVersion: v1
kind: Service
Metadata:
  name: orion
  namespace: fiware
spec:
  selector:
    app: orion
  type: LoadBalancer
  ports:
    - port: 1026
      protocol: TCP
      targetPort: 1026
      nodePort: 30000

错误

time=2021-03-05T04:05:45.784Z | 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 <{ cursor: { id: 0,ns: "orion.csubs",firstBatch: [] },ok: 1.0 }> from caller mongoSubcacheItemInsert:83)
time=2021-03-05T04:05:45.784Z | 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: '{ cursor: { id: 0,ok: 1.0 }'

解决方法

从 3.0.0 版开始,Orion 能够连接到 Azure Cosmos DB。详情请见here。请特别注意以下注意事项:

  • 您需要使用 -dbDisableRetryWrites
  • 启动 Orion
  • 如果您在 NGSIv2 查询中使用 creDate 参数,您需要在 db.entities.createIndex({creDate:1})(例如 orderBy)处创建和索引,甚至更多。更多详情here
  • 由于 Azure Cosmos DB 的限制,Orion 中的 transient entities 功能不可用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。