I am trying to configure a MongoDB replication at AWS with 3 instances. I have two instances right now and I can ping each other. Mongo deamon is running correctly with a same replication name.
But after initiating the primary node, I cannot add the second instance withe a error
yaodao:PRIMARY> rs.add("yaodao2:27017")
{
"ok" : 0,
"errmsg" : "Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded: yaodao1:27017; the following nodes did not respond affirmatively: yaodao2:27017 failed with Connection refused",
"code" : 74
}
Someone sais the "coeection refused" is because no mongod deamon is running at second instance, but I verify that and everything is OK.
/etc/hosts for primary instance
127.0.0.1 yaodao1
54.173.155.9 yaodao2
/etc/hosts for second instance
127.0.0.1 yaodao2
54.175.238.78 yaodao1
rs.status() for primary
yaodao:PRIMARY> rs.status()
{
"set" : "yaodao",
"date" : ISODate("2016-09-17T13:34:01.032Z"),
"myState" : 1,
"term" : NumberLong(4),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 1,
"name" : "yaodao1:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 1132,
"optime" : {
"ts" : Timestamp(1474118471, 2),
"t" : NumberLong(4)
},
"optimeDate" : ISODate("2016-09-17T13:21:11Z"),
"electionTime" : Timestamp(1474118471, 1),
"electionDate" : ISODate("2016-09-17T13:21:11Z"),
"configVersion" : 59679,
"self" : true
}
],
"ok" : 1
}