Mongo Install

In this MongoDB tutorial, I am listing down the steps to install MongoDB on windows machine. Also, we will learn about few basic operations related to start and shutdown of MongoDB. Also, we will learn about few basic operations related to start and shutdown of MongoDB.

MongoDB is a NoSQL database that avoids the traditional structure of relational databases in favor of document-oriented JSON-like objects. What this translates to is the integration between application and data is faster and easier. If that's not enough, consider this: MongoDB is one the databases preferred by big data and large enterprise companies, including Adobe, Craigslist, eBay, FIFA, Foursquare, and LinkedIn.

Data Center Must-Reads

There are different versions of MongoDB; the version I'll focus on is the community edition. You can easily install MongoDB on Ubuntu from the standard repositories, but that version tends to be out of date. Because of that, I'll show how to install the version from the official MongoDB repositories. This repository will install:

  • mongodb-org (this is the meta package that will install everything below)
  • mongodb-org-server (the mongod daemon)
  • mongodb-org-mongos (the mongos daemon)
  • mongodb-org-shell (the mongo shell)
  • mongodb-org-tools (the MongoDB tools package which includes import, dump, export, files, performance, restore, and stats tools)

The package we will install only provides support for 64-bit architecture. This package also only officially supports Long Term Support (LTS) releases (12.04, 14.04, 16.04); other releases may work, but not as a supported configuration (there is an installation issue with Ubuntu 16.04 that I will address later).

SEE:Google wants to commercialize database Spanner, but MongoDB or Cassandra could be safer bets

Setting up the repository

Mongo Install

The first step is add the MongoDB repository. To do this, you must import the MongoDB public key. Here's how.

  1. Open a terminal window.
  2. Issue the command sudo apt-key adv —keyserver hkp://keyserver.ubuntu.com:80 —recv EA312927.
  3. Issue the command sudo touch /etc/apt/sources.list.d/mongodb-org.list.
  4. Issue the command sudo nano /etc/apt-sources.list.d/mongodb-org.list.
  5. Copy and paste one of the following lines from below (depending upon your release) into the open file.
    For 12.04: deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse
    For 14.04: deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse
    For 16.04*: deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse
  6. Hit [Ctrl]+[x] to save the file.

* Note: Getting MongoDB community edition running successfully on Ubuntu 16.04 is challenging. I'll offer the solution after the standard installation steps below.

Installing MongoDB

Mongo Install 3.6

  1. Open a terminal window.
  2. Update apt with the command sudo apt-get update.
  3. Once apt has updated, install MongoDB with the command sudo apt-get install -y mongodb-org.
  4. Allow the installation to complete.

Running the community edition

To start the database, issue the command sudo service mongodb start. You should now be able to issue the command to see that MongoDB is running: systemctl status mongodb.

Mongo

Ubuntu 16.04 solution

If you are using Ubuntu 16.04, you may run into an issue where you see the error mongodb: unrecognized service due to the switch from upstart to systemd. To get around this, you have to follow these steps.

  1. If you added the /etc/apt/sources.list.d/mongodb-org.list, remove it with the command sudo rm /etc/apt/sources.list.d/mongodb-org.list.
  2. Update apt with the command sudo apt-get update.
  3. Install the official MongoDB version from the standard repositories with the command sudo apt-get install mongodb in order to get the service set up properly.
  4. Remove what you just installed with the command sudo apt-get remove mongodb && sudo apt-get autoremove.

Mongodb Install Windows 10

Follow the instructions I outlined earlier for installing MongoDB; this should re-install the latest version of MongoDB with the systemd services already in place. When you issue the command systemctl status mongodb you should see that the server is active (Figure A).

Figure A

The MongoDB server is now running on Ubuntu 16.04.

Time to play

Congratulations! You now have a working instance of MongoDB, and you can start learning the ins and outs of a database used by big data and enterprise companies—a good place to start is the official MongoDB manual. If you're looking for a forum with answers to your questions, check out this MongoDB Google Group.

Also see

  • Why some of the fastest growing databases are also the most experimental (TechRepublic)
  • MongoDB and Cassandra put relational databases on notice (TechRepublic)
  • Big data startups beware: Disruption isn't enough, you need to make money (TechRepublic)
  • Microsoft cozies up to Ubuntu as developers welcome cold day in hell (ZDNet)
  • Job description: Big data modeler (Tech Pro Research)