my current cluster sh.status() is as below:

    {  "_id" : "rsDev",  "host" : "rsDev/," }
    {  "_id" : "rsRaw",  "host" : "rsRaw/," }
  active mongoses:
    "3.0.14" : 1
    Currently enabled:  yes
    Currently running:  no
    {  "_id" : "mike",  "partitioned" : true,  "primary" : "rsDev" }
            shard key: { "_id" : 1 }
            unique: false
            balancing: true
                rsDev   23
                rsRaw   22
            too many chunks to print, use verbose if you want to force print

Now I want to add a new shard into this cluster by

db.runCommand({addShard: "rsPro/", maxSize:1})

After google about maxSize, it is a soft limit for balancer. If I add the new shard rsPro using above command, it start to balance all chunks. If I don't stop the balancer, is there any way to prevent any chunk moving to the new shard rsPro ?

  • What is your goal as far as adding a new shard but not having it accept chunk migrations? Stopping the balancer is the appropriate way to prevent migrations. – Stennie Jan 20 '17 at 3:00
  • @Stennie, I am trying to migrate data to new bought machines, If I add a new shard into current cluster and then use movePrimary to move database to new shard. Cause my boss hope we can keep service alive and also data still can keep inserting when migration. – CSJ Jan 20 '17 at 3:04
  • Migrating to new hardware without downtime is the Migrate a Sharded Cluster to Different Hardware procedure I mentioned on the related question ;-). I'll comment on the earlier question (since it has more details) to hopefully clarify. – Stennie Jan 20 '17 at 3:14

There is other solution, if you want to migrate you data to new machine "on-the-fly" and have only short interruption when you transfer your clients to use that new machine. With this you can replicate data to new location

If you want to add new shard to cluster and still keep balancer running... you can always use TAGs.. Tag your current shards and define that $MinKey - $MaxKey chunk area belongs to that TAG. Check here what I'm talking about

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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