我想通过 docker-compose 部署包含 1 个 mongo 分片(副本集)、1 个配置服务器(副本集)和 1 个路由器的 mongo 集群。我有一个问题,它是“无法到达主要的设置 mongoconfigserver”。我发现了一个关于它的问题:
无法启动 mongos,但在这种情况下,配置服务器没有副本集,而我--replSet mongoconfigserver在命令中需要“”选项。
这是我的 docker-compose.yml:
version: '3'
services:
# Config servers for metadata
mongoconfigserver-01:
container_name: mongoconfigserver-01
image: mongo
command: mongod --configsvr --replSet mongoconfigserver --dbpath /data/db --port 27017
volumes:
- /etc/localtime:/etc/localtime:ro
- /mongo_cluster/config1:/data/db
mongoconfigserver-02:
container_name: mongoconfigserver-02
image: mongo
command: mongod --configsvr --replSet mongoconfigserver --dbpath /data/db --port 27017
volumes:
- /etc/localtime:/etc/localtime:ro
- /mongo_cluster/config2:/data/db
mongoconfigserver-03:
container_name: mongoconfigserver-03
image: mongo
command: mongod --configsvr --replSet mongoconfigserver --dbpath /data/db --port 27017
volumes:
- /etc/localtime:/etc/localtime:ro
- /mongo_cluster/config3:/data/db
# First shard
mongo-shard-01a:
image: mongo
command: mongod --port 27018 --replSet mongo-shard-01 --dbpath /data/db
volumes:
- /etc/localtime:/etc/localtime:ro
- /mongo_cluster/data1:/data/db
ports:
- 27017:27017
mongo-shard-01b:
image: mongo
command: mongod --port 27018 --replSet mongo-shard-01 --dbpath /data/db
volumes:
- /etc/localtime:/etc/localtime:ro
- /mongo_cluster/data2:/data/db
ports:
- 27027:27017
mongo-shard-01c:
image: mongo
command: mongod --port 27018 --replSet mongo-shard-01 --dbpath /data/db
volumes:
- /etc/localtime:/etc/localtime:ro
- /mongo_cluster/data3:/data/db
ports:
- 27037:27017
# Mongo router
mongo-router-01:
container_name: mongo-router-01
image: mongo
depends_on:
- mongoconfigserver-01
- mongoconfigserver-02
- mongoconfigserver-03
- mongo-shard-01a
- mongo-shard-01b
- mongo-shard-01c
command: mongos --configdb mongoconfigserver/mongoconfigserver-01:27017,mongoconfigserver-02:27017,mongoconfigserver-03:27017
volumes:
- /etc/localtime:/etc/localtime:ro
Run Code Online (Sandbox Code Playgroud)
和日志:
mongo-router-01 | 2018-03-14T22:46:40.857+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mongoconfigserver-02:27017 (1 connections now open to mongoconfigserver-02:27017 with a 5 second timeout)
mongo-router-01 | 2018-03-14T22:46:40.857+0100 I NETWORK [shard registry reload] Successfully connected to mongoconfigserver-03:27017 (1 connections now open to mongoconfigserver-03:27017 with a 5 second timeout)
mongo-router-01 | 2018-03-14T22:46:40.857+0100 I NETWORK [monitoring keys for HMAC] Successfully connected to mongoconfigserver-01:27017 (1 connections now open to mongoconfigserver-01:27017 with a 5 second timeout)
mongo-router-01 | 2018-03-14T22:46:40.858+0100 W NETWORK [monitoring keys for HMAC] Unable to reach primary for set mongoconfigserver
mongo-router-01 | 2018-03-14T22:46:41.359+0100 W NETWORK [mongosMain] Unable to reach primary for set mongoconfigserver
mongo-router-01 | 2018-03-14T22:46:41.359+0100 I NETWORK [mongosMain] Cannot reach any nodes for set mongoconfigserver. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
mongo-router-01 | 2018-03-14T22:46:41.860+0100 W NETWORK [mongosMain] Unable to reach primary for set mongoconfigserver
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
小智 0
在配置服务器中设置以下参数。
use admin
config = {
_id : "configs",
members : [
{_id : 0, host : "ip:21000" },
{_id : 1, host : "ip:21000" },
{_id : 2, host : "ip:21000" }
]
}
rs.initiate(config);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4649 次 |
| 最近记录: |