Hi everybody!
My task for today was to configure a MongoDB with redundancy and high availability…
I decided to write my own Chef cookbook to configure “replica”.
Below are the most important parts:
Install MongoDB packages

Use a template for the main configuration file

Enable the Linux service for MongoDB at boot

What about the replica’s configuration?
I suggest using a custom LWRP that executes rs.initiate() to declare the replica set, rs.add(); to add primary and secondary servers, rs.addArb() to add arbiter servers. You can loop over hashes like this:
foobar => { “secondaries” => [“mynode01:27017″,”mynode02:27017”]}
and a Chef provider like this

I need to test my cluster, so let’s prepare a Vagrant file like this in order to manage all virtual machines concurrently.

Finally, Haproxy as reverse proxy and load balancer! Use autodiscovery (https://github.com/hw-cookbooks/haproxy) in order to automatically find the backends and “health check” to point to the right node after a new primary server’s promotion.

Ad maiora!
