MongoDB – Split Read and Write with Primary on HDD and Replica Sets on SSD

mongodbreplication

I have three machines, each machine both has SSH and HDD, I want to save SSD space, and in my env: less write, lots read. So does mongoDB support splitting read and write, with primary on HDD, replica sets on SSD. If so, how do I go about doing this?

Best Answer

You can send rs.stepDown(300) to the replicas on the SSD disks that you want as Secondary. Then they won't get chosen for the next 5 minutes. The replica on the HDD should be Primary when all the others step down.

Also make sure that you can read from your secondaries with rs.slaveOK().

In case that your primary has problems, one of your secondaries will take over. (Unless if you really don't want that, you can use {priority:0} in the member options.) Be aware that your script with these tasks, should only execute when your 'previous primary' is synced correctly again, before you return to your preferred environment. This could be automated as a cronjob or sometimes better manually if you need to figure out what happened with the Primary.

To optimize read/write: