0

I have an existing mongo (3.4) database that is growing quickly, so I need to shard it. I am only getting started with sharding/replication and I'm going through the documentation at the moment.

Is this a logical sequence of events for sharding and replicating an existing collection:

  1. create 3x config server replica set
  2. connect the existing mongo server with the config set
  3. enable sharding on the existing db
  4. create another mongo server and connect with the config set
  5. shard existing collection
  6. create replica servers and connect with the config set

Thanks

3
  • Something to keep in mind is that the MongoDB docs generally assume that your existing DB is already in a replica set before you begin steps to implement sharding. This replica set becomes the first shard. Nov 3, 2017 at 14:25
  • In my scenario, the existing machine would become the first shard, and I would then replicate it in order to create a replica set. Would this work?
    – mils
    Nov 4, 2017 at 2:54
  • Theoretically it seems like it should, but I haven't tried it that way. Nov 4, 2017 at 16:54

1 Answer 1

1

Yes, you can do it just like that. Shards in the cluster don't need to be replica sets, but it is of course recommended. And later, it is possible to convert those nodes to single node replica sets and after that add more nodes to those replica sets. However, after making node as replica set, you need to do little "under the hood" updates, so that config server (and mongos) will know that shard(s) are now replica sets and not single nodes anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.