Tools for monitoring mongodb replica set


First of all, make sure that the replica set is set up properly.

// In one of the replica servers
PRIMARY> rs.status()

In the result, you can verify the members of the set, also check the health, uptime and ping of each member.

Now let’s see the statistics for all members. When read or write is performed, we can see which member is servicing the request

mongostat --discover

In my test scenario, I have 3 nodes (2 nodes and one arbiter) and in case I lose one, I still have enough nodes to elect a new primary and have replication to a backup node.

Now simulate a case when the secondary is down

SECONDARY> use admin
switched to db admin
SECONDARY> db.shutdownServer()

Hitting the app to check and writing data from the app still works. Yay! Failover should be automatic since mongo client knows the right set members. More here


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s