I’ve been reading about split Mongo databases and escalate through shards, but I’m thinking if possible to split a mongo database in the same server by chunks and store that in different files, the range of shard keys will be calculated using a formula considering the number of week and the current year something like (year)x54 + current week number of the year
let’s say 2010×54 + 11 = 108551
Ideally what I have in mind is to split the files by month like the following:
chunk01 (shardKeyID 108551 -> 108555) ----> Server1---> physical file 01
chunk02 (shardKeyID 108556 -> 108560) ----> Server1---> physical file 02
chunk03 (shardKeyID 108561 -> 108565) ----> Server1---> physical file 03
I’ve tried to do it in a single server, but if I it set up for shards I just get a subset of the documents in the DB, something that make sense because the other part will be stores in the other shard in a different server.
Any Ideas?
You can set up a shard cluster on a single server by running separate
mongodinstances on different ports. Instructions can be found in this tutorial.Regarding the splitting of chunks, this is handled automatically by the database. Be aware that by default, your collection will shard using the default chunk size of 64MB. See more details here:
You seem to be describing your own algorithm for when to balance, this is not possible. You will really need to leave it to cluster balancer to figure this out for you.