Getting started with MongoDB under Ubuntu

Printer-friendly versionPrinter-friendly version

What is this MongoDB?

An increasingly popular, document-oriented database that you can read about here.

Installing MongoDB on Ubuntu

And here's the catch because, at the moment, the current release of MongoDB has a shared library issue. So you can try to install MongoDB the normal way and, if that works, you're good to go. If not, you have to do a bit more work.

Installing the normal Ubuntu package

To install the standard package:

$ sudo apt-get install mongodb

and if you can run the following and it works, you're good:

$ mongo

However, as of right this minute, this is what happens with that normal package:

$ mongo
mongo: error while loading shared libraries: libmozjs.so: \
  cannot open shared object file: No such file or directory
$

This is a known issue so, if you run into that, purge that package and continue on to the next section.

Installing the MongoDB snapshot

If the normal MongoDB package doesn't run (or you want to keep up with the regular package snapshots), here's the recipe:

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
$ sudo apt-add-repository \
  "deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen"
$ sudo apt-get update
$ sudo apt-get install mongodb-snapshot

At this point, barring any other weirdness, you should be able to:

$ mongo
MongoDB shell version: 1.5.4-pre-
connecting to: test
>

and just type "Ctl-D" to exit the MongoDB shell.

The MongoDB Upstart scripts

How to control the execution of the mongod server process:

$ sudo status mongodb
$ sudo stop mongodb
$ sudo start mongodb
$ sudo restart mongodb

More coming shortly ...

... on what to actually do with this package. For now, just get it installed and working.

Comments

I 'm getting an issue. .

it has worked for me several times. Good tutorial..

But i am getting this error when i run mongo. I ve tried through synaptic pakage manager also.

Issue:

root@ubuntu:~/mongo# mongo
MongoDB shell version: 1.7.2-pre-
connecting to: test
Sun Nov 21 01:48:27 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:74
exception: connect failed

thanx for the tutorial

it worked fine.. good work..

Worked perfectly

Thanks for this article, it should be part of the MongoDB documentation, as it an way much easier fix than installing xulrunner-dev and everything.

BTW, OpenID login seems to be broken.

We know

We're aware of the time and budget pressures at most companies, normally accompanied by the plaintive cry from management of, "Yes, I know we need training on that topic, but I just can't afford to send my entire team away for three (or four or five) days to get it!" And that's where we come in.

Choices!

The main focus at Crashcourse is to offer a choice of intense, 1-day, hands-on courses on specific topics in Linux and open source. And given that we already have the laptops for the delivery of that training, the idea is to show up early, set up a classroom, then spend the day teaching exactly the topic you're interested in. No travel time, and no wasted classroom time.

Customization

If we don't already have a course that addresses the topic you're interested in, drop us a note and we'll see what we can do -- our content providers can almost certainly put together a course that's precisely what you're after.

The difference

While there are a variety of sources for Linux and open source training, we at Crashcourse are taking a slightly different approach. Our philosophy is simple: exactly the training you want, and no wasted time or travel to get it.