-
Type:
New Feature
-
Resolution: Done
-
Priority:
Minor - P4
-
None
-
Affects Version/s: 3.2.4
-
Component/s: Replication
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have a 2 nodes mongodb replica set in a cloud platform. The two nodes have their own intranet & internet address as follows:
Primary node: intranet 172.17.255.4 internet 39.128.114.219
Secondary node: intranet 172.17.255.6 internet 123.99.24.163
The mongod's listen port 14821 can be telnet in internet.
Then I add two dns records:
172.17.255.4 db2018-3.acmcoder.com
172.17.255.6 db2018-4.acmcoder.com
Now, I use nodejs to connect this replica set.
When the nodejs app using conn string
'mongodb://****:****@172.17.255.4:14821,172.17.255.6:14821/discuss?replicaSet=acmcoder&readPreference=secondary'
is deploy in the same intranet network with mongo server, it can work. But when I start the nodejs app using conn string
'mongodb://****:****@39.128.114.219:14821,123.99.24.163:14821/discuss?replicaSet=acmcoder&readPreference=secondary'
in my office with internet, it cant't work. Because the driver said the secondary address is db2018-4.acmcoder.com. How to fix this problem.
I have a temp way to add a record to the local hosts file in my computer.
123.99.24.163 db2018-4.acmcoder.com
But I think this is the correct way to resolve this problem.
The rs status is:
acmcoder:PRIMARY> rs.status()
{
"set" : "acmcoder",
"date" : ISODate("2018-03-22T01:49:17.235Z"),
"myState" : 1,
"term" : NumberLong(82),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 42,
"name" : "db2018-3.acmcoder.com:14821",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 209805,
"optime" : {
"ts" : Timestamp(1521683357, 8),
"t" : NumberLong(82)
},
"optimeDate" : ISODate("2018-03-22T01:49:17Z"),
"electionTime" : Timestamp(1521474805, 1),
"electionDate" : ISODate("2018-03-19T15:53:25Z"),
"configVersion" : 117,
"self" : true
},
{
"_id" : 43,
"name" : "db2018-4.acmcoder.com:14821",
"health" : 1,
"state" : 2,
"stateStr" : "SECONDARY",
"uptime" : 207736,
"optime" : {
"ts" : Timestamp(1521683355, 18),
"t" : NumberLong(82)
},
"optimeDate" : ISODate("2018-03-22T01:49:15Z"),
"lastHeartbeat" : ISODate("2018-03-22T01:49:15.476Z"),
"lastHeartbeatRecv" : ISODate("2018-03-22T01:49:16.562Z"),
"pingMs" : NumberLong(0),
"syncingTo" : "db2018-3.acmcoder.com:14821",
"configVersion" : 117
}
],
"ok" : 1
}
- duplicates
-
SERVER-1889 Support different networks / nics for client & replication traffic
-
- Closed
-