In this blog, we will learn how to install MongoDB Community Edition on Ubuntu 14.04 LTS Linux systems. Before installing MongoDB check which version you are going to install. Let us say that I have Ubuntu 14.04 with OS type 32-bit and I want to install MongoDB version 3.x.
Step 1: Run the following command over CLI
username@machinename:~$ sudo apt-get update
Step 2: Now we will run the below command-line .
This command will help us to install the latest stable version.
username@machinename:~$ sudo apt-get install -y mongodb-org
We see the output as below:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package mongodb-org
For resolving the above issue we have to make sure that if we want to install MongoDB with version greater than 2.4.9 (i.e. 3.x ) we need our system OS type to be of 64 bit as packages provided by MongoDB are for 64-bit LTS (Long Term Support) Ubuntu releases only. If our OS type is of 64 bit it is very easy to install MongoDB version above 3.x else we need to install the OS with 64-bit type.
To install any specific version we need to specify the version just as below with all the other components package along with the same version as that of the mongodb-org .
sudo apt-get install -y mongodb-org=3.2.9 mongodb-org-server=3.2.9 mongodb-org-shell=3.2.9 mongodb-org-mongos=3.2.9 mongodb-org-tools=3.2.9
Make sure that if we run only the single command (i.e.)
sudo apt-get install -y mongodb-org=3.0
and did not mention the other components package along with the version (i.e 3.0), it will install the latest packages irrespective of checking the version of mongodb-org which can cause conflicts.
After MongoDB is installed successfully we need to check the installation by following the below steps:
Step 1:
username@machinename:~$ sudo service mongod start
Output:
[sudo] password for username:
start: Job is already running: mongod
Step 2:
Now check the following line in a file mongodb.log
2016-08-23T09:24:40.320+0530 I NETWORK [initandlisten] waiting for connections on port 27017
at the following path
/var/log/mongodb/mongodb.log
Note: 27017 is default port. This port is configured in the file mongod.conf at path (/etc/mongod.conf)
Step 3:
If we need to stop the services we use the below command
username@machinename:~$ sudo service mongod stop
Output:
[sudo] password for username:
mongod stop/waiting
Step 4:
Restarting the service
username@machinename:~$ sudo service mongod restart
Output:
stop: Unknown instance:
mongod start/running, process <Number>
0 Comment(s)