I’ve been looking at noSQL databases in conjunction with Node.js. I have several Raspberry Pis that I have been using as development and test platforms. I have had good success with couchDB but have seen more examples and deployments using mongoDB. MongoDB is clearly developed on Intel processors but has been ported to non-Intel processors with different “endian”. Getting mongoDB to compile and run on a Raspberry Pi has been a challenge — as seen by the dearth of info when Googling. I did run across a couple of useful sites with links and directions on how to compile mongoDB on the R-Pi BUT both had a few problems. I’ve managed to get mongoDB version 2.1.1 working. Specific instructions —
As of 20 July 2014, the below instructions no longer result in a stable version of MongoDB. Everything seems to compile and install but mongod & mongo do not function correctly. Check out my new post about mongoDB 2.6.3 on R-Pi
As of 16 February 2013:
First ensure your Raspbian OS is up to date with:
sudo apt-get update
sudo apt-get upgrade
>> Linux black-pi 3.6.11+ #371 PREEMPT Thu Feb 7 16:31:35 GMT 2013 armv6l GNU/Linux
Now apt-get dependencies and do build(s). You need a 512MB RAM R-Pi and this can take about 5 hours!
sudo apt-get install build-essential libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev scons libboost-all-dev python-pymongo git
git clone https://github.com/skrabban/mongo-nonx86
sudo scons –prefix=/opt/mongo install
Now add mongodb user and set up required directories with correct permissions
sudo adduser --firstuid 100 --ingroup nogroup --shell /etc/false --disabled-password --gecos "" --no-create-home mongodb
sudo mkdir /var/log/mongodb/
sudo chown mongodb:nogroup /var/log/mongodb/
sudo mkdir /var/lib/mongodb
sudo chown mongodb:nogroup /var/lib/mongodb
sudo cp debian/init.d /etc/init.d/mongod
sudo cp debian/mongodb.conf /etc/
sudo ln -s /opt/mongo/bin/mongod /usr/bin/mongod
The config file for mongoDb is: /etc/mongodb.conf
You can start mongoDB by: sudo /etc/init.d/mongod start
You can stop it with: sudo /etc/init.d/mogod stop
You can get the command line by: /opt/mongo/bin/mongo
Install Mongodb in Raspberry Pi
[…] Update 02 April 13 Just noticed a new link/site […]
Thank you so much for you tutorial.
Just in case someone has the same issues I had, you also need to create the folder /data/db with proper rights an give execution rights to the /etc/init.d/mongod file at the end of the process.
I’ve completed the steps above and I’m getting the following error when trying to start the mongod service.
sudo: /etc/init.d/mogod: command not found
I can successfully start mongod manually with ‘sudo /opt/mongo/bin/mongod’.
Hey Jeff, check your command line? I see a “:” (colon) after the “sudo”. This should not be there. Also do a “ls -l /etc/init.d/mongod” to see if the file exists. If not, check that you followed the above instructions and note the comments for any corrections or additions.
Looks like the /etc/init.d/mongod file didn’t have execute permissions.
sudo chmod 755 /etc/init.d/mongod
Service starting now. Thanks again for this tutorial and your assistance!
[…] Thanks to Andy Felong who helped out with this. You can read his blog post on the subject here. […]
Hi – I’m quite new to pi and would like to try your solution but I’m bit daunted by the time it takes to build/install mongo. Is it not possible for someone to do the compile once and provide pre-compiled binaries that can be copied onto the target device? I’ve looked on the internet but can’t seem to find them so perhaps my thought process is wrong?