I’ve been asked multiple times if MongoDB 3.2 (or greater) can run on a Raspberry Pi.  The answer has always been “no” — as you need a 64-bit OS to run versions >= 3.2.  Some 64-bit Linux OS’s are starting to become available for R-Pi that, in theory, could run 64-bit MongoDB.  I finally found a configuration that was easy to install and use.  I now have MongoDB 3.2.17 running under Debian buster on a Raspberry Pi 3 — with caveats 😉

The Debian buster release for Raspberry Pi 3 is NOT yet an official image. The hardware still needs the non-free R-Pi firmware to boot. NOTE: this image will NOT work for the new R-Pi 3B+.  There are not a lot of apps available that currently run under buster.  My install is strictly terminal based — or headless (via ssh).  The MongoDB utilities are NOT yet ported.  You can run “mongod”, “mongos” and the “mongo” shell but you’ll need to run utilities such as “mongodump” and “mongorestore” from another computer.

Here is the how-to:

  • get and install the Debian buster image on a microSD Card
  • boot the R-Pi 3 under Debian buster
  • update the OS via “update” and “upgrade”
  • install MongoDB via “apt-get install”
  • configure memory and swap
  • test out your configuration
  • put data into MongoDB database(s)
  • enjoy!

Detailed instructions after the break…


You can get info-on and pointers-to the latest Debian buster image for Raspberry Pi 3 on the Debian Wiki. There is a section that shows where and how to download the current image.  Make sure you use the latest files. As of 02 March 2018:

$ wget https://people.debian.org/~stapelberg/raspberrypi3/2018-01-08/2018-01-08-raspberry-pi-3-buster-PREVIEW.img.xz

You should unzip and burn this image to a microSD card for your R-Pi 3.  The larger and faster, the better.  I used a SanDisk Ultra 32GB microSDHC UHS-I Card You burn this image to the card as “normal” – i.e. like you would for Raspbian or Noobs.

Place the microSD card in your R-Pi 3 and boot.  I assume that your R-Pi is connected to the network via ethernet with DHCP configured.  I believe that Debian buster supports WiFi but that is outside the scope of this simple how-to.

The login (as mentiond on the Debian Wiki) is “root” with password, “raspberry.”  After login, do the customary update/upgrade as “root”:

apt-get update
apt-get upgrade
apt-get dist-upgrade

apt-get install mongodb

There are a few steps to complete before running MongoDB.  MongoDB will run without these but you will probably encounter issues. You will need to do these after every reboot, unless you create a script 😉  So, configure kernel memory allocation per MongoDB recommendations:

cat /sys/kernel/mm/transparent_hugepage/enabled
echo 'never' > /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/enabled
echo 'never' > /sys/kernel/mm/transparent_hugepage/defrag
cat /sys/kernel/mm/transparent_hugepage/defrag

MongoDB needs a fair amount of memory to work with — especially if you want to import or export (or “dump” or “restore”).  Until I created a swap space, I encountered a few hangs and/or significant slow-downs.  The R-Pi 3 only has 1GB of RAM so I suggest making a 2GB swap space:

touch /tmp/theswap
chmod 600 /tmp/theswap
dd if=/dev/zero of=/tmp/theswap bs=1M count=2048
mkswap /tmp/theswap
swapon /tmp/theswap

You can now start-up MongoDB:

service mongodb start

and check status:

service mongodb status

you can stop with:

service mongodb stop

One issue with this combination of MongoDB (3.2.17) and Debian buster OS is that the MongoDB utilities cannot be installed.  You CAN, however, run the utilities on another computer and connect to the R-Pi 3 instance of MongoDB 🙂  This means that you can run “mongoimport”, “mongoexport”, “mongorestore” and “mongodump” from another computer with the “target” being a DB on the R-Pi 3.  Make sure you enable remote connections on the R-Pi.  Edit the /etc/mongodb.conf file and change the “bind-ip” to:

bind_ip =

This will enable connections from any IP address. For example, my R-Pi has the IP address of  I could restore a DB “dump” directory from my Macintosh running MongoDB 3.6 via:

mongorestore --host

You can import a JSON DB from your local host to the R-Pi via:

mongoimport --host --db bldata --collection images --file bl_images.json 

The “mongo” shell works well and I have not experienced any issues:

MongoDB shell version: 3.2.17
connecting to: test
2018-03-02T17:53:34.567-0800 I CONTROL  [initandlisten] 
> show databases;
ProdLogs  0.002GB
bldata    0.560GB
local     0.000GB
> use bldata;
switched to db bldata
> show collections;
> db.stats();
"db" : "bldata",
"collections" : 1,
"objects" : 1637919,
"avgObjSize" : 977.5499405037734,
"dataSize" : 1601147621,
"storageSize" : 584765440,
"numExtents" : 0,
"indexes" : 1,
"indexSize" : 16314368,
"ok" : 1

Note:  Your mileage may vary!  I do NOT recommend using this configuration in a production environment.  Debian buster for Raspberry Pi 3 is NOT officially released.  Do frequent backups!  I’ll try a MongoDB 3.6 source compilation when I have the time and the OS and other software is more mature and stable.

So, here you go.  A 64-bit MongoDB running on an R-Pi 3.  Please LMK if you have questions or issues by leaving a comment.