Reputation: 9783
I created a shard with two replica sets. Each replica set have 3 mongod
server and they work fine. Also, the mongos
server seems to work. Here is it's status:
mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 3,
"minCompatibleVersion" : 3,
"currentVersion" : 4,
"clusterId" : ObjectId("51c5be46dda9b0a5cd83ad64")
}
shards:
{ "_id" : "s1", "host" : "s1/RemotePC_1:27017,RemotePC_1:27018,RemotePC_1:27019" }
{ "_id" : "s2", "host" : "s2/RemotePC_2:27017,RemotePC_2:27018,RemotePC_2:27019" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "student", "partitioned" : true, "primary" : "s1" }
student.grades
shard key: { "_id" : 1 }
chunks:
s1 1
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : s1 { "t" : 1, "i" : 0 }
But, when I run any command (insert, find, count, mongoimport) on the student.grades
collection I get back this error:
mongos> db.grades.count()
Sat Jun 22 20:07:00.968 JavaScript execution failed: count failed: {
"code" : 10429,
"ok" : 0,
"errmsg" : "exception: setShardVersion failed host: RemotePC_2:27017 { oldVersion: Timestamp 0|0, oldVersionEpoch: ObjectId
('000000000000000000000000'), errmsg: \"exception: all servers down/unreachable when querying: My-PC:57017,My-PC:57018,My-PC:57019\", code: 8002, ok: 0.0 }"
} at src/mongo/shell/query.js:L180
Why? Am I missing something?
Upvotes: 1
Views: 3297
Reputation: 42352
All the members of the sharded cluster must be able to reach all the other members.
You are running mongos
on your local machine, it can reach config servers which also run on your local machine, and it can reach the shards which are running on remote machines.
However, if the shards on remote machines cannot reach the config servers on your local machine they will not be able to operate properly within the cluster (and that is the error message that you are seeing).
The solution to this would be to restart mongos
with the config server argument (--configdb
) specified as hostnames which are routable (aka findable) from "remote-PC". If you are running multiple mongos
processes you will need to do that for all of them.
Upvotes: 2