In this article, I would like to guide how we install a MongoDb instance on Ubuntu virtual machine that you have installed.

Prerequisite conditions

  • You must install an Ubuntu OS virtual machine on VWareWorkstation application or any box supports you create a virtual machine.
  • Putty client that can connect to the virtual machine.
  • Ubuntu OS must be 12.04 or 14.04 LTS version

Install MongoDB

Step 1: Connect to the virtual machine through Putty

Step 2: Register the MongoDB packages with Ubuntu

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv EA312927

MongoDB-Intall-1

Step 3: Create list of folder to store mongodb such as data files and log files

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

MongoDB-Intall-2

Step 4: Update some packages before installing

sudo apt-get update

Step 5: Install MongoDB

sudo apt-get install -y mongodb-org

 

Connect to MongoDB

By default, a MongoDB instance named mongod runs on 27017 port and IP is 127.0.0.1 or localhost

Step 1: Verify MongoDB instance status

sudo service mongod status

If status is stop/waiting, we need to start

Step 2: Start a MongoDB service

sudo service mongd start

Step 3: Stop a MongoDB service

sudo service mongd stop

Step 4: connect to MongoDB. By default, you will access test database.

mongo

Now, you’re ready to work on MongoDB.

Modify IP Address of MongDB instance

In case you want to connect to the MongoDB instance what you have installed from other client machines, you need to modify the IP address of the machine that is running the MongoDB instance instead of default value 127.0.0.1

Step 1: login with root user

sudo bash

Step 2: open mongod.conf file. There is the configuration file which mongod service uses it whenever it is started.

sudo /etc/mongod.conf

Step 3: go to line bind_ip and edit the value. In this case, bind_ip is changed 192.168.137.40 instead of 127.0.0.1 as default

Step 4: Cltr+X -> Y -> Cltr+A+M

 

Advertisements

2 thoughts on “How to install MongoDB Community edition on Ubuntu 14.04 LTS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s