Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting up mongodb via AWS opsworks

I am trying to setup a rails stack on AWS Opsworks and i want to use mongodb as the database.

I think that you set this up by creating a new custom layer and adding your chef reciepts to the relevant life cycle hooks but i am unsure as to what receipts to put where.

Can anyone help with how to add mongodb via a chef to AWS Opsworks?

I have seen there is a community mongodb cookbook but from what i can see its not compatible with Opsworks.

Does anyone have any experience of setting this up ?

Please can anyone help with this.

thanks a lot Rick

like image 263
Rick Moss Avatar asked Sep 05 '13 13:09

Rick Moss


1 Answers

I tried setting up a MongoDB 3-node replica set in OpsWorks a few months back. I will share a bit of my experience:

1) How to install a single MongoDB: It is possible and easy to install a single mongodb using the EDelight Chef MongoDB Cookbook. Just add it as a submodule in your custom opsworks chef repository.

To get it to work create a custom layer and call it MongoDB and excecute the following recipes

  • SETUP: mongodb:10gen_repo
  • CONFIGURE: mongodb:default

This will install the latest version of MongoDB.

NOTE: I used Ubuntu instances.

2) MongoDB Best Practices If you talk to MongoDB engineers or customer service reps, they will all tell you that the recommended setup for MongoDB is a 3 node replica set. This means one master and two read replicas hopefully in different availability zones. Also an ideal setup will have lots of RAM, to give you an example: the smallest instance provided by MongoDB that you can find in the AWS market place is a standard large:

MongoDB instance on AWS marketplace

You also have to consider using EBS on RAID10, maybe reserved IOPS...

See the white paper MongoDB on AWS for more info.

3) Security Considerations Ideally you want only application instances to access the DB instances. In AWS you could create a security group with custom rules and assign EC2 instances to the group you just created... Is not quite like this when it comes to OpsWorks as it forces you to have default security groups that have very lax restrictions. AWS will always adopt lax permissions over stricter ones.

4) Time and Money Considerations If the recommended setup is a 3 node replica set using large instances you are looking at at least $600 (on demand) for the DB and this doesn't add reserved IOPS, EBS, and so on. Automating this setup is possible yet not simple. It will take time or an expert in the subject to get you going. If you have the resources and personnel to deal with this go for it. If you are part of a small development team that want's to code more and do less operations, read on.

5) Find a reliable Managed Solution At first I was reluctant to the idea of using a third party company that offered MongoDB as a service. After much evaluation of the different options (Managed, AWS Marketplace, OpsWorks, Direct EC2 installation), I concluded that for our small team the best thing to do was to use either MongoLab or MongoHQ. They host and mange MongoDB instances of all sizes and prices. They even let you choose the hosting (AWS, Rackspace, etc), region and AZ. Price wise will be more expensive if you look at the hardware alone, but like I mentioned before you have to consider not only the price but the operational time MongoDB will require.

I have been there, done that, and ended up not using OpsWorks to host MongodDB. Hopefully this will save you some time and headaches.

like image 136
Onema Avatar answered Oct 18 '22 17:10

Onema