Chapter 16. Sharding Administration
A sharded cluster is the most difficult type of deployment to administer. This chapter gives advice on performing administrative tasks on all parts of a cluster, including:
Inspecting what the cluster’s state is: who its members are, where data is held, and what connections are open
How to add, remove, and change members of a cluster
Administering data movement and manually moving data
Seeing the Current State
There are several helpers available to find out what data is where, what the shards are, and what the cluster is doing.
Getting a Summary with sh.status
sh.status() gives you an
overview of your shards, databases, and sharded collections. If you have
a small number of chunks, it will print a breakdown of which chunks are
where as well. Otherwise it will simply give the collection’s shard key
and how many chunks each shard has:
>sh.status()---ShardingStatus---shardingversion:{"_id":1,"version":3}shards:{"_id":"shard0000","host":"localhost:30000","tags":["USPS","Apple"]}{"_id":"shard0001","host":"localhost:30001"}{"_id":"shard0002","host":"localhost:30002","tags":["Apple"]}databases:{"_id":"admin","partitioned":false,"primary":"config"}{"_id":"test","partitioned":true,"primary":"shard0001"}test.fooshardkey:{"x":1,"y":1}chunks:shard00004shard00024shard00014{"x":{$minKey:1},"y":{$minKey:1}}-->>{"x":0,"y":10000}on:shard0000{"x"
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access