This file contains 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
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, |
This file contains 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
mongos> sh.addShardTag('shard0000', 'recent') | |
mongos> sh.addShardTag('shard0001', 'tier 2') | |
mongos> sh.addShardTag('shard0002', 'tier 2') |
This file contains 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
mongorestore ~/courses/m101p/enron/dump/enron/messages.bson |
This file contains 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
mongos> sh.status() | |
--- Sharding Status --- | |
sharding version: { | |
"_id" : 1, | |
"version" : 3, | |
"minCompatibleVersion" : 3, | |
"currentVersion" : 4, | |
"clusterId" : ObjectId("5314f1487abd6cb2803696d6") | |
} | |
shards: |
This file contains 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
mongos> show dbs | |
admin (empty) | |
config 0.046875GB | |
enron 1.953125GB |
This file contains 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
mongos> use enron | |
switched to db enron | |
mongos> show tables | |
messages | |
system.indexes |
This file contains 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
sh.enableSharding('enron') | |
// { "ok" : 1 } |
This file contains 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
var cursor = db.messages.find({},{_id:1, 'headers.Date':1}) | |
while(cursor.hasNext()){ | |
var doc = cursor.next(); | |
var id = doc._id; | |
var dt = doc.headers.Date; | |
db.messages.update({_id:id},{$set:{date:dt},$unset:{'headers.Date':1}}) | |
} | |
This file contains 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
sh.splitAt('enron.messages', {"date" : ISODate("2001-08-01")}) |
This file contains 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
mongos> sh.status() | |
--- Sharding Status --- | |
sharding version: { | |
"_id" : 1, | |
"version" : 3, | |
"minCompatibleVersion" : 3, | |
"currentVersion" : 4, | |
"clusterId" : ObjectId("5314f1487abd6cb2803696d6") | |
} | |
shards: |
OlderNewer