Have a Raspberry Pi 4 with 4GB or 8GB of RAM and want to run the popular noSQL database, MongoDB? Read on for installing and running the latest 64-bit versions of MongoDB and Ubuntu 20.04.(more…)
[Updated: 28 Feb 2019] Time to lose this post! The MongoDB 3.4 binaries have vanished from the Debian buster ARM repository BUT I now have MongoDB 4.0.6 running under Ubuntu 18.04 on a Raspberry Pi 3B+ Check out this new post!
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.4.18 running under Debian buster on a Raspberry Pi 3 — with a few 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: the latest image WILL work for the new R-Pi 3B+. There are a growing number of apps that run under buster 🙂 My install is strictly terminal based — or headless (via ssh). The MongoDB utilities are also (now) ported. You can run “mongod,” “mongos,” the “mongo” shell and utilities such as “mongoimport,” “mongodump,” and “mongorestore” from the local command line or via ssh.
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)
I use a MongoDB database to analyze data extracted from logs on Linux production servers that handle hundreds of thousands of users per day. I also have databases that I use for research topics – oriented around K-12 education. I have pulled data from The British Library and various datasets from the Europeana Collections.
I’ve blogged before on MongoDB running on a 4 ODROID C2 SBC Cluster with external SATA drives — see this post. I had tried both Arch and Ubuntu flavors of Linux. I pointed out then that MongoDB had an official Enterprise Server Version 3.6 for Ubuntu 16.04 ARM 64. MongoDB Release 4.0.6 is now available for download (as of 15 February 2019). Please check the license terms of the “Enterprise Server Version”. There is also a “Community Server” version that might better meet your needs and/or avoid restrictions. The Community Server install is what is described in this post.
OK it’s great that MongoDB has an official version for “Ubuntu 16.04 Linux 64-bit ARM 64.” I, however, am running the latest Ubuntu OS for ODROID C2 – “Ubuntu 18.04.2 LTS (Bionic Beaver).”
OK, here is the quick and simple way to install the latest MongoDB on your ODROID C2 running Ubuntu 18.04…
The main operating system for Raspberry Pi, Raspbian, continues to evolve. The latest version as of August 2017 is “Raspbian Stretch” — based upon the current stable version of Debian 9. The previous version was known as “Raspbian Jessie”. One difference between versions is OpenSSL libraries. OpenSSL is a general purpose cryptography library that provides an open source implementation of the Secure Sockets Layer (SSL). My previous builds of MongoDB relied on the older library. As a result, my previous binaries for 3.0.14 and 3.0.9 do not run under Raspbian Stretch. Given this change as well as other changes to MongoDB source and newer compilers, I could no longer compile MongoDB 3.0.14 with SSL.
After a few source tweaks and use of various compiler flags, I have manged to compile MongoDB core apps and tools. These binaries do NOT support SSL and only run under Raspian Stretch on a Raspberry Pi 3. [UPDATE — 2018 Mar 22] I have confirmed that these binaries work on the latest Raspberry Pi 3 Model B+ with the March 2018 version of Raspbian.
I’m a big fan of MongoDB but contrary to its “humongous” orientation, I like to think small as in ARM-based SBCs like the Raspberry Pi or ODROID-C2 and DBs under a terabyte 😉 You can get a lot of power out of tiny inexpensive computers and USB disk drives! You can find my blog entries, below, for getting 32-bit MongoDB 3.0 working on R-Pi and 64-bit, MongoDB 3.2 working under ArchLinux ARM on ODROID-C2.
I had seen MongoDB community requests for a 64-bit ARM version and even a mention that there was “official experimental” development going on – including the efficient WiredTiger storage engine. I recently perused the MongoDB Community Edition documentation for version 3.4 and saw a download option for “Ubuntu 16.04 Linux 64-bit ARM 64” on the MongoDB Download Center. Ubuntu 16.04 is the default Linux supplied with the ODROID-C2 🙂 You can purchase a bare ODROID-C2 for US$40 at Hardkernel. Micro SD card or EMMC module with preinstalled Ubuntu Linux is extra.
Click more for installation instructions.
I use MongoDB as my database of choice as you can tell by my blog entries. Under current Raspberry Pi OSs, MongoDB is limited by 32 bit binaries. Databases are restricted to 2GB.
The Raspberry Pi 3 sports an ARMv7 processor that supports 64 bits. At this time (May 2016) there is no official OS support for 64 bits. Raspbian and Arch Linux are only available with 32 bit support. I expect that we WILL see 64 bit support sometime in the future 😉
While waiting, I looked around and found MongoDB
3.2.6 3.2.10 in the Arch Linux ARM aarch64 package repository. I also found out that the ODROID C2 single board computer supports aarch64. This SBC costs $40 and has better specs (for my DB purposes) than the R-Pi 3. It has a 4-core ARMv8 processor running at 2GHz, 2GB of RAM and gigabit ethernet. It also supports WAY fast eMMC Flash storage in addition to Micro SD. Android and Ubuntu are the officially supported OSs but Arch Linux ARM (64 bit) can be installed as well.
[UPDATE: 23 Mar 2017] If you prefer to use the default Ubuntu Linux for ODROID C2 as opposed to Arch, you can now install official MongoDB 3.4. See this blog post.
I’ve written about getting MongoDB running on the Raspberry Pi 2. View my other posts where you can get binaries (3.0.9) or learn how to compile from scratch (3.0.7). The mongo shell works great but you may want/need to code in Python, especially for device control or data logging, etc.
PyMongo is a Python distribution containing tools for working with MongoDB, and is the recommended way to work with MongoDB from Python. You can either use Python 2 or Python 3. Python 3 did not come on the minimal Raspbian Jessie image but can be installed using “sudo apt-get install python3”.
To install the appropriate PyMongo for MongoDB 3.0.x you can do the following from the command line. Note you could use “python3” where I use “python”, depending on your preference. I normally use the default Python 2.7.
Instructions after the break: (more…)
I’ve received feedback that some folks are having problems compiling MongoDB 3.0.7 per my instructions AND it takes a long time 😉
MongoDB 3.0.9 just became available but needs quite a few changes to source in order to compile on the Raspberry Pi. I worked through MongoDB build scripts for ARCH ARM Linux and managed to “translate” for Raspbian (Jessie) Linux on the R-Pi 2. Rather than creating patch files and writing instructions for building from source, I am providing my compiled binaries. PLEASE do not post links to my binaries! Feel free to download for personal use from this site.
[NOTE: I have compiled version 3.0.14 and created binaries for Raspbian Jessie for the R-Pi 2 & 3. NEW: I have also created 3.0.14 binaries for the R-Pi 3 running Raspbian Stretch that will also work on the new R-Pi 3B+. I have confirmed that the instructions in this blog entry work with the new binaries.]
I 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.
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