Database Reference
In-Depth Information
The removeShard command responds with a message indicating that the removal process has started. It also
indicates that mongos has begun relocating the chunks on the target shard server to the other shard servers in the
cluster. This process is known as draining the shard.
You can check the progress of the draining process by reissuing the removeShard command. The response will
tell you how many chunks and databases still need to be drained from the shard:
> db.runCommand({removeShard : "localhost:27025"})
{
"msg" : "draining ongoing",
"state" : "ongoing",
"remaining" : {
"chunks" : NumberLong( 12 ),
"dbs" : NumberLong( 0 )
},
"ok" : 1
}
Finally, the removeShard process will terminate, and you will get a message indicating that the removal process
is complete:
> db.runCommand({removeShard : "localhost:27025"})
{
"msg" : "removeshard completed successfully",
"state" : "completed",
"shard" : "shard0002",
"ok" : 1
}
To verify that the removeShard command was successful, you can run listshards to confirm that the desired
shard server has been removed from the cluster. For example, the following output shows that the shard2 server that
you created previously is no longer listed in the shards array:
>db.runCommand({listshards:1})
{
"shards" : [
{
"_id" : "shard0000",
"host" : "localhost:27023"
},
{
"_id" : "shard0001",
"host" : "localhost:27024"
}
],
"ok" : 1
}
At this point, you can terminate the Shard2 mongod process and delete its storage files because its data has been
migrated back to the other servers.
Search WWH ::




Custom Search