To Gain Knowledge and to become a one, who all wants to become

Dreams are not those which are seen during sleep ,but Dreams are those which do not let you sleep,so see the dreams
and work hard to make them true.

Friday, October 15, 2010

Installing MongoDB on Ubuntu

Installing MongoDB on Ubuntu
MongoDB is a schema-free document oriented database developed by 10gen. It has been designed with the high performance demands of modern web applications in mind, and is currently gaining a great deal of traction in the development community. In this article, we will explain how to install the database on the Ubuntu. Fortunately, considerable work has already been done that makes accomplishing this task extremely quick and simple.
The instructions provided here work with Ubuntu's Karmic (9.10) and Lucid (10.04) releases. Both of these are available options with (ve) server. The newest release at the time of this writing (2010-06-10) is the Lucid release. We recommend using this release as it will have the most current application software easily available in the standard repositories.
There are a few steps to get things working.
  • Install the 10gen signing key
  • Set up the 10gen apt repository
  • Install the drivers for your language(s) of choice
The kind folks at 10gen have made the first two steps fairly straightforward. First, shell into your server using SSH as the root user (the commands in this article will all assume you are shelled in as the root user). Next, run the following command from the command line to import the 10gen signing key:
apt-key adv --keyserver --recv 7F0CEB10
This will ensure that the database software you download is actually the software published by 10gen.
Next, we need to set up the 10gen software repository on the system. If you have an Ubuntu Lucid server, run the following command:
echo "deb 10.4 10gen" >> /etc/apt/sources.list.d/10gen.list
If you are using Ubuntu Karmic use the following analagous command:
echo "deb 9.10 10gen" >> /etc/apt/sources.list.d/10gen.list
Now, to actually install the MongoDB database, run the following commands:
apt-get update
apt-get -y install mongodb-stable
This will install the current, stable release of MongoDB, along with the standard associated utility programs like mongodump and mongostat onto your server. If you want to install the unstable (development) or nightly snapshot releases, you may use these commands instead:
apt-get -y install mongodb-unstable
apt-get -y install mongodb-snapshot
If, having done this, you type mongo at the command prompt, and you see something similar to the following:
MongoDB shell version: 1.4.3
url: test
connecting to: test
type "help" for help
then you have successfully installed MongoDB! (Press Ctrl-D to get out of the Mongo shell).
You will probably also want to install language drivers for your language of choice so that you can develop applications using your new Mongo database. Fortunately, a (mt) Media Temple employee has made a repository with pre-packaged drivers that are easy to install. Drivers are currently available for the Perl, PHP, and Python languages.
There are no packages currently for the Ruby programming language due to complications with packaging RubyGems based software. 10gen has instructions for manually installing these drivers.
To install the other drivers, first install the python-software-properties package which helps you interface with the Ubuntu Launchpad platform.
apt-get -y install python-software-properties
Next, add the mongodb-drivers repository.
add-apt-repository ppa:chris-lea/mongodb-drivers
This will take care of installing the signing key and setting up the repository. To install drivers for all three languages, use the following commands.
apt-get update
apt-get -y install libmongodb-perl php5-mongo python-mongodb

No comments:

Post a Comment