0

We have a sharded cluster with several collections sharded. There are two collections that cannot be sharded because there is a unique index on the collection. So these two collections are on the primary shard. We want to make sure our application is available when this primary shard goes down. We thought of using the movePrimary() admin command to move the primary to other shard. However, this doesn't work when the current primary shard is not available (a disaster scenario where only one node of primary shard is available and the shard has become readonly)

Example: Consider two shards replSet1 and replSet2 with 3 nodes each. There is a non sharded collection NonShardedCollection that currently resides in replSet2 because replSet2 is primary shard. We connect to a mongos from our application to query the data from this system. Now because of an issue in replSet2, two of the nodes go down. Now replSet2 has only 1 node and has become read only. Is there a way for us to move the primary shard to replSet1 so that we can continue to do the inserts in NonShardedCollection from mongos?

Tried calling movePrimary command throws an error "Could not find host matching read preference { mode: "primary" } for set replSet2"

Any help in this is very much appreciated.

5
  • Looks like a question for Database Administrators Commented Mar 21 at 20:48
  • What about all of the sharded data that resides on the primary shard?
    – Joe
    Commented Mar 21 at 21:07
  • Each of your shard has 3 members. If 2 of them go down, then the third one cannot become the PRIMARY, i.e. the entire shard replSet2 becomes read/only. Thus you cannot change anything. Moving data from a node is also a write operation. Commented Mar 22 at 15:23
  • What you could do is to set the two members as passive. Then the remaining node becomes a PRIMARY member. Commented Mar 22 at 15:26
  • That’s one way, thanks. I was hoping we could copy the data to another shard thru dump and restore but problem is that won’t allow us to query from mongos. Commented Mar 22 at 21:56

0

Your Answer

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

Browse other questions tagged or ask your own question.