我创建了两个分片,并将分片应用于收集帖子,其详细信息如下:
sh.status()
--- Sharding Status ---
sharding version: {
"_id" : 1,
"version" : 3,
"minCompatibleVersion" : 3,
"currentVersion" : 4,
"clusterId" : ObjectId("50fde9a8552b8ce5c47c8ead")
}
shards:
{ "_id" : "rs0", "host" : "rs0/serv1:27017,serv2:27017,serv3:27017" }
{ "_id" : "rs1", "host" : "rs1/serv4:27017,serv5:27017,serv6:27017" }
databases:
{ "_id" : "admin", "partitioned" : false, "primary" : "config" }
{ "_id" : "myposts", "partitioned" : true, "primary" : "rs0" }
myposts.posts
shard key: { "_id" : "hashed" }
chunks:
rs0 2
{ "_id" : { "$minKey" : 1 } } -->> { "_id" : NumberLong(0) } on : rs0 Timestamp(1, 0)
{ "_id" : NumberLong(0) } -->> { "_id" : { "$maxKey" : 1 } } on : rs0 Timestamp(1, 1)
我插入了 200000 行数据:
mongos> db.posts.count()
201002
mongos>
db.posts.find().explain() 给出以下结果:
{
"clusteredType" : "ParallelSort",
"shards" : {
"rs0/serv1:27017,serv2:27017,serv3:27017" : [
{
"cursor" : "BasicCursor",
"isMultiKey" : false,
"n" : 201002,
"nscannedObjects" : 201002,
"nscanned" : 201002,
"nscannedObjectsAllPlans" : 201002,
"nscannedAllPlans" : 201002,
"scanAndOrder" : false,
"indexOnly" : false,
"nYields" : 1,
"nChunkSkips" : 0,
"millis" : 587,
"indexBounds" : {
},
"server" : "serv1:26016"
}
]
},
"cursor" : "BasicCursor",
"n" : 201002,
"nChunkSkips" : 0,
"nYields" : 1,
"nscanned" : 201002,
"nscannedAllPlans" : 201002,
"nscannedObjects" : 201002,
"nscannedObjectsAllPlans" : 201002,
"millisShardTotal" : 587,
"millisShardAvg" : 587,
"numQueries" : 1,
"numShards" : 1,
"indexBounds" : {
},
"millis" : 589
}
集合中插入的每个文档大小为 26KB