MongoDB 3.0.7 on Raspberry Pi 2!

MongoDB logoI have successfully compiled MongoDB version 3.0.7 and tools on the Raspberry Pi 2.  Full instructions are after the break — click on “more“.  As usual I found great help from the Linux community for getting this to work on ARM7.  mongo, mongod, mongos, and tools are all working great.  The WiredTiger Engine does NOT work under 32-bit ARM but, AFAIK, all other components do 🙂

NOTE: I have made MongoDB 3.0.9 binaries available for Raspbian (Jesse) for R-Pi 2 – here.


Compiling MongoDB 3.0.7 under Raspbian Jessie on a Raspberry Pi 2:

NOTE: this take a few hours!  I’ve also heard reports that the compile may not have enough space on a “loaded” 16GB SD Card.  I used 2 different 32GB SD Cards with no issues.  You DO need a large swap file, however.

Do the usual bring-up-to-date:

sudo apt-get update
sudo apt-get upgrade

You will need a large swap file so as not to run out of memory during compile & link:

sudo dd if=/dev/zero of=/swapfile1 bs=1024 count=824000
sudo mkswap /swapfile1
sudo chmod 0600 /swapfile1
sudo swapon /swapfile1

Load the appropriate tools and libraries required:

sudo apt-get install build-essential libssl-dev git scons libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev

create and go to the build directory & then clone the source repository:

mkdir build_mongodb
cd build_mongodb/
git clone git://
cd mongo
git checkout r3.0.7

download the patched file, “SConscript” needed for ARM support in the V8-32.5 Javascript Engine.  You can get this file from GitHub at OR from this site at SConscript.

On an R-Pi, you can run these commands but PLEASE do not share this link!


Assuming you now have the file, “SConscript” in your home directory — confirm it and move to the target directory:

ls -l SConscript
cd ~/build_mongodb/mongo/src/third_party/v8-3.25/

confirm that you are in the right place and can see the old SConscript — then overwrite the old file with the patched version:

ls -l SConscript
mv ~/SConscript ./SConscript

OK, you are now ready to compile the core elements of MongoDB — mongod, mongo, and mongos. NOTE that I use the “-j 2” option (use 2 cores) NOT “-j 4” (use 4 cores) for compiling as I kept getting random errors with “-j 4”, ranging from “internal error” to “error 9”.   The “-j 2” option has worked reliably for me in a couple of trials.

[NOTE – 06 Apr 2016: corrected a typo in directory path, below]

cd ~/build_mongodb/mongo
scons -j 2 --ssl --wiredtiger=off --js-engine=v8-3.25 --c++11=off --disable-warnings-as-errors CXXFLAGS="-std=gnu++11" core

You can ignore the “Warning: swp{b}” messages as the R-Pi Jessie kernel supports the needed ARM instructions.  You can walk away from the compile for 2-3 hours 😉  If things go well, you will eventually see: “scons: done building targets.”.

Congratulations!  You will find non-stripped binary executables for mongod, mongo and mongos in the directory:  “~/build_mongodb/mongodb”.  You could setup your PATH variable to include this directory or continue as described below to get stripped binaries (smaller!) ready for “final” install.

Make sure you still have the large swap file.  FYI: the file will be disabled on a reboot.  Run the install script:

cd ~/build_mongodb/mongo
scons --ssl --wiredtiger=off --js-engine=v8-3.25 --c++11=off --disable-warnings-as-errors CXXFLAGS="-std=gnu++11" install

After about 15 minutes, you should see, “scons: done building targets.” — if things went well 😉   You will now have stripped binaries in  “~/build_mongodb/mongo/build/install/bin”

cd ~/build_mongodb/mongo/build/install/bin
ls -l

MORE TO COME on how to install, set the database directory and set other default MongoDB settings.  Also, I will document how to build the MongoDB Tools.  That build requires “Go” which also needs to be compiled 😉




19 thoughts on “MongoDB 3.0.7 on Raspberry Pi 2!”

  1. Pingback: MongoDB on the Raspberry Pi 2

  2. Thanks great tutorial.
    It is the first time i try to compile a program for pi.
    Is this possible to compile this an import the file on the arm architecture ?
    I only have 16GB SD card for my pi and it doesn’t seems to be enough.

    After compiling on my computer and import compiled files to pi it doesn’t work i get bash: /usr/bin/mongod: cannot execute binary file: Exec format error
    Can you share the compiled bin folder ? I tried a lot of time to achieve that and i didn’t succeed

  3. Pingback: MongoDB 3.0.9 binaries for Raspberry Pi 2 (Jessie)

    1. Hi! Please check your typing carefully. NOTE the tilde “~” at the beginning of certain directories. It means to start at the user’s “home” directory and then go from there — so, “~/build_mongodb” === “/home/pi/build_mongodb”.

      Please LMK if that helps.

      – Andy

  4. Thanks andy!!
    However once I run this command ” scons -j 2 –ssl –wiredtiger=off –js-engine=v8-3.25 –c++11=off –disable-warnings-as-errors CXXFLAGS=”-std=gnu++11″ core” It took more than 4 hours so I decided to leave it over night and once I woke up today i found broken pipe from ssh so I assumed that I had finished.. then I the next command which was supposed to be 15 minutes but it has been more than 50 minutes and it does the same things like the previous command and it gives simillar warning which you said we have to ignore..any idea what might be wrong ? Thanks

  5. Hi Andy,

    Thanks for your tutorial.

    However, I was trying to compile a newer version of MongoDB, i.e. 3.2.11, but your instructions does not work anymore, e.g. due to changes to the js-engine.

    Do you have any idea on how newer versions can be compiled?


    1. As you pointed out, there are different dependencies for version 3.2. I have read (somewhere) where MongDB 3.2 was working on an R-Pi BUT did not have the JS shell 🙁 Not that useful for me. I know that MongoDB has an “experimental” branch of version 3.4 for 64-bit ARM Debian/Ubuntu Linux. Unfortunately R-Pi does not yet have official 64-bit OS (Raspbian) support. I did see an announcement of 64-bit SUSE enterprise Linux on R-Pi 3. I’ll investigate more when I have time 😉

  6. Rory Standley

    Managed to get everything as per the tutorial (Thanks!)

    When I run mongod the version is 2.4.10 and not 3.0.9

    Have I missed something or not understanding completely?


    1. Hi Rory, I’m not sure which directions you followed? Also did you install MongoDB at any time using “apt-get”? What does “which mongod” return? Rather than compiling, etc. — why not just download my 3.0.9 binaries? LMK

      – Andy

  7. Pingback: MongoDB 3.0.9 binaries for Raspberry Pi 2 & 3 (Jessie)

  8. Pingback: Install MongoDB in RaspberryOS Jessie or Stretch – Blinking Led

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top