Table of Contents
- 1 HOW TO INSTALL MONGODB COMMUNITY EDITION ON LINUX UBUNTU?
- 2 IMPORTING THE PUBLIC KEY USED BY THE UBUNTU PACKAGE MANAGER SYSTEM
- 3 CREATING A LIST TYPE FILE FOR MONGODB
- 4 IF I AM USING ELEMENTARY OS, HOW DO I KNOW WHICH VERSION OF UBUNTU I AM USING?
- 5 WE UPDATE THE LOCAL PACKAGE DATABASE OF OUR SO
- 6 INSTALLING MONGODB PACKAGES
- 7 RUNNING / RUNNING MONGODB
- 8 SOURCES
HOW TO INSTALL MONGODB COMMUNITY EDITION ON LINUX UBUNTU?
As of version 3.0, MongoDB can be installed more easily on Linux
Ubuntu or Elementary OS.
In this article we will see how to install MongoDB for Ubuntu 12.04 LTS (Precise Pangolin) and Ubuntu 14.04.5 LTS (Trusty Tahr).
It is very likely that this type of installation also works correctly for new versions of Ubuntu.
IMPORTING THE PUBLIC KEY USED BY THE UBUNTU PACKAGE MANAGER SYSTEM
Ubuntu’s package management tools (ie dpkg and apt) ensure consistency and
authenticity of the package by requiring distributors to sign packages with GPG keys.
Run the following command to import the MongoDB GPG public key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
CREATING A LIST TYPE FILE FOR MONGODB
In this file you will find the list of repositories from which mongoDB will be installed.
IF I AM USING ELEMENTARY OS, HOW DO I KNOW WHICH VERSION OF UBUNTU I AM USING?
Simply by executing the following command:
lsb_release -a -u | grep "Description"
This command will give us a result similar to the following:
Description: Ubuntu 14.04.5 LTS
We create the file type list /etc/apt/sources.list.d/mongodb-org-3.2.list, using the
appropriate command for the version of ubuntu that you are using:
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list"
WE UPDATE THE LOCAL PACKAGE DATABASE OF OUR SO
sudo apt-get update
INSTALLING MONGODB PACKAGES
We can install the latest stable version of MongoDB or a specific version of MongoDB.
INSTALLING THE LATEST STABLE VERSION OF MONGODB
sudo apt-get install -y mongodb-org
INSTALLING A SPECIFIC VERSION OF MONGODB
To install a specific version, you must specify each component individually along with
its version number, as in the following example:
sudo apt-get install -y mongodb-org=3.2.5 mongodb-org-server=3.2.5 mongodb-org-shell=3.2.5 mongodb-org-mongos=3.2.5 mongodb-org-tools=3.2.5
If only mongodb-org = 3.2.5 is installed, and the other components are not included, the
latest version of each MongoDB component will be installed, regardless of the version you specified.
VERIFYING MONGODB INSTALLATION
To verify if the installation of MongoDB has been successful simply write in the terminal the
If it indicates a version number, for example MongoDB shell version: 3.2.5, it means that MongoDB version 3.2.5 has been correctly installed.
RUNNING / RUNNING MONGODB
The MongoDB instance stores its data files in / var / lib / mongodb and its log record in / var / log / mongodb by default, and runs using the mongodb user account. You can specify
alternate logfile and logfile directories in /etc/mongod.conf.
We execute the following command to start MongoDB:
sudo service mongod start
VERIFYING THAT MONGODB HAS STARTED CORRECTLY
Verify that the mongod process has started successfully by checking the contents of the log file in /var/log/mongodb/mongod.log with the following command:
When executing this command we will be able to see the current log of MongoDB.
STOPPING THE MONGODB SERVICE
To stop the MongoDB service we simply have to type the following command:
sudo service mongod stop
RESTARTING THE MONGODB SERVICE
To restart the MongoDB service we simply have to type the following command:
sudo service mongod restart
Well friends, I hope this article is useful to you, if you find a bug please do not
hesitate to comment it to correct the steps of the installation and you know please do not
forget to share the article.
MongoDB, Inc. Install MongoDB Community Edition on Ubuntu. [Online]