Setting up a Replicate Set on different networks

How can you setup a Replicate Set where the members are in different networks? Since the rs.add(HOST_NAME:PORT NUMBER) command to add members will not work since the HOST NAME cannot be recognized because the network is not private but a public one.

If the members are reachable, and they must be, despite being in different network, you may add them to your replica set.

But the question is how do you reach them, right now, if HOST_NAME is not recognized?

If you do it with IP address, then use the IP address in your rs.add().

How come HOST_NAME is not recognized if the network is public?

Note that your private network hosting one or more members also needs to be reachable from the public network that is hosting the other members.

The rule is simple:

All members of a replica set must be reachable from all members of the replica set and from all clients using the same host names/IP.

1 Like

Thank you got it, so I can just use the public IP address to identify and add a member in another network with the rs.add() command. May I also ask another question, for the command:

mongod --port “PORT” --dbpath “YOUR_DB_DATA_PATH” --replSet “REPLICA_SET_INSTANCE_NAME”

The dbpath is where all of the DBs are stored right, so if I am setting up the primary node for example it would write and read the data to the specified DBs from the dbpath and then would forward the data to the Secondary nodes for replication. In the Secondary nodes, the replicated data forwarded from the Primary node will be stored in the dbpath as well a reading of the dataset will be made from it by the client application.


A must to take is


Thanks for the recommendations.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.