Sample Header Ad - 728x90

How to load balance mongodb replica cluster

1 vote
2 answers
4220 views
I have created a mongod replica cluster of 2 nodes , mongo1 and mongo2. to load balance I have added following rule in my haproxy listen mongo_replica_cluster bind *:27017 mode tcp balance roundrobin server mongo1 10.2.0.12:27017 check inter 10s fall 3 rise 99999999 server mongo2 10.2.0.11:27017 check backup but if the mongo1 goes down mongo2 becomes the primary but even if mongo1 comes up mongo2 remains primary but ha redirect all traffic to mongo1 which is slave now. I want to redirect all my traffic to only the primary node.
Asked by user128113 (11 rep)
Jul 6, 2017, 08:12 AM
Last activity: Jun 7, 2023, 06:00 PM