Skip to content

Instantly share code, notes, and snippets.

@lukelex
Created December 24, 2012 14:17
Show Gist options
  • Select an option

  • Save lukelex/4369401 to your computer and use it in GitHub Desktop.

Select an option

Save lukelex/4369401 to your computer and use it in GitHub Desktop.
Installing latest version of MongoDB on ubuntu

=Install MongoDB

==Add 10gen package to source.list

The 10gen package contains the latest mongoDB version, append below line to the end of the file “/etc/apt/sources.list”

deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

For example, vim the “source.list” and append the 10gen package like this :

$ sudo vim /etc/apt/sources.list

File : /etc/apt/sources.list

#...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
deb-src http://extras.ubuntu.com/ubuntu natty main
 
#mongo repo ###############new line
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen

==Update package

Update the modified “/etc/apt/sources.list” :

sudo apt-get update

Now, a new “mongodb-10gen – An object/document-oriented database” is available for install.

==Add GPG Key

10gen package required GPG key, import it :

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10

==Install mongodb-10gen

Everything is ready, now you can Install the mongoDB package :

sudo apt-get install mongodb-10gen

==Post-Installation

Now, MongoDB is installed, started, and auto start MongoDB script is generated to “/etc/init/mongo” and “/etc/init.d/mongo“. In addition, all MongoDB files are copied to “/usr/bin” folder.

The main configuration file “mongodb.conf” is located at “/etc/mongodb.conf“, change the values to customize your mongoDB server.

File : mongodb.conf

# mongodb.conf
# Where to store the data.
 
dbpath=/var/lib/mongodb
 
#where to log
logpath=/var/log/mongodb/mongodb.log
 
logappend=true
 
#port = 27017
#......

==Verification

To verify it, just connect it with “mongo”

$ mongo
MongoDB shell version: 1.8.1
connecting to: test
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment