I am using mongodb with two servers physically located in respectively Italy and France.
The France server runs Ubuntu server is the Primary of the replica set, and works fine, i.e it accepts connections from mongo shell whether locally or remotely and is continuously updated by a python client.
The second server in Italy works fine standalone with CentOS, but get stuck to STARTUP status when starting as part of the replica set. The log indicates that it received the configuration from the primary.
I tried a several things to fix the issue but none of them works:
- Try to use keyfile (or not) between members of the replica set.
- Check the Firewall is open on both sides with nmap
- Add iptables rules to assert the mongodb port accept in/out traffic.
- Check mongod is up and listening on all IP on both sides.
- Configure (or not) the same admin user on secondary before restarting with --replSet. This step can only be done when secondary is standalone, since started as member of the replica set, it is stuck in transient state and thus it does not accept user creation. Hence it follows that login to the secondary fails.
Also both members (France:primary and Italy:secondary) are started with --auth, --replSet rs0, --keyFile.
I researched the issue on the web before, and found the closest answer here: MonogoDB Replica Set Status Not changing from Startup to Secondary
But the author mention that the secondary did not received the configuration which makes the issue different than this one.
Thanks for your help.