For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

View Cluster Configuration

To list your databases, query the databases collection in the Config Database. Connect mongosh to a mongos instance and run the following operation to get a full list of the databases in your cluster:

use config
db.databases.find()

To list the current set of configured shards, use the listShards command, as follows:

db.adminCommand( { listShards : 1 } )

To view cluster details, issue db.printShardingStatus() or sh.status(). Both methods return the same output.

Example

In the following example output from sh.status()

  • sharding version displays the version number of the shard metadata.

  • shards displays a list of the mongod instances used as shards in the cluster.

  • databases displays information about all databases in the cluster.

  • The chunks information for the foo database displays how many chunks are on each shard and displays the range of each chunk.

--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("59a4443c3d38cd8a0b40316d")
}
shards:
{ "_id" : "shard0000", "host" : "m0.example.net:27018" }
{ "_id" : "shard0001", "host" : "m3.example2.net:27018" }
{ "_id" : "shard0002", "host" : "m2.example.net:27018" }
active mongoses:
"3.4.7" : 1
autosplit:
Currently enabled: yes
balancer:
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
1 : Success
databases:
{ "_id" : "foo", "primary" : "shard0000" }
foo.contacts
shard key: { "zip" : 1 }
unique: false
balancing: true
chunks:
shard0001 2
shard0002 3
shard0000 2
{ "zip" : { "$minKey" : 1 } } -->> { "zip" : "56000" } on : shard0001 { "t" : 2, "i" : 0 }
{ "zip" : 56000 } -->> { "zip" : "56800" } on : shard0002 { "t" : 3, "i" : 4 }
{ "zip" : 56800 } -->> { "zip" : "57088" } on : shard0002 { "t" : 4, "i" : 2 }
{ "zip" : 57088 } -->> { "zip" : "57500" } on : shard0002 { "t" : 4, "i" : 3 }
{ "zip" : 57500 } -->> { "zip" : "58140" } on : shard0001 { "t" : 4, "i" : 0 }
{ "zip" : 58140 } -->> { "zip" : "59000" } on : shard0000 { "t" : 4, "i" : 1 }
{ "zip" : 59000 } -->> { "zip" : { "$maxKey" : 1 } } on : shard0000 { "t" : 3, "i" : 3 }
{ "_id" : "test", "primary" : "shard0000" }