How to install MongoDB on ubuntu 12.04 (Precise) Server
Sponsored Link
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()
“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!