0

I have a shard cluster: one mongos, three shard replica sets and one config replica set. My application only talks to the mongos for read/write to mongodb. I wonder whether I can make the mongos replica. What I mean by this is that in case of a mongos is down, I need a slave of the mongos to become the primary. There is --replSet parameter on mongod but mongos doesn't have such parameter. How can I make it in mongos?

1 Answer 1

0

You cannot have mongos as a replica set, it is just "proxy" between application and cluster. You can have multiple mongos-services. Normally you create mongos service to the same machine where you have the application. So, every application node has its own mongos and your application connects to that localhost mongos. If you mongos is down, your (single) application is down already, probably.

Of course, nothing prevents you to create multiple mongos nodes and put load balancer to the front of them. But I wouldn't recommend that.

6
  • If I have multiple applications deployed in a cloud-based environment and they need to talk to the same mongos, based on your suggestion, each application has its own mongos process. And each mongos will have the same shards members. Is this correct? Oct 12, 2017 at 6:29
  • 1
    Applications do not need to speak to same mongos! Every mongos takes its own connections to all primaries (config and shard). Needed information is exchanged between mongos.
    – JJussi
    Oct 12, 2017 at 9:04
  • Can one shard be added to multiple mongos? Nov 27, 2017 at 20:19
  • You don't add shard to mongos. Every mongos connects every shard automatically, base on information what it gets from config server.
    – JJussi
    Nov 28, 2017 at 4:06
  • Can one shard server connect with multiple mongos? Since my mongos is running with the same server as my application server, and I have multiple app servers work as a replica set, I don't want all my app servers to talk to one mongos instance. So there is a need to create multiple mongos instances in my app system. Is it possible? Nov 28, 2017 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.