Skip to content

Instantly share code, notes, and snippets.

@BernardoSilva
Last active August 29, 2015 14:04
Show Gist options
  • Save BernardoSilva/802a1d0b9ecd17a7d2f2 to your computer and use it in GitHub Desktop.
Save BernardoSilva/802a1d0b9ecd17a7d2f2 to your computer and use it in GitHub Desktop.
Install specific version of MongoDb on Ubuntu
First you have to download the 32bit or 64bit Linux binaries from here and unzip the contents to /usr/local.
# cd /tmp
# curl -O http://downloads.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz
# sudo tar -zxf /tmp/mongodb-linux-i686-2.4.9.tgz -C /usr/local
Then you need to configure some symbolic links.
#sudo ln -s /usr/local/mongodb-linux-i686-2.0.1 /usr/local/mongodb
#sudo ln -s /usr/local/mongodb/bin/bsondump /usr/local/bin/bsondump
#sudo ln -s /usr/local/mongodb/bin/mongo /usr/local/bin/mongo
#sudo ln -s /usr/local/mongodb/bin/mongod /usr/local/bin/mongod
#sudo ln -s /usr/local/mongodb/bin/mongodump /usr/local/bin/mongodump
#sudo ln -s /usr/local/mongodb/bin/mongoexport /usr/local/bin/mongoexport
#sudo ln -s /usr/local/mongodb/bin/mongofiles /usr/local/bin/mongofiles
#sudo ln -s /usr/local/mongodb/bin/mongoimport /usr/local/bin/mongoimport
#sudo ln -s /usr/local/mongodb/bin/mongorestore /usr/local/bin/mongorestore
#sudo ln -s /usr/local/mongodb/bin/mongos /usr/local/bin/mongos
#sudo ln -s /usr/local/mongodb/bin/mongosniff /usr/local/bin/mongosniff
#sudo ln -s /usr/local/mongodb/bin/mongostat /usr/local/bin/mongostat
All you need to do now is to setup the Linux service which will be used to start MongoDB server, to do so download this script from here.
-- in case the link goes away just download the file content from here
-- https://gist.github.com/BernardoSilva/104a7aeb04920fd52755#file-mongod
wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/mongod
#sudo mv mongod /etc/init.d/mongod
#sudo chmod +x /etc/init.d/mongod
After this, you’ll need to create a new system user ‘mongodb’ and prepare some folders.
#sudo useradd mongodb
#sudo mkdir -p /var/lib/mongodb
#sudo mkdir -p /var/log/mongodb
#sudo chown mongodb.mongodb /var/lib/mongodb
#sudo chown mongodb.mongodb /var/log/mongodb
And finally you need to activate you MongoDB service’s by adding it to your system’s run-level. That way the service will startup during the boot sequence and stop nicely during the OS shutdown procedure.
#sudo update-rc.d mongod defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment