Adicionei um shard a um cluster existente e, quando faço db.printShardingStatus(), vejo uma distribuição:
mongos> db.printShardingStatus()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"minCompatibleVersion" : 5,
"currentVersion" : 6,
"clusterId" : ObjectId("5c84149e75f51a74e9796add")
}
shards:
{ "_id" : "shard0000", "host" : "127.0.0.1:27023", "state" : 1 }
{ "_id" : "shard0001", "host" : "127.0.0.1:27024", "state" : 1 }
{ "_id" : "shard0002", "host" : "localhost:27025", "state" : 1 }
active mongoses:
"4.0.6" : 1
autosplit:
Currently enabled: yes
balancer:
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 3
Last reported error: Error connecting to localhost:27025 (127.0.0.1:27025) :: caused by :: Connection refused
Time of Reported error: Sat Mar 09 2019 20:55:55 GMT+0000 (UTC)
Migration Results for the last 24 hours:
8 : Success
databases:
{ "_id" : "config", "primary" : "config", "partitioned" : true }
config.system.sessions
shard key: { "_id" : 1 }
unique: false
balancing: true
chunks:
shard0000 1
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : { "$maxKey" : 1 } } on : shard0000 Timestamp(1, 0)
{ "_id" : "testdb", "primary" : "shard0001", "partitioned" : true, "version" : { "uuid" : UUID("68b7f8fe-17f6-4049-87ce-6c616c7746b7"), "lastMod" : 1 } }
testdb.testcollection
shard key: { "testkey" : 1 }
unique: false
balancing: true
chunks:
shard0000 3
shard0001 3
shard0002 1
{ "testkey" : { "$minKey" : 1 } } -->> { "testkey" : "key0" } on : shard0002 Timestamp(9, 0)
{ "testkey" : "key0" } -->> { "testkey" : "key20968" } on : shard0000 Timestamp(7, 1)
{ "testkey" : "key20968" } -->> { "testkey" : "key4265" } on : shard0000 Timestamp(4, 0)
{ "testkey" : "key4265" } -->> { "testkey" : "key53621" } on : shard0000 Timestamp(6, 0)
{ "testkey" : "key53621" } -->> { "testkey" : "key64595" } on : shard0001 Timestamp(5, 1)
{ "testkey" : "key64595" } -->> { "testkey" : "key8552" } on : shard0001 Timestamp(9, 1)
{ "testkey" : "key8552" } -->> { "testkey" : { "$maxKey" : 1 } } on : shard0001 Timestamp(4, 1)
Mas quando eu acesso o shard recém adicionado (shard0002), a coleção está vazia? Alguem sabe por quê?
Adicionar fragmentos a um cluster
Conforme mencionado na documentação do MongoDB,