// Aula 5 - Particionamento de dados com Chunks

No servidor Mongos digite:

use myShardedDB

db.dropDatabase()

sh.enableSharding('myShardedDB')

sh.shardCollection('myShardedDB.users', {age: 1})

Em um outro terminal, digite:

mongoimport -h 192.168.1.210 --port 27027 --type csv --headerline -d myShardedDB -c users mockdata2.csv

sh.status()

sh.stopBalancer()

use admin

db.runCommand({split: 'myShardedDB.users', middle: {age: 50}})

sh.status()

sh.moveChunk('myShardedDB.users', {age: 52}, "shard0002")

sh.startBalancer()

sh.status()

Pronto, já manuseamos os documentos do valor de 52 para o shard0002 ou algum outro servidor de sua escolha.

Links de referência:
https://docs.mongodb.com/manual/core/sharding-data-partitioning/
https://docs.mongodb.com/manual/tutorial/create-chunks-in-sharded-cluster/
https://docs.mongodb.com/manual/tutorial/modify-chunk-size-in-sharded-cluster/
https://goo.gl/gJQV3X












