简体   繁体   中英

Mongos can add replica set, but can't connect

I'm setting up a sharded mongo cluster. I have two replica sets consisting of two nodes each, a replica set of three config servers, and a single mongos instance.

I have been able to add the replica set to the mongos instance:

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

This returns {"ok" : 1} and the same is true of the second replica set.

However when I try to do any database operations such as db.test.insert(...) I receive this error:

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

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:

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" }] } )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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