Can't connect to secondary members in a replica Set

1.4k views Asked by At

I've created a mongodb replica set with 3 members. They are synchronized, but if I try to connect to secondary members via Robomongo and via webapp it does not work. I get the error for the slaveOK is set to false, but I've just set rs.slaveOk() to each member of the replica set.

If I connect via shell I do not get the error and I can list everything. If a secondary member becomes primary I can read from it also via Robomongo.

MongoDB shell version: 2.6.10

here is the rs.status()

rs:PRIMARY> rs.status()
{
    "set" : "gmrrs",
    "date" : ISODate("2015-06-25T16:14:53Z"),
    "myState" : 1,
    "members" : [
        {
            "_id" : 0,
            "name" : "****",
            "health" : 1,
            "state" : 1,
            "stateStr" : "PRIMARY",
            "uptime" : 2014,
            "optime" : Timestamp(1435246594, 1208),
            "optimeDate" : ISODate("2015-06-25T15:36:34Z"),
            "electionTime" : Timestamp(1435248124, 1),
            "electionDate" : ISODate("2015-06-25T16:02:04Z"),
            "self" : true
        },
        {
            "_id" : 1,
            "name" : "***:27019",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 774,
            "optime" : Timestamp(1435246594, 1208),
            "optimeDate" : ISODate("2015-06-25T15:36:34Z"),
            "lastHeartbeat" : ISODate("2015-06-25T16:14:52Z"),
            "lastHeartbeatRecv" : ISODate("2015-06-25T16:14:52Z"),
            "pingMs" : 0,
            "syncingTo" : "****:27018"
        },
        {
            "_id" : 2,
            "name" : "****:27020",
            "health" : 1,
            "state" : 2,
            "stateStr" : "SECONDARY",
            "uptime" : 759,
            "optime" : Timestamp(1435246594, 1208),
            "optimeDate" : ISODate("2015-06-25T15:36:34Z"),
            "lastHeartbeat" : ISODate("2015-06-25T16:14:51Z"),
            "lastHeartbeatRecv" : ISODate("2015-06-25T16:14:51Z"),
            "pingMs" : 1,
            "syncingTo" : "***:27018"
        }
    ],
    "ok" : 1
}

and here the rs.conf()

 rs:PRIMARY> rs.conf()
{
    "_id" : "rs",
    "version" : 3,
    "members" : [
        {
            "_id" : 0,
            "host" : "***:27018"
        },
        {
            "_id" : 1,
            "host" : "***:27019"
        },
        {
            "_id" : 2,
            "host" : "***:27020"
        }
    ]
}

I would like to write on just one server and read to all of them.

Can anyone help?

Thanks, Nicola

1

There are 1 answers

1
vhuynh On

Robomongo currently can't query secondary instances in a replica set: https://github.com/paralect/robomongo/issues/116