Tag-aware Sharding commands
use dbversity
db.nosql.ensureIndex({“mongodb” : 1})
db.rbdms.ensureIndex({“oracle” : 1})
db.newsql.ensureIndex({“memsql” : 1})
sh.enableSharding(“dbversity”)
use admin
db.runCommand({shardCollection: “dbversity.nosql”, key : {“mongodb”:1}})
db.runCommand({shardCollection: “dbversity.rbdms”, key : {“oracle”:1}})
db.runCommand({shardCollection: “dbversity.newsql”, key : {“memsql”:1}})
sh.startBalancer()
sh.isBalancerRunning()
sh.getBalancerState()
for (var i=0; i<100000; i++) { db["nosql"].insert({mongodb: Math.random(), count: i, time: new Date()}); } for (var i=0; i<100000; i++) { db["rdbms"].insert({oracle: Math.random(), count: i, time: new Date()}); } for (var i=0; i<100000; i++) { db["newsql"].insert({memsql: Math.random(), count: i, time: new Date()}); } db.chunks.find({ns: "dbversity.nosql"}, {shard:1, _id:0}).sort({shard:1}) db.chunks.find({ns: "dbversity.rdbms"}, {shard:1, _id:0}).sort({shard:1}) db.chunks.find({ns: "dbversity.newsql"}, {shard:1, _id:0}).sort({shard:1}) sh.addShardTag("rs1", "MON") sh.addShardTag("rs2", "ORA") sh.addShardTag("rs3", "NEW") db.shards.find()