Migration of chunks not taking place in sharding I am trying sharding in MongoDB. I am working with


1 config server 
1 Query router 
2 shards


I tried hash based sharding. The data is getting partitioned but sharding is not successful. In one shard some documents are present but in another shard the number of documents is zero. In logging I could see the warning:


  warning: moveChunkCmd deleted data already in chunk


I can get a point that the data is lost while the chunk is migrating from one shard to another shard. But I am not sure how to avoid the data lost while the chunk is migrating.
The data is not being lost - that message means that when the migration was attempted from the source shard to the target, there was already data present that matched the chunk range, which was then deleted (this is what is supposed to happen, which is why that is not an error, but a warning).  Since you are starting from scratch, it implies that you have data present in that collection, in that range before any migrations are attempted.  

This condition can happen occasionally on sharded clusters that have been running for a while (and chunks move around), hence the warning rather than an error.  However in this case it suggests that this was not a clean database on at least one shard when you began.  There are either some steps missing from this description, or possibly you failed to clean up properly after a previous attempt.

In any case, I would suggest posting the full procedure that brought this about - I have tested hashed sharding with 2 shards, 1 config server and 1 mongos many, many times (occasionally live in front of others as part of a demo) and never caused this to happen with normal operations.