1

I have edited the question. I was trying to run the sh.splitAt

mongos> sh.splitAt("test.zp",{"city": "1"})it worked.

But the problem is at sharding chunks.

when i have run the command sh.status(). It shows like this

databases:
{  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
{  "_id" : "test",  "partitioned" : true,  "primary" : "shard0000" }
test.zp
shard key: { "city" : 1 }
chunks:shard0000  34
too many chunks to print, use verbose if you want to force print.

i have three more shards but with different ip's.why sharding is not applied to the secondary shards. I have shards like

    {  "_id" : "shard0000", }  
{  "_id" : "shard0001", } 
{  "_id" : "shard0002", }  
{  "_id" : "shard0003", }

How chunks will be added to "shard0001" and remaining shards.I have added all shards to the test db. and my data is 1.2GB.

2

You need to enable sharding on the database test first:

sh.enableSharding("test");

Then you need to shard the collection and pick a shard key. Based on what you were trying to split on, that would be:

sh.shardCollection("test.zp", {"city" : 1});

A couple of notes:

  1. "city" is probably a poor shard key unless you are expecting an even distribution of records per city and you are going to have a lot of them. Take a look at the docs on picking a key
  2. If you have data in the collection already, you will need to create an index on the "city" field before you can use it as a shard key. If the collection is empty, MongoDB will do it for you automatically when you use it as a shard key.

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.