Last Updated: February 25, 2016
·
1.955K
· tylerbrock

Fast MongoDB Sharded Cluster

Working at 10gen, we often find it necessary to test something that requires a sharded cluster. Sharded clusters typically have many moving parts so setting one up can seem like a daunting task. However, what a lot of developers don't know that you can do this really easily using the mongo shell. This is how:

Start the mongo shell without connecting to a database:

mongo --nodb

Then start a new sharding test specifying the number of mongos and shards that you would like:

var st = new ShardingTest({ shards: 2, mongos: 1 })

Done!

The logging output from each of the processes will be piped to this single shell (so there will be a lot). This makes that shell somewhat unusable but at least it only takes up one window and spares you from having to fork and specify a log path.

1 Response
Add your response