OPTIONS

shardingState

shardingState

shardingState is an admin command that reports if mongod is a member of a sharded cluster. shardingState has the following prototype form:

{ shardingState: 1 }

For shardingState to detect that a mongod is a member of a sharded cluster, the mongod must satisfy the following conditions:

  1. the mongod is a primary member of a replica set, and
  2. the mongod instance is a member of a sharded cluster.

If shardingState detects that a mongod is a member of a sharded cluster, shardingState returns a document that resembles the following prototype:

{
  "enabled" : true,
  "configServer" : "<configdb-string>",
  "shardName" : "<string>",
  "shardHost" : "string:",
  "versions" : {
       "<database>.<collection>" : Timestamp(<...>),
       "<database>.<collection>" : Timestamp(<...>)
  },
  "ok" : 1
}

Otherwise, shardingState will return the following document:

{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }

The response from shardingState when used with a config server is:

{ "enabled": false, "ok": 1 }

Note

mongos instances do not provide the shardingState.

Warning

This command obtains a write lock on the affected database and will block other operations until it has completed; however, the operation is typically short lived.

Was this page helpful?

Yes No

Thank you for your feedback!

We're sorry! You can Report a Problem to help us improve this page.