ouzhoudijie 发表于 2018-10-27 08:38:03

MONGODB SHARDING

Balancing
  The balancer is a background process that manages chunk migrations. The balancer runs in all of the query routers in a cluster.
  When the distribution of a sharded collection in a cluster is uneven, the balancer process migrates chunks from the shard that has the largest number of chunks to the shard with the least number of chunks until the collection balances. For example: if collection users has 100 chunks on shard 1 and 50 chunks on shard 2, the balancer will migrate chunks from shard 1 to shard 2 until the collections achieves balance.
  The shards manage chunk migrations as a background operation. During migration, all requests for a chunks data address the “origin” shard.
  In a chunk migration, the destination shard receives all the documents in the chunk from the origin shard. Then, the destination shard captures and applies all changes made to the data during migration process. Finally, the destination shard updates the metadata regarding the location of the on config server.
  If there’s an error during the migration, the balancer aborts the process leaving the chunk on the origin shard. MongoDB removes the chunks data from the origin shard after the migration completes successfully.
  Diagram of a collection distributed across three shards. For this collection, the difference in the number of chunks between the shards reaches the migration thresholds (in this case, 2) and triggers migration.

页: [1]
查看完整版本: MONGODB SHARDING