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”
One possible area of improvement when you encounter bottlenecks when inserting or updating in MongoDB is to limit the number of indexes on your collections.
Even though indexes are good for queries against collections, they add an extra step when inserting or updating, which may take some time. Given this fact, it may be wise to delete unused indexes.
So, today, I’m going to give you a Mongo shell script that I use to get statistics on indexes usage for all collections on a MongoDB instance and to identify those that are not used.
Continue reading “Get indexes usage for all collections of all databases of your MongoDB instance”
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”
If you read my last post, you now know how to get a valid JSON output from your MongoDB shell.
But raw JSON is often useless in your scripts because you have to manipulate it to extract only the information you need.
For this purpose, I personalty use a free tool called “jq“. It is very powerful and has many advanced features. I will only show you some basic concepts that will allow you to simply deal with JSON data in your scripts.
Continue reading “How to deal with MongoDB shell output in your shell scripts – Part 2/2: parsing JSON with jq”
Today, I will show you how to easily deal with MongoDB shell output in your shell (bash, ksh, …) scripts.
For readybility purpose, this topic will be divided into 2 posts. This part will focus on how to produce valid JSON output from your MongoDB shell using the “–eval” option. Second part will focus on how to use “jq” to manipulate JSON data.
Continue reading “How to deal with MongoDB shell output in your shell scripts – Part 1/2: produce valid JSON output”
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”