Not able to use secondary for read using Readpreference=secondary and nearest.

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hi,

      We are using mongodb with some node.js application and need to figure output to push the read connections to secondary/nearest secondary.

      We tried couple of options with mongodb url
      1) With replica set as below
      mongodb://renewmedb_rw:renewmedb_rw123@renewmedbprd003las.io.askjeeves.info:27017/renewmedb?replicaSet=rs1&w=5&ReadPreference=NEAREST"

      2)mongodb://renewmedb_rw:renewmedb_rw123@renewmedbprd001iad.io.askjeeves.info,renewmedbprd002iad.io.askjeeves.info,renewmedbprd003iad.io.askjeeves.info,renewmedbprd001las.io.askjeeves.info.renewmedbprd002las.io.askjeeves.info,renewmedbprd003las.io.askjeeves.info:27017/renewmedb?replicaSet=rs1&readPreference=secondary"

      3) "mongodb://renewmedb_rw:renewmedb_rw123@renewmedbprd001iad.io.askjeeves.info,renewmedbprd002iad.io.askjeeves.info,renewmedbprd003iad.io.askjeeves.info,renewmedbprd001las.io.askjeeves.info.renewmedbprd002las.io.askjeeves.info,renewmedbprd003las.io.askjeeves.info:27017/renewmedb?readPreference=secondary&slaveOk=true"

      All the connection goes to primary in case of replicaset and without replicates also it goes to primary alongwith all secondary because those are the part of URL.

      Can someone help us to provide some details so we can push all reads just to secondaries?

      Thanks,
      Amit

            Assignee:
            Unassigned
            Reporter:
            Amit Agarwal
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: