Http://songgz.iteye.com/blog/1139345
The following describes how to install MongoDB on Ubuntu 11.04.
1. Add 10gen package to source. List.10gen package contains the latest MongoDB version. Add the following lines at the end of the file "/etc/APT/sources. List.
Java code
- Deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart Dist 10gen
For example, use nano to edit the file "source. List" and add the 10gen package as follows.
Java code
- $ Sudo nano/etc/APT/sources. List
File:/etc/APT/sources. List.
Java code
- #... Content omitted...
- # This software is not part of ubuntu, but is offered by third-party
- # Developers who want to ship their latest software.
- Deb http://extras.ubuntu.com/ubuntu natty main
- The Deb-Src http://extras.ubuntu.com/ubuntu natty main
- # Mongo repo ############### New Line
- Deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart Dist 10gen
2. Add the GPG key.
10gen package requires the GPG key. Import it:
Java code
- Sudo apt-key adv -- keyserver keyserver.ubuntu.com -- Recv 7f0ceb10
3. Update the package.
Revise "/etc/APT/sources. List ".
Java code
- Sudo apt-Get update
Now, a new "mongodb-10gen-an image-oriented, document-oriented database is effective for installation.
4. Install mongodb-10gen
Everything is ready. Now you can install MongoDB package:
Java code
- Sudo apt-Get install mongodb-10gen
5. aftercare.
Now, MongoDB has been installed, and the script for starting and automatically starting MongoDB is generated to "/etc/init/mongo" and "/etc/init. d/mongo". In addition, all MongoDB files are stored in the "/usr/bin" folder.
The main configuration file "MongoDB. conf" is put into "/etc/MongoDB. conf", where you can modify the custom configuration.
File: MongoDB. conf is as follows.
Java code
- # MongoDB. conf
- # Where to store the data.
- # Note: If you run MongoDB as a non-root user (recommended) You may
- # Need To create and Set permissions for this directory manually,
- # E.g., if the parent directory isn' t mutable by the MongoDB user.
- Dbpath =/var/lib/MongoDB
- # Where to log
- Logpath =/var/log/MongoDB. Log
- Logappend = true
- # Port = 27017
- #......
6. Verify.
Use Mongo to connect to MongoDB to verify it.
Java code
- $ Mongo
- MongoDB shell version: 1.8.1
- Connecting to: Test
- >