Boas Enkler
Boas Enkler

Reputation: 12557

Best Practice automated MongoDb Cluster Restart

We have a MongoDB cluster and would like to restart all members of a cluster.

We could automate the windows services to restart or use shutdownServer via mognoshell.

But we don't want to have the database unavailable, so an idea would be to only restart the slaves, make a step down, then restart the old master.

I know I can determine masters and slaves with rs.status() and with rs.StepDown() and rs.freeze() I can manage who the primary is.

But is there an built in way to restart a MongoDB cluister without downtime? Or would I have to write a tool which reads the status of the server and then handles this manually?

Upvotes: 1

Views: 446

Answers (1)

profesor79
profesor79

Reputation: 9473

There is no "safe restart" mechanism build in mongo yet.

To solve that, custom tool will have to follow those steps:

  • Take list of servers (A, B, C)
  • Check if A is primary -> if not restart and wait x minutes
  • -> if yes put it at the end of list

....

  • when we reach last server - issue stepdown, wait for finish and restart

When stepdown is issued - all clients are forcibly disconnected from master, but reconnection will be made to new master immediately.

Upvotes: 1

Related Questions