Zocoi Vietnamese /ʒoʊ kɔɪ/: (informal) Let's watch/read together

Tools for monitoring mongodb replica set

mongodb

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

[code]
// In one of the replica servers
mongo
PRIMARY> rs.status()
[/code]

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

[code]
mongostat --discover
[/code]

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

[code]
mongo
SECONDARY> use admin
switched to db admin
SECONDARY> db.shutdownServer()
[/code]

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