I am very new to MongoDB and am trying to do database sharding.
I have created two MongoDB shards and inserted 10000 records in it. I have used shard key as "no" which increments by 1 in every document in ascending order.
mongos>sh.addShard("localhost:27004",{"no":1})
mongos>sh.addShard("localhost:27005",{"no":1})
Here, when I insert the records, the shard 1 gets only 6 records and shard 2 gets the rest of the records.
The output of sh.shatus()
is:
databases:
{ "_id" : "shard_test_2", "primary" : "shard0000", "partitioned" : true }
shard_test_2.test
shard key: { "no" : 1 }
unique: false
balancing: true
chunks:
shard0000 2
shard0001 1
{ "no" : { "$minKey" : 1 } } -->> { "no" : 1 } on : shard0000 Timestamp(2, 1)
{ "no" : 1 } -->> { "no" : 6 } on : shard0000 Timestamp(1, 2)
{ "no" : 6 } -->> { "no" : { "$maxKey" : 1 } } on : shard0001 Timestamp(2, 0)
Now, I want my shard one to store more documents than 6.
I read that how many documents will go to which shard is the function of balancer. So, how do I configure the balancer?
Or is there any other way of setting how much data should go to which shard? No resource online is helping much in this.