Last active
December 30, 2015 23:29
-
-
Save FrancescaK/7901452 to your computer and use it in GitHub Desktop.
Adding Shards and a shard key to the archive and recent clusters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#add two shards | |
sh.addShardTag ("shard0000", "archive") | |
sh.addShardTag ("shard0001", "recent") | |
#shard database and collection, use "_id" as shard key | |
sh.enableSharding("mydb") | |
sh.shardCollection("mydb.mydata", { "_id" : 1 }) | |
#define tag ranges | |
#first tag range: from the beginning of time until 1 Jan 2013, everything goes to "archive" | |
sh.addTagRange("mydb.mydata", { "_id" : MinKey }, { "_id" : 201301010000032543 }, "archive") | |
#second tag range: from 1 Jan 2013 until the end of time (now), everything goes to "recent" | |
sh.addTagRange("mydb.mydata", { "_id" : 201208140000000000 }, { "_id" : MaxKey }, "recent") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment