"Google Compute Engine - Quickstart"

Published: Mon 04 July 2016

In content.

Quickstart with MongoDB

Once you have obtained your account with Google Cloud Console, proceed to do the following:

[Create an Instance]

  • Name the instance. Name must start with a lowercase letter followed by up to 62 lowercase letters, numbers, or hyphens, and cannot end with a hyphen. In this case, name it back-end.
  • Select Zone of your choice. it can be any from asia, europe or us.
  • Then proceed to select Machine Type. Select f1-micro.
  • Then select Boot disk image. In this case , select Ubuntu 14.04 LTS.
  • Then proceed to Firewall and tick Allow HTTP traffic to allow VMs to interact in between them.
  • Finally, click Create VM.

Create another VM e.g front-end following steps above.

Once you're done, proceed to ssh into back-end VM you have created earlier.

Proceed to install and run the back-end database. Enter these commands to install and run MongoDB.

  • sudo apt-get update
  • sudo apt-get install mongodb
  • sudo service mongodb stop # The mongodb service started when you installed it. you would need to stop it.
  • sudo mkdir $HOME/db ; sudo mongod --dbpath $HOME/db --port 80 --fork --logpath /var/tmp/mongodb #Create a directory for MongoDB and then run the MongoDB service in the background on port 80.

Now install and run the web app on your front-end VM.

Proceed by SSH into the VM.

Follow steps below to install and run the app.

  • sudo apt-get update
  • sudo apt-get install git nodejs npm
  • git clone https://github.com/GoogleCloudPlatform/todomvc-mongodb.git #Clone the sample application and install application dependencies.
  • cd todomvc-mongodb; npm install
  • nohup nodejs server.js --be_ip --fe_ip & #Start the todo web application. Note: The IP addresses below are internal IPs for communication between servers. You can find these IP addresses on each server’s details page.

Proceed to open the app in new browser window:


You will find your new app running.