简体   繁体   English

Mongos可以添加副本集,但无法连接

[英]Mongos can add replica set, but can't connect

I'm setting up a sharded mongo cluster. 我正在建立一个分片的mongo集群。 I have two replica sets consisting of two nodes each, a replica set of three config servers, and a single mongos instance. 我有两个副本集,每个副本集包含两个节点,一个由三个配置服务器组成的副本集,以及一个mongos实例。

I have been able to add the replica set to the mongos instance: 我已经能够将副本集添加到mongos实例:

sh.addShard("rs1/shard-rs01-s01");

This returns {"ok" : 1} and the same is true of the second replica set. 这将返回{“ok”:1},第二个副本集也是如此。

However when I try to do any database operations such as db.test.insert(...) I receive this error: 但是,当我尝试执行任何数据库操作,如db.test.insert(...)时,我收到此错误:

2017-02-23T01:17:28.599+0000 I ASIO [CatalogManagerReplacer] Connecting to shard-RS01-S01:27017 2017-02-23T01:17:28.600+0000 I ASIO [CatalogManagerReplacer] Connecting to config-01:27019 2017-02-23T01:17:28.603+0000 I ASIO [CatalogManagerReplacer] Successfully connected to config-01:27019 2017-02-23T01:17:48.600+0000 I ASIO [CatalogManagerReplacer] Failed to connect to shard-RS01-S01:27017 - ExceededTimeLimit: Operation timed out 2017-02-23T01:17:28.599 + 0000 I ASIO [CatalogManagerReplacer]连接到shard-RS01-S01:27017 2017-02-23T01:17:28.600 + 0000 I ASIO [CatalogManagerReplacer]连接到config-01:27019 2017- 02-23T01:17:28.603 + 0000 I ASIO [CatalogManagerReplacer]已成功连接到config-01:27019 2017-02-23T01:17:48.600 + 0000 I ASIO [CatalogManagerReplacer]无法连接到shard-RS01-S01:27017 - ExceededTimeLimit:操作超时

I double checked that the firewall wasn't blocking the connection by disabling it on all of the systems. 我仔细检查了防火墙是否通过在所有系统上禁用它来阻止连接。 For what it is worth, on the node that contains the mongos instance I can connect to the replica-set directly through the command like using this command regardless of the firewall state: 对于它的价值,在包含mongos实例的节点上,我可以直接通过命令连接到副本集,就像使用此命令一样,无论防火墙状态如何:

mongo --host rs1/shard-rs01-s01:27017

So I am fairly sure it is not a firewall issue. 所以我很确定它不是防火墙问题。 Anyone have any ideas? 有人有想法么?

Here's a shard map of the setup if it is useful for anyone able to help... 这是设置的分片图,如果它对任何能够提供帮助的人都有用...

mongos> db.runCommand("getShardMap")
{
    "map" : {
        "config" : "rs0/config-01:27019,config-02:27019,config-03:27019",
    "config-01:27019" : "rs0/config-01:27019,config-02:27019,config-03:27019",
    "config-02:27019" : "rs0/config-01:27019,config-02:27019,config-03:27019",
    "config-03:27019" : "rs0/config-01:27019,config-02:27019,config-03:27019",
    "rs0/config-01:27019,config-02:27019,config-03:27019" : "rs0/config-01:27019,config-02:27019,config-03:27019",
    "rs1" : "rs1/shard-RS01-S01:27017,shard-RS01-S02:27017",
    "rs1/shard-RS01-S01:27017,shard-RS01-S02:27017" : "rs1/shard-RS01-S01:27017,shard-RS01-S02:27017",
    "rs2" : "rs2/shard-RS02-S03:27017,shard-RS02-S04:27017",
    "rs2/shard-RS02-S03:27017,shard-RS02-S04:27017" : "rs2/shard-RS02-S03:27017,shard-RS02-S04:27017",
    "shard-RS01-S01:27017" : "rs1/shard-RS01-S01:27017,shard-RS01-S02:27017",
    "shard-RS01-S02:27017" : "rs1/shard-RS01-S01:27017,shard-RS01-S02:27017",
    "shard-RS02-S03:27017" : "rs2/shard-RS02-S03:27017,shard-RS02-S04:27017",
    "shard-RS02-S04:27017" : "rs2/shard-RS02-S03:27017,shard-RS02-S04:27017"
},
"ok" : 1

} }

你需要初始化你的mongos。

rs.initiate( { _id: "configReplSet", configsvr: true, members: [ { _id: 0, host: "mongo-config-1:27017" }] } )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM