shard cluster shows data only on 1 node

45 views
Skip to first unread message

Anmol

unread,
May 15, 2018, 5:07:00 AM5/15/18
to mongodb-user
I have defined 2 shards ShardA and ShardB
Shard A  has data for ag.table1 from x=1 to 99 and Shard B from x=100 to x=199. however, when i see data distribution, it shows that all of data resides on Shard A Why so??

mongos> db.table1.getShardDistribution()

 data : 8KiB docs : 200 chunks : 3
 estimated data per chunk : 2KiB
 estimated docs per chunk : 66

 data : 0B docs : 0 chunks : 1
 estimated data per chunk : 0B
 estimated docs per chunk : 0

Totals
 data : 8KiB docs : 200 chunks : 4
 Shard shard_Repl_SetA contains 100% data, 100% docs in cluster, avg obj size on shard : 46B
 Shard shard_Repl_SetB contains 0% data, 0% docs in cluster, avg obj size on shard : NaNGiB
================
Configuration-->>>


 sharding version: {
        "_id" : 1,
        "minCompatibleVersion" : 5,
        "currentVersion" : 6,
        "clusterId" : ObjectId("5aeff2b0da17efd745775bf8")
  }
  shards:
        {  "_id" : "shard_Repl_SetA",  "host" : "shard_Repl_SetA/xtlinno1vmongo02.xavient.com:34001,xtlinno1vmongo03.xavient.com:34001,xtlinno1vmongo04.xavient.com:34001",  "state" : 1,  "tags" : [ "ShardA" ] }
        {  "_id" : "shard_Repl_SetB",  "host" : "shard_Repl_SetB/xtlinno1vmongo01.xavient.com:33001,xtlinno1vmongo05.xavient.com:33001",  "state" : 1,  "tags" : [ "ShardB" ] }
  active mongoses:
        "3.6.4" : 2
  autosplit:
        Currently enabled: yes
  balancer:
        Currently enabled:  yes
        Currently running:  no
        Failed balancer rounds in last 5 attempts:  3
        Last reported error:  Could not find host matching read preference { mode: "primary" } for set shard_Repl_SetB
        Time of Reported error:  Tue May 15 2018 11:48:53 GMT+0530 (IST)
        Migration Results for the last 24 hours:
                6 : Success

    {  "_id" : "ag",  "primary" : "shard_Repl_SetA",  "partitioned" : true }
                ag.table1
                        shard key: { "x" : 1 }
                        unique: false
                        balancing: true
                        chunks:
                                shard_Repl_SetA 3
                                shard_Repl_SetB 1
                        { "x" : { "$minKey" : 1 } } -->> { "x" : "1" } on : shard_Repl_SetA Timestamp(2, 1)
                        { "x" : "1" } -->> { "x" : "100" } on : shard_Repl_SetA Timestamp(1, 2)
                        { "x" : "100" } -->> { "x" : "200" } on : shard_Repl_SetB Timestamp(2, 0)
                        { "x" : "200" } -->> { "x" : { "$maxKey" : 1 } } on : shard_Repl_SetA Timestamp(1, 5)
                         tag: ShardA  { "x" : "1" } -->> { "x" : "100" }
                         tag: ShardB  { "x" : "100" } -->> { "x" : "200" }

Kevin Adistambha

unread,
May 30, 2018, 9:09:35 PM5/30/18
to mongodb-user

Hi

I believe this is the main issue you’re having:

Last reported error: Could not find host matching read preference { mode: “primary” } for set shard_Repl_SetB

It appears that the Shard B replica set does not have a primary. This means that no data can be written to the replica set. In other words, MongoDB tried to balance the cluster, but cannot since Shard B does not accept writes.

One very likely cause if because the Shard B replica set appears to contain only 2 members. This is not a recommended configuration for a replica set, since a replica set depends on its ability to elect a primary member that can accept writes by simple majority. In a 2-member replica set, if one of them is offline, the remaining node will become a secondary to prevent “split-brain” scenario. Thus the minimum of 3 members is the recommended configuration for a replica set. This is described in detail in the Replication page.

To enable the cluster to balance itself, Shard B must be writable (e.g. the replica set having a primary). The best way to solve this is to add another data-bearing member to Shard B replica set.

Best regards
Kevin

Reply all
Reply to author
Forward
0 new messages