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 😉




15 Comments (+add yours?)

  1. alex
    Jan 04, 2016 @ 11:36:21

    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


    • alex
      Jan 05, 2016 @ 02:45:17

      I finally succeed thanks again !!!


    • Martin
      Jun 30, 2016 @ 19:37:44

      Hello Alex, could you please tell me, how did you compile mongodb on your PC ? ..


  2. Andreas Schiffler
    Jan 11, 2016 @ 18:51:39

    Hi Andy, based on your instructions, I got MongoDB 3.0.8 compiled for my pcDunion3nano cluster – steps and patch references are in the article.
    Cheers, Andreas


  3. Thomas Mundt
    Jan 18, 2016 @ 06:51:57

    Hi Andy!

    Thank you so much for this great article.

    As Alex I would like to ask if you could share the compiled data?


  4. Gerald Stockinger
    Feb 22, 2016 @ 12:01:26

    Me too, pls. share!


  5. andy
    Feb 22, 2016 @ 12:19:35

    Binaries + instructions for 3.0.9 are here:

    – Andy


  6. Masinde
    Mar 02, 2016 @ 10:22:40

    Once I reach it does not work…

    -bash: cd: /home/pi/build_mongodb/mongodb: No such file or directory


    • andy
      Mar 02, 2016 @ 10:28:55

      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


  7. Masinde
    Mar 02, 2016 @ 22:18:19

    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


  8. Andrea
    Dec 21, 2016 @ 06:53:46

    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?



    • andy
      Dec 21, 2016 @ 14:19:03

      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 😉


  9. Andrea
    Jan 02, 2017 @ 04:40:46


    Let me know if you have any news.



Leave a Reply