Find a Shard Key查找分片键
Every shared collection has a shard key. 每个共享集合都有一个分片键。To display the shard key, connect to a 要显示分片键,请连接到mongos
instance and run the db.printShardingStatus()
method:mongos
实例并运行db.printShardingStatus()
方法:
db.printShardingStatus()
The output resembles:输出类似于:
<dbname>.<collection>
shard key: { <shard key> : <1 or hashed> }
unique: <boolean>
balancing: <boolean>
chunks:
<shard name1> <number of chunks>
<shard name2> <number of chunks>
...
{ <shard key>: <min range1> } -->> { <shard key> : <max range1> } on : <shard name> <last modified timestamp>
{ <shard key>: <min range2> } -->> { <shard key> : <max range2> } on : <shard name> <last modified timestamp>
...
tag: <tag1> { <shard key> : <min range1> } -->> { <shard key> : <max range1> }
...
For more details on the 有关db.printShardingStatus()
output, see the sharded collection section on the sh.status()
page.db.printShardingStatus()
输出的更多详细信息,请参阅sh.status()
页面上的分片集合部分。