Workout Smarter

Migrating Parse MongoDB to MongoRocks on AWS

GYMINUTES, uses parse to backup our users data. Gyminutes community has lifted more than 8.5 Million pounds till date. Thats a lot of weight and a lot of data for us to store.

We used parse as our backend because it reduced our time to market. But now Parse is going down. So we decided to migrate to AWS.

Here is a step-by-step guide to help anyone who is looking to migrate their app away from PARSE to AWS. Why only AWS, if you may ask? Because its STABLE and unlike Parse to Facebook, AWS is actually bringing in $$. So thats why. I am sure other services are great but I don’t plan to use them PERIOD. Now lets get to it.

Its cheap for small apps as data is compressed to roughly 10x. This means, you save $$.

If it is good for parse to use it, it is good for you too.

STEP 1: MIGRATING MONGODB TO AWS

I am going to assume that you are new to AWS, Mongo and MongoRock. So I have divided this into multiple steps. Even if you are familiar with AWS and Mongo, I recommend you follow the guide below. It will reduce your debugging time.

Bringing up AWS instance.

Installing MongoRock on AWS

Migrating data from Parse to MongoRock.

Testing the data

Step 1.1 Bringing up AWS instance.

If you know how to set-up instance on AWS, jump to step 1.1.11, as its required for mongoRock.

Step 1.1.1 Login/Signup into AWS. (aws.amazon.com)

Step 1.1.2 Click “Network & Security” > “Key Pair”

Step 1.1.3 Click “Create Key Pair” on top Left tab.

Step 1.1.4 Give a name and click “Create”.

Step 1.1.5 It will prompt to download the key, save it somewhere safe. This is your private key that you will use to log into the server.

Step 1.1.6 Click “INSTANCES” > “Instance” from left menu.

Step 1.1.7 Click “Launch Instance”

Step 1.1.8 This will bring up list of OS that you can install it on. We will be using Ubuntu. Click “Select” on ubuntu tab.

Step 1.1.9: Select the instance type. Now I am assuming your app is small. If it is big, you should size them accordingly. For setup purpose, choose “t2.micro” and click “Next: Configure Instance Details”

Step 1.1.10: You will see the screen below. Leave everything as is and select “Protect against accidental termination” and “Enable CloudWatch detailed Monitoring” and click “Next: Add Storage”

Step 1.1.11: This is important. For MongoRock, you need to mount 2 more volumes. Click “Add New Volume” and add 2 volumes. It should look like screen below. Once done, click “Next: tag Instance”

Step 1.1.13: You would need to create a security group. Trust me this is for your own good. Just add 1 more rule to the table so we can allow external applications like parse server to talk to our mongoRock DB. It should look like this.

Step 1.1.14: Click “Review and Launch”. Verify everything and then click “LAUNCH”. As soon as you do that, a pop up will appear asking for the key. Select the key we created in step 1.1.3. Click “I ack….” and select “Launch Instance”. Click “View Instance” and wait for it to launch.

After initialization, you should have the instance “Public IP” and DNS”.

Step 2.1 Installing MongoRock on AWS instance.

Step 2.1.1: Login using your private key that you downloaded in step 1.1.3 and the public ip of your new instance. As we created the ubuntu instance, the username is “ubuntu”. Open a terminal and execute the command,

#> “sudo chmod 600 mongo-key”

#> “ssh -i mongo-key ubuntu@<xx.xx.xx.xx>”

This should log you in the server. Changing permission for key is required otherwise you get error message “key too open. Permission denied”

Step 2.1.2: After you log in, execute following command in this order.

Step 2.1.3: Now we need to enable MongoRock. MongoRock is a compression engine that is already compiled with the mongo instance we just installed. So now we need to enable that. Perform Following steps

#> sudo service mongod stop

#> sudo vim /etc/mongod.conf

//uncomment the like “engine: rocksdb”. The config file should look like this. Save and quit

#> sudo service mongod start* Starting database mongod [fail]
This will most likely fail. Why? Because we already had a mongo instance created before. So a mongo database do exist. And since we are new to installation and bringing up rockdb, we need to clear the directory containing the OLD database. I am assuming you don’t have any data in that database.

Make sure you keep the indentation as it looks like above. Mongo is PICKY.

#> sudo service mongod start

Step 2.1.5: Restart the box.

#> sudo reboot

Why? Because sooner or late your box will go down. It may go down because of IT fault or because you want to resize the instance. In any case, its better if we test this now? You are now assuming that if you restart the box, mongo will comeback up and start running.

I think the auto formatting of wordpress screwed up the command.
the mdadm command for create has 2 ‘-‘ in it..
so instead of
“sudo mdadm –create /dev/md0 –level=stripe –raid-devices=2 /dev/xvdb /dev/xvdc”

I am trying to start mongodb service. Till step 2.1.2 it was successfully, the time I changed the storage engine to rocksdb via
sudo vim /etc/mongod.conf
with exactly 2 spaces as shown.
It is failing, Have also excecuted
cd /var/lib/mongodb/
ls
sudo rm -rf *.*
But still it is failing. Even not printing in log why is it failing.
Have gone through the solutions available on the net nothing is working
Can you just help me out how to debug/solve this and get start the secrvice back again