Re: [mongodb-user] problems draining a shard

501 views
Skip to first unread message

Scott Hernandez

unread,
Sep 16, 2012, 10:15:51 AM9/16/12
to mongod...@googlegroups.com
What version are you using?

Yes, you should not do this. While this may be useful for testing this
would never be something you want for a production system. You will
get an error message when running removeshard if you only have one
shard -- this is not allowed.

If you want to start over it is best to stop everything, remove the
data, and restart with a blank slate.

On Sun, Sep 16, 2012 at 4:45 AM, Sam Darwin <samuel....@gmail.com> wrote:
>
> Hi , I am a newbie and just learning mongo.
>
> I added some shards:
>
> db.runCommand({addshard : "mongo1:27018", name:"shard1"})
> db.runCommand({addshard : "mongo2:27018", name:"shard2"})
>
> and deleted some shards:
>
> db.runCommand({removeshard : "mongo1:27018"})
> db.runCommand({removeshard : "mongo2:27018"})
>
> and now I observe this with:
>
> db.printShardingStatus()
>
> mongos> db.printShardingStatus()
> --- Sharding Status ---
> sharding version: { "_id" : 1, "version" : 3 }
> shards:
> { "_id" : "shard1", "draining" : true, "host" : "mongo1:27018" }
> databases:
> { "_id" : "test2", "partitioned" : false, "primary" : "shard1" }
> { "_id" : "test", "partitioned" : false, "primary" : "shard1" }
> { "_id" : "admin", "partitioned" : false, "primary" : "config" }
>
> It is draining, and nothing I do will get it to stop draining.
>
> My theory is that you can't ever drain down to 0 shards. But there are
> two problems with this.
>
> 1. It would be nice to see a message indicating that. Where am I being
> informed of it?
> 2. During testing, you might like to set things up, and tear them down, and
> set them up again. But you are preventing me from doing this sort of
> testing?
>
> Thanks,
> Sam
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb

Sam Darwin

unread,
Sep 16, 2012, 10:36:55 AM9/16/12
to mongod...@googlegroups.com
Hi Scott,

Thanks for the reply.  It's version 2.0.4.

Ok.. starting from a blank slate.     There isn't really any data there to get rid of.   There is just this sharding configuration which refuses to go away.     But anyway, what would be the steps to get back to a blank slate??  Let's assume there is data, just to be thorough about it.   

Sam

Scott Hernandez

unread,
Sep 16, 2012, 10:45:33 AM9/16/12
to mongod...@googlegroups.com
You need to stop all the processes, remove the config server data, and
restart the processes. Now you can add the shards, add data and shard
collections. On a running system you cannot remove the last shard as
it contains data, and would break the whole system -- that is why you
must do this manually.

I would suggest using version 2.2.x as there are some important
improvements if you aren't planning on going though the full process
above.

Sam Darwin

unread,
Sep 16, 2012, 1:04:51 PM9/16/12
to mongod...@googlegroups.com

great Scott!!

oh, that expression has another meaning also.
Reply all
Reply to author
Forward
0 new messages