- Reference >
- Database Commands >
- Sharding Commands >
- shardingState
shardingState¶
On this page
-
shardingState¶ shardingStateis an admin command that reports ifmongodis a member of a sharded cluster.shardingStatehas the following prototype form:To run the command, you must run against the
admindatabase. Seedb.adminCommand().
Behavior¶
For shardingState to detect that a mongod is a
member of a sharded cluster, the mongod must satisfy the
following conditions:
- the
mongodis a primary member of a replica set, and - the
mongodinstance 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:
Otherwise, shardingState will return the following document:
The response from shardingState when used with a
config server is:
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.