mercredi 11 mars 2015

MongoDB: How to shard based on country name


I am new to MongoDb: I am creating an small use-case , where am streaming Twitter data into my mongodb.


what I want is all the tweets from usa should go to one shrad ->shrad0000


I did shrading as below:



mongos> db.runCommand({enableSharding: "twitterdb"})

mongos> db.runCommand({shardCollection: "twitterdb.tweets", key: {country: 1}})

mongos> use twitterdb

sh.addTagRange( "twitterdb.tweets", { country: "usa"}, "usa")

sh.addShardTag("shard0000", "usa");

sh.addTagRange( "twitterdb.tweets", { country: "usa", name: MinKey }, { country: "usa", name: MaxKey }, "usa")


But if I insert data into it... shard0000 has all countries data.


What Am I missing here? Can anyone help me out. Thanks in advance





Aucun commentaire:

Enregistrer un commentaire