在特定 mongodb 设置中部署 fiware-orion
deploy fiware-orion in specific mongodb setup
我使用 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 无法连接到 MongoDB。可能 -rplSet "iot-rs1,iot-rs2,iot-rs3"
不起作用,因为它只需要一个副本集名称。
我不太记得 MongoDB 分片设置的配置方面,其中每个分片都由一个副本集实现,但我会说副本集名称是每个分片中的一个内部方面。换句话说,访问 mongos 的进程(在本例中为 Context Broker)不应该知道每个分片内部使用的副本集名称。
我建议从更简单的设置开始,使用:
command: -dbhost dbrouter1:27997 -corsOrigin __ALL
一旦你成功了,试着同时用第二个和第三个 mongos 进化。但是,不确定 Orion 驱动程序是否支持它。请注意,典型的 multi-mongos 部署假设应用程序的多个实例(即具有 CB 的 3 个节点)在每个节点本地运行 mongos(即在具有 CB 的 3 个节点中的每一个节点中都有一个 mongos,每个 CB 与其本地 mongos 连接).
following link 可能会有用(尽管我不确定该模型是否与您尝试实现的情况相同)。
我不是分片方面的专家,我也从未用 Orion 测试过它,但从技术上讲,@fgalan 是对的。
当您使用 mongo 分片时,访问会通过充当路由器的 mongos,即它们知道通过配置服务器将写入和读取路由到正确的分片集群,这也意味着它们为访问路由器的客户端处理与分片副本集的连接。所以你不需要指定任何副本集,你只需要列出你想要连接的路由器(这可能是由驱动程序使用循环方法选择的,但我不确定,你应该检查 C++ legacy driver实施验证)。
顺便说一句,路由器是无头服务,所以(假设您使用的是堆栈部署)我将拥有一个可以向上和向下扩展的服务,这样您就不需要在前面放置负载均衡器(诚实地进行测试)
要获得更可配置/可扩展的 docker 服务,您可以调整我们在这里所做的工作:
- https://github.com/smartsdk/smartsdk-recipes/tree/master/recipes/data-management/context-broker/ha
- https://github.com/smartsdk/mongo-rs-controller-swarm
当然,如果您愿意,请随时提出拉取请求。
感谢您的所有建议。这是我的 Orion 堆栈文件。
version: '3.4'
services:
orion1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: fiware/orion:latest
hostname: orion1
ports:
- "1026:1026"
command: -dbhost dbrouter1:27997 -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion1
orion2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: fiware/orion:latest
hostname: orion2
ports:
- "1027:1026"
command: -dbhost dbrouter2:27998 -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion2
orion3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: fiware/orion:latest
hostname: orion3
ports:
- "1028:1026"
command: -dbhost dbrouter3:27999 -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion3
networks:
STC-nw-orion:
external:
name: STC-mongo1_STC-nw-mongo1
我现在在前面配置我的 HAProxy 以实现负载平衡。下一步将身份验证添加到我的特殊 MongoDB 集群。
我使用 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-composeversion: '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 无法连接到 MongoDB。可能 -rplSet "iot-rs1,iot-rs2,iot-rs3"
不起作用,因为它只需要一个副本集名称。
我不太记得 MongoDB 分片设置的配置方面,其中每个分片都由一个副本集实现,但我会说副本集名称是每个分片中的一个内部方面。换句话说,访问 mongos 的进程(在本例中为 Context Broker)不应该知道每个分片内部使用的副本集名称。
我建议从更简单的设置开始,使用:
command: -dbhost dbrouter1:27997 -corsOrigin __ALL
一旦你成功了,试着同时用第二个和第三个 mongos 进化。但是,不确定 Orion 驱动程序是否支持它。请注意,典型的 multi-mongos 部署假设应用程序的多个实例(即具有 CB 的 3 个节点)在每个节点本地运行 mongos(即在具有 CB 的 3 个节点中的每一个节点中都有一个 mongos,每个 CB 与其本地 mongos 连接).
following link 可能会有用(尽管我不确定该模型是否与您尝试实现的情况相同)。
我不是分片方面的专家,我也从未用 Orion 测试过它,但从技术上讲,@fgalan 是对的。
当您使用 mongo 分片时,访问会通过充当路由器的 mongos,即它们知道通过配置服务器将写入和读取路由到正确的分片集群,这也意味着它们为访问路由器的客户端处理与分片副本集的连接。所以你不需要指定任何副本集,你只需要列出你想要连接的路由器(这可能是由驱动程序使用循环方法选择的,但我不确定,你应该检查 C++ legacy driver实施验证)。
顺便说一句,路由器是无头服务,所以(假设您使用的是堆栈部署)我将拥有一个可以向上和向下扩展的服务,这样您就不需要在前面放置负载均衡器(诚实地进行测试)
要获得更可配置/可扩展的 docker 服务,您可以调整我们在这里所做的工作:
- https://github.com/smartsdk/smartsdk-recipes/tree/master/recipes/data-management/context-broker/ha
- https://github.com/smartsdk/mongo-rs-controller-swarm
当然,如果您愿意,请随时提出拉取请求。
感谢您的所有建议。这是我的 Orion 堆栈文件。
version: '3.4'
services:
orion1:
deploy:
placement:
constraints: [node.hostname == docker-vm1]
image: fiware/orion:latest
hostname: orion1
ports:
- "1026:1026"
command: -dbhost dbrouter1:27997 -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion1
orion2:
deploy:
placement:
constraints: [node.hostname == docker-vm2]
image: fiware/orion:latest
hostname: orion2
ports:
- "1027:1026"
command: -dbhost dbrouter2:27998 -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion2
orion3:
deploy:
placement:
constraints: [node.hostname == docker-vm3]
image: fiware/orion:latest
hostname: orion3
ports:
- "1028:1026"
command: -dbhost dbrouter3:27999 -corsOrigin __ALL
networks:
STC-nw-orion:
aliases:
- orion3
networks:
STC-nw-orion:
external:
name: STC-mongo1_STC-nw-mongo1
我现在在前面配置我的 HAProxy 以实现负载平衡。下一步将身份验证添加到我的特殊 MongoDB 集群。