MongoDB Clustering – Setting Up Mongo with Clustering

mongodb

I'm going to start using Mongo as a database but I will not have it clustered at first. Can I use Mongo on a single machine, then later come back, cluster it and capitalize on the sharding? Or can I set it up for a cluster with only one machine until I have more to add to the cluster?

Best Answer

You can do it either way.

There isn't much benefit to starting all of the overhead for sharding now, unless you simply want to try it out to see how it works. It is important to pick the correct shard key, so you would want to make sure your schema and insert/update usage is firm enough to know what to pick.

Kristina Chodorow has a great blog entry about how to pick a shard key: http://www.snailinaturtleneck.com/blog/2011/01/04/how-to-choose-a-shard-key-the-card-game/

For general information about how sharding works: http://www.snailinaturtleneck.com/blog/2010/03/30/sharding-with-the-fishes/

For some instructions on how to set up clustering on a single machine, see here: http://www.mongodb.org/display/DOCS/A+Sample+Configuration+Session and here: http://www.snailinaturtleneck.com/blog/2010/08/30/return-of-the-mongo-mailbag/