OK, mongoDB isn’t So Bad…

MongoDB

This morning I was working on some code and it was getting a little frustrating working with the mongoDB replica sets - after all, they are meant to be able to switch the PRIMARY as will. Fair enough, but that makes it hard if you have to target the primary in your mongo command-line shell:

  $ mongo --host xchi43mongo:32018

where we might have a replica set of xchi43mongo and xchi44mongo. Seems they should make the third box in the set be the one to talk to - but I don't write it, so I have to try one and then another if I'm wrong. Kinda frustrating.

So this morning I decided to figure this out, and sure enough, mongoDB allows for referencing it's replica sets:

  $ mongo --host dapool/xchi43mongo:32018,xchi44mongo:32018

and it picks up the name of the replica set from your command as well as the machines in the set. Nice. I can see this - it's an alias now, and I can pretty easily deal with this.

Not bad, mongoDB.