gpt4 book ai didi

mongodb - 在特定的 mongodb 设置中部署 fiware-orion

转载 作者:可可西里 更新时间:2023-11-01 10:02:08 25 4
gpt4 key购买 nike

我使用 mongodb 分片并通过 docker 复制。 (3 个虚拟机托管 15 个容器)。我的 Mongodb 集群功能齐全。

现在我尝试在其上连接 Orion CB。通常我必须将它连接到 Mongo 路由器,但它不起作用。

这是我的 MongoDB 堆栈文件

version: "3.4"
services:

db1-1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: mongo:3.6.2
hostname: db1-1
environment:
- MONGODB_REPLICA_SET_MODE=primary
ports:
- "27011:27011"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db1-1:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs1 --shardsvr --dbpath /data/db --port 27011
networks:
STC-nw-mongo1:
aliases:
- db1-1

db1-2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: mongo:3.6.2
hostname: db1-2
environment:
- MONGODB_REPLICA_SET_MODE=secondary

ports:
- "27012:27012"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db1-2:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs1 --shardsvr --dbpath /data/db --port 27012
networks:
STC-nw-mongo1:
aliases:
- db1-2

db1-3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: mongo:3.6.2
hostname: db1-3
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "27013:27013"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db1-3:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs1 --shardsvr --dbpath /data/db --port 27013
networks:
STC-nw-mongo1:
aliases:
- db1-3

db2-1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: mongo:3.6.2
hostname: db2-1
environment:
- MONGODB_REPLICA_SET_MODE=primary
ports:
- "27021:27021"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db2-1:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs2 --shardsvr --dbpath /data/db --port 27021
networks:
STC-nw-mongo1:
aliases:
- db2-1

db2-2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: mongo:3.6.2
hostname: db2-2
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "27022:27022"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db2-2:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs2 --shardsvr --dbpath /data/db --port 27022
networks:
STC-nw-mongo1:
aliases:
- db2-2

db2-3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: mongo:3.6.2
hostname: db2-3
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "27023:27023"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db2-3:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs2 --shardsvr --dbpath /data/db --port 27023
networks:
STC-nw-mongo1:
aliases:
- db2-3

db3-1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: mongo:3.6.2
hostname: db3-1
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "27031:27031"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db3-1:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs3 --shardsvr --dbpath /data/db --port 27031
networks:
STC-nw-mongo1:
aliases:
- db3-1

db3-2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: mongo:3.6.2
hostname: db3-2
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "27032:27032"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db3-2:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs3 --shardsvr --dbpath /data/db --port 27032
networks:
STC-nw-mongo1:
aliases:
- db3-2

db3-3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: mongo:3.6.2
hostname: db3-3
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "27033:27033"
volumes:
- /var/lib/docker/config/STC-mongo1/data/db3-3:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet iot-rs3 --shardsvr --dbpath /data/db --port 27033
networks:
STC-nw-mongo1:
aliases:
- db3-3

dbconfig1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: mongo:3.6.2
hostname: dbconfig1
environment:
- MONGODB_REPLICA_SET_MODE=primary
ports:
- "37001:37001"
volumes:
- /var/lib/docker/config/STC-mongo1/data/dbconfig1:/data/configdb
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet conf-serv --configsvr --port 37001
networks:
STC-nw-mongo1:
aliases:
- dbconfig1

dbconfig2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: mongo:3.6.2
hostname: dbcoonfig2
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "37002:37002"
volumes:
- /var/lib/docker/config/STC-mongo1/data/dbconfig2:/data/configdb
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet conf-serv --configsvr --port 37002
networks:
STC-nw-mongo1:
aliases:
- dbconfig2

dbconfig3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: mongo:3.6.2
hostname: dbconfig3
environment:
- MONGODB_REPLICA_SET_MODE=secondary
ports:
- "37003:37003"
volumes:
- /var/lib/docker/config/STC-mongo1/data/dbconfig3:/data/configdb
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongod --replSet conf-serv --configsvr --port 37003
networks:
STC-nw-mongo1:
aliases:
- dbconfig3

dbrouter1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: mongo:3.6.2
hostname: dbrouter1
ports:
- "27997:27997"
volumes:
- /var/lib/docker/config/STC-mongo1/data/dbrouter1:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongos --configdb conf-serv/dbconfig1:37001,dbconfig2:37002,dbconfig3:37003 --port 27997 --bind_ip_all
networks:
STC-nw-mongo1:
aliases:
- dbrouter1

dbrouter2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: mongo:3.6.2
hostname: dbrouter2
ports:
- "27998:27998"
volumes:
- /var/lib/docker/config/STC-mongo1/data/dbrouter2:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongos --configdb conf-serv/dbconfig1:37001,dbconfig2:37002,dbconfig3:37003 --port 27998 --bind_ip_all
networks:
STC-nw-mongo1:
aliases:
- dbrouter2

dbrouter3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: mongo:3.6.2
hostname: dbrouter3
ports:
- "27999:27999"
volumes:
- /var/lib/docker/config/STC-mongo1/data/dbrouter3:/data/db
- /var/lib/docker/config/STC-mongo1/data/certificats:/etc/ssl/iot-certs
- /var/lib/docker/config/STC-mongo1/config:/etc/config
command: mongos --configdb conf-serv/dbconfig1:37001,dbconfig2:37002,dbconfig3:37003 --port 27999 --bind_ip_all
networks:
STC-nw-mongo1:
aliases:
- dbrouter3

networks:
STC-nw-mongo1:

这是我的 orion 的 docker-compose

version: '3.4'
services:

orion1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: fiware/orion:latest
hostname: orion1
ports:
- "1026:1026"
volumes:
- /var/lib/docker/config/STC-orion/config:/etc/sysconfig
command: -dbhost "dbrouter1:27997,dbrouter2:27998,dbrouter3:27999" -rplSet "iot-rs1,iot-rs2,iot-rs3" -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion1

networks:
STC-nw-orion:
external:
name: STC-mongo1_STC-nw-mongo1

我的 orion 容器正在运行,但是当我查看日志时,我只有这些信息:

docker logs -f STC-orion_orion1.1.iiv0xf6qe4pco4fk679b1s3i9 time=Wednesday 28 Feb 14:07:47 2018.732Z | lvl=ERROR | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=mongoConnectionPool.cpp[195]:mongoConnect | msg=Database Startup Error (cannot connect to mongo - doing 100 retries with a 1000 microsecond interval)

谢谢你的帮助

最佳答案

我不是分片方面的专家,也从未用 Orion 测试过它,但从技术上讲,@fgalan 是对的。

当您使用 mongo 分片时,访问通过充当路由器的 mongos 进行,即它们知道通过配置服务器将写入和读取路由到正确的分片集群,这也意味着它们处理与分片副本的连接为访问路由器的客户端设置。所以你不需要指定任何副本集,你只需要列出你想要连接的路由器(这可能是由驱动程序使用循环方法选择的,但我不确定,你应该检查 C++ legacy driver执行以验证)。

顺便说一句,路由器是一个 headless 服务,所以(假设你正在使用堆栈部署)我会有一个单一的服务,你可以向上和向下扩展,这样你就不需要在前面放置一个负载均衡器(是诚实测试)

要获得更可配置/可扩展的 docker 服务,您可以调整我们在这里所做的工作:

当然,如果您愿意,可以随时提出拉取请求。

关于mongodb - 在特定的 mongodb 设置中部署 fiware-orion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49047299/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com