0

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?

0

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:

  • Thank you @aldwinaldwin, I have another question, if I put primary and another replica set node (for voted to be a primary, if original primary down) on ssd, other replica set nodes on HDD, Is this a better way? – zwb Aug 13 '15 at 9:32
  • If I use sharding, will there be anything wrong with this scene? – zwb Aug 13 '15 at 9:35
  • Sharding is just having multiple "replica sets". So for each shard you can do the same. About how many need to be on SSD or HDD, that's a matter of opinion/preferences/needs. But you do great in thinking well about your system and options. You might want to write some benchmarking and testing scripts to create different scenarios. Mostly I write some python test scripts that I let run and observe what happens if I bring down the primary, and when you fix your preferred state. And even if you want/need to go further, put logfiles and journal directory away from datadisk... – aldwinaldwin Aug 13 '15 at 10:13
  • Thank you @aldwinaldwin, would you please share your python test scripts to me? If possible, please tell me your code address(github?) or send to my email: zwb.ict@gmail.com. Thank you vey much! – zwb Aug 13 '15 at 10:20
  • @zwb : added the simple speed test on the Howto Benchmark and test limits link – aldwinaldwin Aug 13 '15 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.