MongoDB on the Raspberry Pi 2


Raspberry Pi 2 After purchasing a Raspberry Pi 2, I decided to move some of my projects to it.  I also added an external 2.5 inch USB drive via a USB hub.  I store various sensor information in a MongoDB database and needed everything to run on the R-Pi 2.  I chose to stick with the well-supported Debian Linux port, Raspbian Wheezy, as opposed to ARCH Linux that I used on my old R-Pi B+, as the R-Pi 2 has a quad core ARMv7 processor that requires a new kernel.

UPDATE (30 January 2016):  I’ve compiled MongoDB 3.0.9 and tools for R-Pi 2 Raspbian (Jessie).  Check here.

UPDATE (25 December 2015): Instructions for compiling MongoDB 3.0.7 and tools for R-Pi 2 running Raspbian Jessie are now available.  Check here.

UPDATE (8 November 2015): If you are running Raspbian Jessie, you can “apt-get install mongodb”.  This will result in an install of MongoDB v2.4.  Good enough for most uses and you get a working mongo shell 😉  If you want MongoDB v2.6.3, read-on!

I was back to hunting for a compatible MongoDB binary — or instructions on how to compile from source.  Research showed that MongoDB does not compile for ARM after version 2.6.3 🙁  Searching the ‘net led me to the “facat’ blog.” This blog shows how to cross-compile MongoDB 2.6.3 for ARM.  Precompiled binaries are also available.  NOTE that the mongo shell does NOT work correctly on the R-Pi.  “mongod”, the server, does work fine and can be accessed programmatically or via a mongo shell from another (non-R-Pi) computer.  I use “mongo” on my Mac to connect to “mongod” running on the R-Pi 2.

more after the break

I created a “mongodb.conf” in “/etc” that configures MongoDB to use a data directory and log file on my USB-connected hard drive which is mounted on “/mnt”.  The config file:

$ cat mongodb.conf
destination: file
path: "/mnt/log/mongodb/mongodb.log"
logAppend: true
quiet: true
dbPath: "/mnt/DBdata"
enabled: true
fork: true
bindIp: XXX.0.0.XXX
port: 27017

I invoke mongod with “mongod -f /etc/mongodb.conf”  I connect via mongo on my Mac with “mongo −−host XXX.0.0.XXX”  You can get a zip file of all of the MongoDB executables here. NOTE again that the MongoDB shell, “mongo” does not work correctly on the R-Pi and throws a segment fault on many operations.

I also recommend Robomongo,  a shell-centric cross-platform open source MongoDB management tool (i.e. Admin GUI). Robomongo embeds the same JavaScript engine that powers MongoDB’s mongo shell.  It is available for Mac, Windows and Linux.

9 Comments (+add yours?)

  1. Tomek
    Aug 04, 2015 @ 04:40:40

    Very interesting 🙂 but is MongoDB on R-Pi2 limited to around 2GB of data ?


  2. andy
    Aug 31, 2015 @ 14:25:51

    Yes, given the 32-bit nature of the R-Pi’s ARM CPU, databases are limited to 2GB. I create multiple databases for large data needs and use Javascript to query and combine result sets.


  3. William Lucas
    Nov 08, 2015 @ 09:49:42

    Although yes they may be limited in their use, especially when only using one. I look at it this way. It’s an embedded client that can be connected to a server. The server being the one with more compute and capacity. I have had no trouble with the limit storage since the data can be synced and flushed daily/weekly/monthly.


  4. Thomas Mundt
    Dec 16, 2015 @ 01:54:55

    With the new Raspbian Jessie, is it possible to get a new MongoDB (version 3.x.x)?


    • andy
      Dec 17, 2015 @ 10:30:15

      Update 22 Dec 2015: OK you CAN compile MongoDB 3.0.x on a R-Pi 2 running Jessie. Instructions coming soon… The WiredTiger engine does not work under 32-bit ARM, however.

      MongoDB 3.x requires a 64-bit processor which the R-Pi 2 does NOT have (Raspian Jessie is a 32-bit OS). I also believe MongoDB 3.x only runs on Intel processors, currently.


  5. Pradip
    Oct 08, 2016 @ 03:00:49

    Robomongo is not working.

    I installed it with this guide

    It gives following error:
    bash: /usr/bin/robomongo/bin/robomongo: cannot execute binary file: Exec format error

    I think this error is because the robomongo does not support arm.
    Please help.


    • andy
      Oct 08, 2016 @ 12:24:15

      Pradip, As you noted Robomongo does not run on ARM under Raspbian. I use Robomongo on my Mac to connect remotely into my MongoDB DBs on my R-Pis 😉 Otherwise I just stick to the mongo shell on R-Pi.


  6. Mark
    Dec 22, 2017 @ 13:11:43

    This looks promissing –

    A web site devoted to running mongdb on Pis.

    Good luck!



    • andy
      Dec 22, 2017 @ 13:43:44

      Note that this site points to 64-bit MongoDB binaries that run on an R-Pi 3 under OpenSUSE Leap 42.2


Leave a Reply