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
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10This 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 http://downloads.mongodb.org/distros/ubuntu 10.4 10gen" >> /etc/apt/sources.list.d/10gen.listIf you are using Ubuntu Karmic use the following analagous command:
echo "deb http://downloads.mongodb.org/distros/ubuntu 9.10 10gen" >> /etc/apt/sources.list.d/10gen.listNow, to actually install the MongoDB database, run the following commands:
apt-get update apt-get -y install mongodb-stableThis 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-snapshotIf, 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-propertiesNext, add the mongodb-drivers repository.
add-apt-repository ppa:chris-lea/mongodb-driversThis 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