2
votes

I have created a MongoDB Auto Sharding Cluster having 3 Shard servers (without replication), 1 Config server and 1 Mongos instance.

Here is the sh.status() output.

 mongos> sh.status()
--- Sharding Status ---
  sharding version: {
        "_id" : 1,
        "minCompatibleVersion" : 5,
        "currentVersion" : 6,
        "clusterId" : ObjectId("56ffa36ab327ae2bee8fe804")
}
  shards:
        {  "_id" : "shard0000",  "host" : "172.18.109.46:27018" }
        {  "_id" : "shard0001",  "host" : "172.18.109.60:27018" }
        {  "_id" : "shard0002",  "host" : "172.18.109.63:27018" }
  balancer:
        Currently enabled:  yes
        Currently running:  no
        Failed balancer rounds in last 5 attempts:  0
        Migration Results for the last 24 hours:
                3 : Failed with error 'aborted', from shard0000 to shard0001
                749 : Failed with error 'data transfer error', from shard0000 to shard0001
  databases:
        {  "_id" : "admin",  "partitioned" : false,  "primary" : "config" }
        {  "_id" : "NLA_M",  "partitioned" : true,  "primary" : "shard0000" }
                NLA_M.Read
                        shard key: { "Status.StatusCode" : 1 }
                        chunks:
                                shard0000       18
                        { "Status.StatusCode" : { "$minKey" : 1 } } -->> { "Status.StatusCode" : 200
 } on : shard0000 Timestamp(1, 1)
                        { "Status.StatusCode" : 200 } -->> { "Status.StatusCode" : 202 } on : shard0
000 Timestamp(1, 14)
                        { "Status.StatusCode" : 202 } -->> { "Status.StatusCode" : 300 } on : shard0
000 Timestamp(1, 15)
                        { "Status.StatusCode" : 300 } -->> { "Status.StatusCode" : 301 } on : shard0
000 Timestamp(1, 16)
                        { "Status.StatusCode" : 301 } -->> { "Status.StatusCode" : 302 } on : shard0
000 Timestamp(1, 3)
                        { "Status.StatusCode" : 302 } -->> { "Status.StatusCode" : 303 } on : shard0
000 Timestamp(1, 4)
                        { "Status.StatusCode" : 303 } -->> { "Status.StatusCode" : 400 } on : shard0
000 Timestamp(1, 5)
                        { "Status.StatusCode" : 400 } -->> { "Status.StatusCode" : 401 } on : shard0
000 Timestamp(1, 17)
                        { "Status.StatusCode" : 401 } -->> { "Status.StatusCode" : 403 } on : shard0
000 Timestamp(1, 18)
                        { "Status.StatusCode" : 403 } -->> { "Status.StatusCode" : 404 } on : shard0
000 Timestamp(1, 19)
                        { "Status.StatusCode" : 404 } -->> { "Status.StatusCode" : 406 } on : shard0
000 Timestamp(1, 7)
                        { "Status.StatusCode" : 406 } -->> { "Status.StatusCode" : 498 } on : shard0
000 Timestamp(1, 8)
                        { "Status.StatusCode" : 498 } -->> { "Status.StatusCode" : 500 } on : shard0
000 Timestamp(1, 9)
                        { "Status.StatusCode" : 500 } -->> { "Status.StatusCode" : 501 } on : shard0
000 Timestamp(1, 11)
                        { "Status.StatusCode" : 501 } -->> { "Status.StatusCode" : 503 } on : shard0
000 Timestamp(1, 20)
                        { "Status.StatusCode" : 503 } -->> { "Status.StatusCode" : 504 } on : shard0
000 Timestamp(1, 21)
                        { "Status.StatusCode" : 504 } -->> { "Status.StatusCode" : 524 } on : shard0
000 Timestamp(1, 22)
                        { "Status.StatusCode" : 524 } -->> { "Status.StatusCode" : { "$maxKey" : 1 }
 } on : shard0000 Timestamp(1, 13)
                NLA_M.ReadTime
                        shard key: { "TimeElapsed" : 1 }
                        chunks:
                                shard0000       194
                        too many chunks to print, use verbose if you want to force print
        {  "_id" : "test",  "partitioned" : false,  "primary" : "shard0001" }

mongos>

Though here number of chunks are large, all data is getting stored in one shard only. Balancer state is "Active" but it is not running all the time. Once it just ran for 5-10 seconds only. It shows below error,

Failed balancer rounds in last 5 attempts:  0
Migration Results for the last 24 hours:
        3 : Failed with error 'aborted', from shard0000 to shard0001
        749 : Failed with error 'data transfer error', from shard0000 to shard0001

Can anyone please help me to solve it out? I am new in MongoDB and want to learn and test MongoDB scalability by creating sharded cluster.

Here are some more information if it helps to solve it out:

While creating the cluster I followed below steps.

  1. Install MongoDB in all machines.
  2. Give ownership with all permission to "/data/db/" folder for shard servers and "/data/configdb/" folder for config server.
  3. Start Config server. [mongod --configsvr]
    (here, config server ip: 172.18.109.81:27019)
  4. Start Mongos. [mongos --configdb 172.18.109.81:27019 --port 27020]
    (here, mongos server ip: 172.18.109.250:27020)
  5. Start all Shard servers. [mongod --shardsvr]
    Note: Shard servers => 172.18.109.46:27018 (shard0000) , 172.18.109.60:27018 (shard0001), 172.18.109.63:27018 (shard0002)
  6. In Mongos machine, open another terminal and run mongo 172.18.109.250:27020/admin
  7. Add all shards [sh.addShard("172.18.109.46:27018")...]
  8. Enable Sharding for Database, define Shard collection with shardKey

I have tried the same with different shard key also (as I thought, choosing the shard key is the problem) but it also results same. "NLA_M.Read" has a shard key whose values are ranged between 100 & 600. Also I have tried by selecting hashed shard key, but no change.

Please let me know if I'm missing anything.

Thanks :)

1

1 Answers

1
votes

Previously all PCs had different versions of MongoDB, like,

Mongos server - 3.0.11
Config server - 3.2.4
Shard server 0 - 3.2.4
Shard server 1 - 2.6.12
Shard server 2 - 2.6.12

I thought different versions of MongoDB might be the problem, hence I have reinstalled MongoDB in all PCs with 3.2.4 version.

And now it's working fine.

Thanking you. :)