Databases Reference
In-Depth Information
"shard" : "shard0"
}
This is what a collection with a single chunk will look like: the chunk range goes from
-∞ (MinKey) to ∞ (MaxKey) .
Sharding Commands
We've already covered some of the basic commands, such as adding chunks and ena-
bling sharding on a collection. There are a couple more commands that are useful for
administering a cluster.
Getting a summary
The printShardingStatus function will give you a quick summary of the previous
collections:
> db.printShardingStatus()
--- Sharding Status ---
sharding version: { "_id" : 1, "version" : 3 }
shards:
{ "_id" : "shard0", "host" : "localhost:10000" }
{ "_id" : "shard1", "host" : "localhost:10001" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "foo", "partitioned" : false, "primary" : "shard1" }
{ "_id" : "x", "partitioned" : false, "primary" : "shard0" }
{ "_id" : "test", "partitioned" : true, "primary" : "shard0",
"sharded" : { "test.foo" : { "key" : { "x" : 1 }, "unique" : false } } }
test.foo chunks:
{ "x" : { $minKey : 1 } } -->> { "x" : { $maxKey : 1 } } on : shard0
{ "t" : 1276636243000, "i" : 1 }
Removing a shard
Shards can be removed from a cluster with the removeshard command. removeshard
drains all of the chunks on a given shard to the other shards.
> db.runCommand({"removeshard" : "localhost:10000"});
{
"started draining" : "localhost:10000",
"ok" : 1
}
As the shard is drained, removeshard will give you the status of how much remains on
the shard.
> db.runCommand({"removeshard" : "localhost:10000"});
{
"msg" : "already draining...",
"remaining" : {
"chunks" : 39,
"dbs" : 2
},
 
Search WWH ::




Custom Search