content_image/834881.jpg content_image/834880.jpg
<img src='content_image/834881.jpg'>

Next, the destination shard captures and applies all changes made to the data during the migration process. Finally, the metadata regarding the location of the chunk on config server is updated. 

If there’s an error during the migration, the balancer aborts the process leaving the chunk unchanged on the origin shard. MongoDB removes the chunk’s data from the origin shard after the migration completes successfully. 

<img src='content_image/834880.jpg'>

## Adding and Removing Shards from the Cluster 

Adding a shard to a cluster creates an imbalance since the new shard has no chunks. While MongoDB begins migrating data to the new shard immediately, it can take some time before the cluster balances. 

When removing a shard, the balancer migrates all chunks from a shard to other shards. After migrating all data and updating the meta data, you can safely remove the shard. 

## 10.1.5 Additional Resources 

• Sharding Methods for MongoDB (Presentation) 2 

• Everything You Need to Know About Sharding (Presentation) 3 

• MongoDB for Time Series Data: Sharding 4 

• MongoDB Operations Best Practices White Paper 5 

