• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
sharadchhetri.com

sharadchhetri.com

Linux,Cloud Computing And DevOps

  • Home
  • Linux
  • CloudComputing
    • Introduction Cloud Computing
    • Amazon AWS
  • Free E-Books
  • About Me

Install MongoDB server on Ubuntu 12.04 LTS

February 16, 2014 by Sharad Chhetri Leave a Comment

In this tutorial we will learn,how to install MongoDB server on Ubuntu 12.04 LTS.
MongoDB is one the popular nosql database.It is a cross-platform document-oriented database system.MongoDB has its interactive shell called mongo .In recent years,many companies started using MongoDB.To know about more details on MongoDB,you can visit the Wikipedia link

How to install MongoDB server on Ubuntu 12.04 LTS

To install MongoDB server on Ubuntu 12.04 LTS,follow the given below steps.

Step 1: Log into your Ubuntu system and run below given command

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
sudo echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list

Step 2: Now update the apt source

sudo apt-get update

Step 3: Install MongoDB with apt-get command.It will install the latest
stable MongoDB in the system.

sudo apt-get install mongodb-10gen

Step 4: After installing the mongodb in Ubuntu.It will be automatically started.
You can check the running status by using the below given command

sudo service mongodb status

Alternatively, you can also use the ps command.It will show the running process

ps -ef|grep mongo

Given below is the example from my system

root@ubuntu:~# ps -ef|grep mongodb
mongodb 2841 1 7 14:05 ? 00:00:08 /usr/bin/mongod –config /etc/mongodb.conf
root 2861 2392 0 14:07 pts/0 00:00:00 grep –color=auto mongodb
root@ubuntu:~#

To stop the MongoDB run below given command

service mongodb stop

To start the MongoDB run below given command

service mongodb start

To restart the MongoDB run below given command

service mongodb restart

Step 5: You can check the listening port of running MongoDB by using netstat command.

NOTE: MongoDB using the port no. 27017 and 28017
(MongoDB default port number)

netstat -tanp |grep mongo


Below given is reference from my system

root@ubuntu:~# netstat -tanp|grep mongo
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 2841/mongod
tcp 0 0 0.0.0.0:28017 0.0.0.0:* LISTEN 2841/mongod
root@ubuntu:~#

Step 6 : To acces the MongoDB console,you have to run only mongo command

When first time you run mongo command,you will get welcome message as well as MongoDB version information

See the below given reference

root@ubuntu:~# mongo
MongoDB shell version: 2.4.9
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	http://docs.mongodb.org/
Questions? Try the support group
	http://groups.google.com/group/mongodb-user
> 

Now you will be at mongo console

To exit from mongo console

To exit from mongo console.In console type the command exit and hit enter.
You can also press CTRL + D key from your keyboard for exit .You will bye message on exit.

See below given example for exit from mongo console.Because now I am again entering into mongo console,the welcome message will not be there.

mongodb

Other important information of MongoDB

(1) MongoDB configuration path is /etc/mongodb.conf.

root@ubuntu:~# cat /etc/mongodb.conf |egrep -v '^#|^$'
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongodb.log
logappend=true
root@ubuntu:~#

Note: I used the command egrep -v '^#|^$', to do not show commented lines(#) and blank lines from the file /etc/mongodb.conf. the file has lots of commented options.

(2) MongoDB data directory bydefault path is /var/lib/mongodb
Below given is the reference from my system.

root@ubuntu:~# ls -l /var/lib/mongodb/
total 81932
drwxr-xr-x 2 mongodb nogroup     4096 Feb 16 18:40 journal
-rw------- 1 mongodb nogroup 67108864 Feb 16 18:40 local.0
-rw------- 1 mongodb nogroup 16777216 Feb 16 18:40 local.ns
-rwxr-xr-x 1 mongodb nogroup        5 Feb 16 18:40 mongod.lock
root@ubuntu:~# 

(3) MongoDB log file path is /var/log/mongodb/mongodb.log

Do'nt be greedy, share the knowledge!

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)

Related

Filed Under: Database Server, Linux Tagged With: mongodb

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Twitter
  • GitHub
  • YouTube

Recent Posts

  • Activate.ps1 cannot be loaded because running scripts is disabled on this system
  • How to install Java (OpenJDK) on Ubuntu Linux
  • How to install Groovy on Ubuntu 20.04 LTS
  • How to Disable selinux in Red Hat or CentOS
  • How to remove date from WordPress Post URL

Top Posts & Pages

  • How to delete mail queue in Postfix
  • How to fix read only USB pen drive in Ubuntu
  • How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7
  • 4 different commands to check the load average in linux
  • How to set hostname and FQDN on CentOS 7 and RHEL 7
  • How to find absolute path of command on Linux / Unix : which command
  • How to create Jenkins user by command line and GUI
  • How to print particular line number by using sed command
  • How to setup Jenkins Credentials for Git repo access
  • make command not found in linux CentOS Red Hat ubuntu Debian

DevOps Posts

  • vagrant cloud flow

    Install Vagrant on Ubuntu and create first VM

  • git jenkins credential github

    How to setup Jenkins Credentials for Git repo access

  • terraform

    how to install terraform in Linux : CentOS-Ubuntu

  • docker image

    How to create Ubuntu docker base image

  • Install Ansible on Ubuntu / CentOS / RHEL

Footer

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Sharad Chhetri is an experienced Linux - Cloud Engineer & freelancer. Working on Open Source Technology since RHEL 4.0 (Red Hat Enterprise Linux). He loves sharing the knowledge which earned from real scenarios. Don't be surprised if you find him in technology seminars and meetup groups. You can contact him on email for freelance projects at admin@sharadchhetri.com. Read More…

Tags

Amazon AWS apache automation awk bash script CentOS centos 7 debian devops docker freebsd ftp ghost git grep hostname jenkins kvm linux linux command linux commands MariaDB Server mysql Nagios nginx Octopress owncloud Owncloud 6 php postfix postgres python Red Hat rpm sed selinux ssh swap ubuntu user management vagrant varnish virtualbox vsftp wordpress

Recent Comments

  • Sharad Chhetri on How to fix read only USB pen drive in Ubuntu
  • iain mckeand on How to fix read only USB pen drive in Ubuntu
  • Sharad Chhetri on Secondary Logging : save all users history command output as log
  • Sharad Chhetri on How to fix read only USB pen drive in Ubuntu
  • er on What is /dev/shm and how to mount /dev/shm
  • Bala on Send nagios report as pdf file via email
  • Terry on How to fix read only USB pen drive in Ubuntu
  • Terry on How to fix read only USB pen drive in Ubuntu

Copyright © 2009 - 2022 · All Rights Reserved sharadchhetri.com · · Privacy Policy ·
· sitemap.xml · ·The content is copyrighted to sharadchhetri.com and may not be reproduced on other websites without our permission. ·

Copyright © 2022 Ā· Genesis Sample on Genesis Framework Ā· WordPress Ā· Log in

 

Loading Comments...