blog@jatinganhotra

render :object => Experience.new

Install MongoDB on Ubuntu

| Comments

Having trouble viewing in English, Choose Your Language :    

 
There are multiple ways to install MongoDB on Ubuntu (I have got Ubuntu 11.10 setup on my machine).
  • the mongodb package in Debian/UbuntuOpen or Close
    On running
    1
    
    sudo apt-cache show mongodb
    it will print out a lot of information about the package like
    1
    2
    3
    4
    5
    
    Package: mongodb
    Architecture: i386
    Version: 1:1.8.2-1ubuntu1
    Depends: mongodb-server, mongodb-dev
    Filename: pool/universe/m/mongodb/mongodb_1.8.2-1ubuntu1_i386.deb
    If you carefully notice, the version is outdated. If you wish to install it, run
    1
    
    sudo apt-get install mongodb
    and mongodb will be installed for you alongwith
    libmozjs185-1.0 mongodb-clients mongodb-dev mongodb-server
  • the mongodb-10gen package by 10genOpen or Close
    To install the mongodb-10gen package, corresponding to the latest stable release, follow the instructions as follows:
    + Add the GPG key:
    1
    
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
    + Add this line verbatim to your /etc/apt/sources.list
    /etc/apt/sources.list
    1
    2
    3
    4
    
    # if you are on older Ubuntus
    deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen
    # On new Ubuntus, add this
    deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
    
    + Update the sources
    1
    
    sudo apt-get update
    + Install the desired package(latest stable or latest development release)
    1
    
    sudo apt-get install mongodb-10gen
    For more detailed guide on this, refer to MongoDB guide for Ubuntu and Debian packages
  • Unix binariesOpen or Close
    32-bit
    1
    2
    3
    
    $ # replace "2.0.1" in the url below with the version you want
    $ curl http://downloads.mongodb.org/linux/mongodb-linux-i686-2.0.1.tgz > mongo.tgz
    $ tar xzf mongo.tgz
    
    64-bit
    1
    2
    3
    
    $ # replace "2.0.1" in the url below with the version you want
    $ curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.0.1.tgz > mongo.tgz
    $ tar xzf mongo.tgz
    
  • Building from sourceOpen or Close
    + Install prerequisites For Ubuntu 10.04+ :
    (For older versions, refer MongoDB guide for building from source )
    1
    2
    3
    
    apt-get -y install tcsh git-core scons g++
    apt-get -y install libpcre++-dev libboost-dev libreadline-dev xulrunner-1.9.2-dev
    apt-get -y install libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev
    
    + Get source
    1
    2
    3
    
    git clone git://github.com/mongodb/mongo.git && cd mongo
    git tag -l
    git checkout r2.0.0
    
    + Build
    1
    
    scons all
    + Install –prefix can be anywhere you want to contain your binaries e.g. /usr/local or /opt/mongo.
    1
    
    scons --prefix=/opt/mongo install

Comments