This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // response time by operation type | |
| db.system.profile.aggregate( { | |
| $group : { | |
| _id :"$op", | |
| count:{$sum:1}, | |
| "max response time":{$max:"$millis"}, | |
| "avg response time":{$avg:"$millis"} | |
| } | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use <dbname> | |
| db.setProfilingLevel(0) | |
| db.system.profile.drop() | |
| db.runCommand( { create : "system.profile", capped : true, size : 104857600 } ) | |
| db.setProfilingLevel(2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var allChunkInfo = function(ns){ | |
| var chunks = db.getSiblingDB("config").chunks.find({"ns" : ns}).sort({min:1}); //this will return all chunks for the ns ordered by min | |
| //some counters for overall stats at the end | |
| var totalChunks = 0; | |
| var totalSize = 0; | |
| var totalEmpty = 0; | |
| print("ChunkID,Shard,ChunkSize,ObjectsInChunk"); // header row | |
| // iterate over all the chunks, print out info for each | |
| chunks.forEach( | |
| function printChunkInfo(chunk) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mkdir -p /tmp/mongodump | |
| mongodump --host $HOST --port $PORT --username $USERNAME --password $PASSWORD --authenticationDatabase $DBNAME --db config --out /tmp/mongodump/ > /tmp/mongodump/mongodump.log | |
| tar -cz -C /tmp -f /tmp/mongodump.tgz mongodump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Connect a Mongo shell to each of your config servers, and run the following: | |
| use config | |
| db.runCommand({dbhash:1}) | |
| db.changelog.find().sort({ $natural: 1 }).limit(10) | |
| db.chunks.find().sort({ $natural: 1 }).limit(10) |
NewerOlder