I have a single replica set having 3 mongod instance, collection in this instance has data already.

I want to convert this instance to sharded cluster. I followed Convert a Replica Set to a Sharded Cluster but when I access my mongod at the end of the setup it doesn't show the existing data.

Any suggestions?

1 Answer 1

  1. You have config server replica set installed?
  2. You are running at least one mongoS -service
  3. You are connecting (with mongo) to mongoS when you are working with cluster
  4. You have added your replica set(s) to the cluster with sh.addShard() -command
  5. You have added (at least one) your databases to cluster with command sh.enableSharding("yourDBname")

This point your collection is still there, sitting on original location with all data. You still need to shard your collections, which data is needed to "spread" to other shards (nodes).

  • I apologize for error in my question. I have a single replica set which was build for exploration purpose. Now i am trying to partition it to sharded cluster. But i don't want to loose the data in the rpl set currently present
    – Geek
    Jul 3, 2017 at 12:59
  • You are not loosing data, because nothing is removed or moved during sharding procedure. After you have added at least one new replica set to cluster AND start sharding at least one collection, data is moved but only IF you start balancer procedure. Connect to your mongos -service and give command sh.status() and provide result here, then we can check what is wrong with your setup.
    – JJussi
    Jul 3, 2017 at 13:13
  • re-writing answer...
    – JJussi
    Jul 3, 2017 at 13:28

Your Answer

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

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