How user authentication works in a shared MongoDB cluster

Today, I want to clarify an important point about users authentication in a MongoDB sharded cluster because this seems to be misunderstood by some people.

In a such environment, there are two notions to understand about user authentication, especially when you are DBA:

  • cluster¬†authentication, that is, the authentication made when connected trough a “mongos” process.
  • local¬†authentication, that is, the authentication made when connected locally on a shard trough a “mongod” process.

Continue reading “How user authentication works in a shared MongoDB cluster”

MongoDB sharded cluster topology

Today, I’m going to share with you a bash script that gives you a quick overview of the topology of your MongoDB cluster.

It will give you:

  • The list and status of your mongos
  • The list and status of your config server
  • The list and status of every replica set members present in your cluster (including secondary members and arbiters), plus:
    • The date of the last role change between primary and secondary
    • The apply lag between primary and all secondary members
    • The oplog window
  • The balancer status

You can download the script on my GitHut repository “MyDBAWorld”.

Continue reading “MongoDB sharded cluster topology”

Get chunk distribution for all databases in a MongoDB cluster

One of the most important tasks for maintaining good performance in a sharded MongoDB cluster is to ensure optimal chunk distribution across each cluster member.

I’m not going to talk about picking a good shard key for your collections because the MongoDB documentation on the subject is pretty good. But I will share with you a script that I use to get the chunk distribution for all databases on a MongoDB sharded cluster.

Continue reading “Get chunk distribution for all databases in a MongoDB cluster”