I have been successfully running a 3-member replicaset on 3 separate VMs in 2 locations.
My mongo_uri was of the form: mongoldb://username:password@member0.host.com:27017,member1.host.com:27017,member2.host.com:27017/?replicaSet=rs_name
This has worked perfectly for 8+ months.
On Tuesday however the host where 2 VMs are running, had a data center issue. As a result (I can’t really deduce the order of things), my primary became a secondary and was unable to elect itself to primary again.
As the situation at the data center lasted beyond reasonable times, I decided to restart my primary member as a standalone node.
Basically, going from:
mongo:
image: mongo:latest
container_name: mongo_mini
restart: always
command: --replSet rs2 --keyFile /kk/keyFile
to:
mongo:
image: mongo:latest
container_name: mongo_mini
restart: always
#command: --replSet rs2 --keyFile /kk/keyFile
This resulted in this member starting up again and my services being able to access the db again (after telling them to look for the standalone host).
My question:
The data center is up and running again, 1 VM had to be re-created and the other still has the replication data.
My hope is that I can revert the change for my current standalone host and restart again with the --replSet command enabled, but would that work?
The new VM will start in STARTUP2 mode syncing and hopefully the surviving VM will pick up replication where it stopped 2 days ago?
Happy to hear your thoughts.