I have 3 mongo nodes running in one region which are mapped to the same replica set with 1 primary and others secondary. I have created another standalone mongo in another region. Now I want to add the newly created node as a secondary to the same existing replica set. For that I have executed the rs.add() command in the primary. This will shows the newly added one in rs.config(), But this is showing in not reachable state when rs.status() command executed.
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"lastHeartbeatMessage" : "Connection refused",
"configVersion" : -1
I can connect to the newly created mongo from primary node in existing replica set and on other side, I can connect to the primary node from the newly created mongo machine as well.
This is resolved.
check the replication and security options in /etc/mongod.conf
of primary node, and update the same to newly created node in the other region.
If we have a keyFile present in the existing region create keyFile with the same key in new region as well.
Make sure mongod has read and write access to that file. (sudo chown mongod:mongod /var/lib/mongo/keyFile)
Restart mongod in new region.
Add this as secondary node if not already added.
This worked for me.