Skip to content

Instantly share code, notes, and snippets.

@FrancescaK
Last active August 29, 2015 13:57
Show Gist options
  • Save FrancescaK/9371048 to your computer and use it in GitHub Desktop.
Save FrancescaK/9371048 to your computer and use it in GitHub Desktop.
STEP connect, add tags, insert data, verify sharding status, set up shards,
MongoDB shell version: 2.4.6
connecting to: 127.0.0.1:30004/test
//
mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 3,
"minCompatibleVersion" : 3,
"currentVersion" : 4,
"clusterId" : ObjectId("5314f1487abd6cb2803696d6")
}
shards:
{ "_id" : "shard0000", "host" : "Rohit-MacBook-Pro.local:30000" }
{ "_id" : "shard0001", "host" : "Rohit-MacBook-Pro.local:30001" }
{ "_id" : "shard0002", "host" : "Rohit-MacBook-Pro.local:30002" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
//Adding tags
mongos> sh.addShardTag('shard0000', 'current')
mongos> sh.addShardTag('shard0001', 'archive')
mongos> sh.addShardTag('shard0002', 'archive')
//Add in Enron Data
mongorestore ~/courses/m101p/enron/dump/enron/messages.bson
//Verifying sharding status
mongos> sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 3,
"minCompatibleVersion" : 3,
"currentVersion" : 4,
"clusterId" : ObjectId("5314f1487abd6cb2803696d6")
}
shards:
{ "_id" : "shard0000", "host" : "Rohit-MacBook-Pro.local:30000", "tags" : [ "current" ] }
{ "_id" : "shard0001", "host" : "Rohit-MacBook-Pro.local:30001", "tags" : [ "archive" ] }
{ "_id" : "shard0002", "host" : "Rohit-MacBook-Pro.local:30002", "tags" : [ "archive" ] }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "test", "partitioned" : false, "primary" : "shard0000" }
{ "_id" : "enron", "partitioned" : false, "primary" : "shard0000" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment