Skip to content

Instantly share code, notes, and snippets.

@jokandre
Created February 10, 2017 09:19
Show Gist options
  • Select an option

  • Save jokandre/6cd0ba12b8817d49c1862645ceea60ab to your computer and use it in GitHub Desktop.

Select an option

Save jokandre/6cd0ba12b8817d49c1862645ceea60ab to your computer and use it in GitHub Desktop.
Setting up mongo 3.4 in cloud9 environment

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#install-mongodb Use linux 14.4

&&

dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
dpkg-divert --local --rename --add /etc/init.d/mongod
ln -s /bin/true /etc/init.d/mongod

&& #Installing MongoDB on a Cloud9 workspace To install MongoDB in your workspace, you can open a terminal and run the following command:

sudo apt-get install -y mongodb-org

Running MongoDB on a Cloud9 workspace MongoDB is preinstalled in your workspace. To run MongoDB, run the following below (passing the correct parameters to it). Mongodb data will be stored in the folder data.

$ mkdir data
$ echo 'mongod --bind_ip=$IP --dbpath=data --nojournal --rest "$@"' > mongod
$ chmod a+x mongod

You can start mongodb by running the mongod script on your project root:

$ ./mongod

MongoDB parameters used: --dbpath=data - Because it defaults to /var/db (which isn't accessible) --nojournal - Because mongodb usually pre-allocates 2 GB journal file (which exceeds Cloud9 disk space quota) --bind_ip=$IP - Because you can't bind to 0.0.0.0 --rest - Runs on default port 28017

Drivers You should use the host $IP instead of localhost as your driver connection URL. For example, in Node, it is: process.env.IP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment