Useful Scripts for working with MongoDB
This script will connect to a sharded cluster, retrieve all of the interesting and useful diagnostic information I could think of, and put it all in a neat file in /tmp.
./getShardingDiags.sh --host $MONGOS_HOST --port $PORT
- Replace $MONGOS__HOST with the hostname where a 'mongos' process is running
- Replace $PORT with the port number that this 'mongos' is listening to
- BASH shell
- The 'mongo' shell and 'mongodump' must be installed in the $PATH of the user running the script
- Only tested on OSX so far -- beware bugs!
- Contents of the collections, databases, locks, lockpings, mongos, settings, shards, and tags collections from the config database
- A 'mongodump' of the config database
- The output of 'sh.status(true)'
- Collection stats() and indexes for every collection in every database in the cluster
- There is one such directory for each shard in the cluster
- This directory contains the following information from the primary for the shard:
- Connection pool stats
- As much of the log file as is in the internal capped collection
- If the shard is a replica set, this directory will also contain the following information from the primary node:
- Replication information
- There is one such directory for each 'mongos' listed in the config database
- This directory contains the same information for each 'mongos' that is collected for a standalone shard