I can't seem to connect pymongo to a replica set I've created. The message I'm getting doesn't seem to make much sense as it's not what I'm seeing.
I'll first explain my configuration.
Basically I have three machines 10.141.0.156, 10.141.0.158, 10.141.0.159
I have 3 mongod instances, each running on a different machine, each running with:
mongod --configsvr --dbpath /mnt/sdb/ --port 27019
Next I've added the 3 mongod machines to a replica set:
{
"set" : "replSet",
"date" : ISODate("2016-04-01T12:23:12.552Z"),
"myState" : 2,
"term" : NumberLong(2),
"syncingTo" : "10.141.0.158:27017",
"configsvr" : true,
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 0,
"name" : "10.141.0.156:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 2751,
"optime" : {
"ts" : Timestamp(1459513383, 6),
"t" : NumberLong(2)
},
"optimeDate" : ISODate("2016-04-01T12:23:03Z"),
"syncingTo" : "10.141.0.158:27017",
"configVersion" : 2,
"self" : true
},
{
"_id" : 1,
"name" : "10.141.0.158:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 2749,
"optime" : {
"ts" : Timestamp(1459513383, 6),
"t" : NumberLong(2)
},
"optimeDate" : ISODate("2016-04-01T12:23:03Z"),
"lastHeartbeat" : ISODate("2016-04-01T12:23:11.054Z"),
"lastHeartbeatRecv" : ISODate("2016-04-01T12:23:11.579Z"),
"pingMs" : NumberLong(0),
"electionTime" : Timestamp(1459510633, 1),
"electionDate" : ISODate("2016-04-01T11:37:13Z"),
"configVersion" : 2
},
{
"_id" : 2,
"name" : "10.141.0.159:27017",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 2749,
"optime" : {
"ts" : Timestamp(1459513383, 6),
"t" : NumberLong(2)
},
"optimeDate" : ISODate("2016-04-01T12:23:03Z"),
"lastHeartbeat" : ISODate("2016-04-01T12:23:11.261Z"),
"lastHeartbeatRecv" : ISODate("2016-04-01T12:23:12.240Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "10.141.0.158:27017",
"configVersion" : 2
}
],
"ok" : 1
}
Next I've started the mongos on the first machine 10.141.0.156:
mongos --configdb replSet/10.141.0.156:27017,10.141.0.158:27017,10.141.0.159:27017 --port 27077
At this point everything is running normally and I'm not getting any errors.
Then I try to connect to the replica set with pymongo 3.2.1:
MongoClient("10.141.0.156", 27077, replicaSet='replSet')
When I try either to read all the keys, or to write, I get:
*** ServerSelectionTimeoutError: No replica set members available for replica set name "replSet"
Despite seeing the replica set in the mongo shell.