Question

I have created two shards,and applied sharding to the collection posts whose details are as:

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)

I inserted 200000 rows of data:

mongos> db.posts.count()
201002
mongos>

db.posts.find().explain() gives the following result:

{
        "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
}

Each document inserted in the collection is of 26KB

Was it helpful?

Solution

Got the answer: It was not happening as ntp time was not synced.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top