This guide shows you how to install MongoDB on Ubuntu.
- Ubuntu 12.10
- MongoDB 2.2.3
1. Add 10gen package to source.list.d
Ubuntu 12 comes with a “mongo” package, but not the latest version.
$ sudo apt-cache search mongodb
mongodb
mongodb-clients
mongodb-dev
mongodb-serverIt’s recommended to add 10gen package to
/etc/apt/sources.list.d, as it contains the latest stable MongoDB. Create a /etc/apt/sources.list.d/mongo.list file, and declared the 10gen distro.$ sudo vim /etc/apt/sources.list.d/mongo.list/etc/apt/sources.list.d/mongo.list
##10gen package location
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen2. Add GPG Key
10gen package required GPG key, imports it :
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10If you didn’t imports the GPG key,
apt-get update will hits following error message :GPG error: http://downloads-distro.mongodb.org dist Release:
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 9ECBEC467F0CEB103. Update package
Update your
apt-get list.$ sudo apt-get updateSearch “mongodb” again, a new 10gen package is appearing now. Get the “
mongodb-10gen“, it contains the latest stable MongoDB.$ sudo apt-cache search mongodb
mongodb
mongodb-clients
mongodb-dev
mongodb-server
mongodb-10gen
mongodb18-10gen
mongodb20-10gen4. Install mongodb-10gen
Everything is ready, now you can Install MongoDB :
$ sudo apt-get install mongodb-10gen5. Where is MongoDB?
MongoDB is installed and started.
$ ps -ef | grep mongo
mongodb 5262 1 0 15:27 ? 00:00:14 /usr/bin/mongod --config /etc/mongodb.conf
mycareerrepublic 5578 3994 0 16:29 pts/0 00:00:00 grep --color=auto mongo
$ mongo -version
MongoDB shell version: 2.2.3All MongoDB executable files are stored at
/usr/bin/$ ls -ls /usr/bin | grep mongo
4220 -rwxr-xr-x 1 root root 4317928 Feb 2 08:11 mongo
10316 -rwxr-xr-x 1 root root 10563336 Feb 2 08:11 mongod
10320 -rwxr-xr-x 1 root root 10563664 Feb 2 08:11 mongodump
10284 -rwxr-xr-x 1 root root 10526736 Feb 2 08:11 mongoexport
10324 -rwxr-xr-x 1 root root 10567768 Feb 2 08:11 mongofiles
10296 -rwxr-xr-x 1 root root 10539056 Feb 2 08:11 mongoimport
10272 -rwxr-xr-x 1 root root 10514544 Feb 2 08:11 mongooplog
10272 -rwxr-xr-x 1 root root 10518512 Feb 2 08:11 mongoperf
10320 -rwxr-xr-x 1 root root 10563632 Feb 2 08:11 mongorestore
6644 -rwxr-xr-x 1 root root 6802848 Feb 2 08:11 mongos
10312 -rwxr-xr-x 1 root root 10556560 Feb 2 08:11 mongostat
10272 -rwxr-xr-x 1 root root 10515856 Feb 2 08:11 mongotopThe “mongodb control script” is generated at
/etc/init.d/mongodb$ ls -ls /etc/init.d | grep mongo
0 lrwxrwxrwx 1 root root 21 Feb 2 08:11 mongodb -> /lib/init/upstart-jobThe MongoDB config file is at
/etc/mongodb.conf/etc/mongodb.conf
# 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/mongodb.log
logappend=true
#port = 27017
#......6. Controlling MongoDB
Some commands to control the MongoDB.
Starting MongoDB
$ sudo service mongodb startStoping MongoDB
$ sudo service mongodb stopRestarting MongoDB
$ sudo service mongodb restart

0 comments:
Post a Comment