I have two PCs with IP addresses 10.1.1.52 and 10.1.1.11. I want to configure mongo replication (without sharding) with one primary and one secondary node running on 10.1.1.52 and one secondary node running on 10.1.1.11.
I have followed these steps:
Ran three config servers on 10.1.1.11 PC with the following commands::
mongod --configsvr --port 26050 --logpath /data/db/log.cfg0 --logappend --dbpath /data/db/cfg0 –fork
mongod --configsvr --port 26051 --logpath /data/db/log.cfg1 --logappend --dbpath /data/db/cfg1 –fork
mongod --configsvr --port 26052 --logpath /data/db/log.cfg2 --logappend --dbpath /data/db/cfg2 –fork
Following which I created a replica set ('a') and added three nodes to it by using the following commands (the first on 10.1.1.11 & the other two on 10.1.1.52):
mongod --replSet a --dbpath /data/a/a0 --logpath /data/a/log.a0 --port 27000 --fork --logappend --smallfiles --oplogSize 50
mongod --replSet a --dbpath /data/a/a1 --logpath /data/a/log.a1 --port 27001 --fork --logappend --smallfiles --oplogSize 50
mongod --replSet a --dbpath /data/a/a2 --logpath /data/a/log.a2 --port 27002 --fork --logappend --smallfiles --oplogSize 50
I set up query routers on 10.1.1.11 with the following command:
mongos --configdb gaugedata-elastic:26050,gaugedata-elastic:26051,gaugedata-elastic:26052 --fork --logappend --logpath /data/db/log.mongos --port 26060
After that I entered the following command to connect from mongos and initiate the replica set:
mongo --port 27000
rs.initiate()
The problem that is being faced is after adding the nodes:
rs.add("10.1.1.52:27001")
rs.add("10.1.1.52:27002")
The nodes running on remote PC i.e. 10.1.1.52 are not reachable and unhealthy. However the node running on my PC i.e. 10.1.1.11 is automatically declared as SECONDARY.