9 months ago

A few myth busting first

  1. MongoDB is preinstalled in your workspace. Nope it is not.
  2. The sudo apt-get install -y mongodb-org method mentioned all over the Web and in mongodb page as written will work. Nope. It won’t.

What you - need to do

  1. Create a fresh node workspace. It is best not to start from a old workspace because cloud9's older workspaces have different software setup.
  2. Open a terminal and type cd ~ This command will take you one directory above your workspace. This is actually your true home directory - in the unix file system sense. If you type pwd
    You will see /home/ubuntu We will do most of the work from this directory and not workspace directory as you are used to.
  3. From home directory and NOT from workspace directory type the following curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.2.tgz It will take few seconds to complete and get you back to the prompt. What you are doing is using curl to fetch a zipped version of the mongo db code.
  4. Type ls to make sure the mongodb-linux-x86_64-3.4.2.tgz file is in your home directory.
  5. Now type tar -zxvf mongodb-linux-x86_64-3.4.2.tgz This unzips and untars the file creating all the directories.
  6. Once the command completes type ls again and you will see that the file has created the directories. Make sure you are still in your home (/home/ubuntu) directory.
  7. Now we need to modify the .bashrc file. It is a hidden file. So an ls will not show you. Type ls -a (from your home directory :-)) you will see the .bashrc file along with several other hidden files.
  8. Type vim .bashrc At the very top, there should be three lines, each preceded by a ‘#’ character. Create a blank line under the third ‘#’ and enter the following: export PATH=/home/ubuntu/mongodb-linux-x86_64-3.4.2/bin:$PATH What you are doing is adding the mongo-db to your path manually
  9. Press 'esc' to get into the command mode. Type :wq in the command mode. Do not forget the ‘:’ -- the : switches vim to edit mode and wq says write and quit. If you forget the : you will not be able to get out of text entry mode and your .bashrc file will get wrong data. If that happens hit : again and type q without the the w. You will quit without changes. Then start back again.
  10. You are almost there. Type . .bashrc There are two dots. One dot then space then .bashrc (that is the filename)
  11. If there are no errors. You are probably doing great
  12. Type which mongod you should see the following : /home/ubuntu/mongodb-linux-x86_64-3.4.2/bin/mongod
  13. Type mongod & disown This will start the mongo daemon and get you back to the prompt. You may have to hit enter after a few seconds.
  14. If you type mongo now - you will be in the database :-)

Issues:

This is a quick and dirty setup.

  1. I did not show you how to start the database in a proper way
  2. I do not show you how to shut the daemon in a clean fashion. You can do the following:
    • ps - a will show the processes. Write down process number that says mongod
    • kill -9 process num

Before putting real data you must solve these.
This link may be reliable, but this one said mongodb was pre-installed!!

← Sorting out sorts in Javascript Manipulating Tabular Data using Python's List Comprehension →