How to install MongoDB on ubuntu 12.04 (Precise) Server

Sponsored Link
MongoDB (from "humongous") is an open source document-oriented NoSQL database system.MongoDB is part of the NoSQL family of database systems. Instead of storing data in tables as is done in a "classical" relational database, MongoDB stores structured data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.
MongoDB is a document database used commonly in modern web applications.

Install MongoDB on ubuntu 12.04 (Precise) Server

From the command line run the following comamnds

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

Run the following command to install the latest stable version of MongoDB

sudo apt-get -y install mongodb-10gen

Configure MongoDB

These packages configure MongoDB using the /etc/mongodb.conf file in conjunction with the control script. For Upstart-based systems, find the control script is at /etc/init/mongodb.conf.

This MongoDB instance will store its data files in the /var/lib/mongodb and its log files in /var/log/mongodb, and run using the mongodb user account.

Controlling MongoDB

Starting MongoDB

Upstart users can start the mongod process by issuing the following command:

sudo service mongodb start

Stopping MongoDB

Upstart users can stop the mongod process by issuing the following command:

sudo service mongodb stop

Restarting MongoDB

Upstart users can restart the mongod process by issuing the following command:

sudo service mongodb restart

Controlling mongos

As of the current release, there are no control scripts for mongos. mongos is only used in sharding deployments and typically do not run on the same systems where mongod runs. You can use the mongodb script referenced above to derive your own mongos control script.

Using MongoDB

Among the tools included with the MongoDB package, is the mongo shell. You can connect to your MongoDB instance by issuing the following command at the system prompt:

mongo

This will connect to the database running on the localhost interface by default. At the mongo prompt, issue the following two commands to insert a record in the “test” collection of the (default) “test” database.

> db.test.save( { a: 1 } )
> db.test.find()

Sponsored Link

Incoming search terms:

Related posts

One thought on “How to install MongoDB on ubuntu 12.04 (Precise) Server

  1. “Controlling mongos

    As of the current release, there are no control scripts for mongos. mongos is only used in

    sharding

    deployments and typically do not run on the same systems where mongod runs. You can use the mongodb script referenced above to derive your own mongos control script.”

    :} sharding delpoyments is an unexpected pasttime!

    P.S watch out for that swiss shard!

    [Reply]

Leave a comment

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