
[UPDATED 05 Jan 2020] There is now an official Ubuntu 18.04 LTS image for Raspberry Pi 3. Install the arm64 image following instructions on the Ubuntu Wiki. You can then install MongoDB 4.2.x per this blog entry. NOTE that I still recommend adding swap space – as mentioned below.
[UPDATED 03 Nov 2019] Looking to run MongoDB 4.2.x on a Raspberry Pi 4? Check out this post. It is also possible to run Ubuntu 18.04.2 (ARM 64-bit) directly on the Raspberry Pi 3. You can read more about this and get SD Card images from the Ubuntu wiki. I am using the server version of “Ubuntu Classic” as opposed to the new “Snappy Ubuntu Core.” MongoDB has an official release of MongoDB 4.0.6 4.0.11 for “Ubuntu 16.04 Linux 64-bit ARM 64.” I will show how to install this version of MongoDB under Ubuntu 18.04 on the Raspberry Pi 3B+. These instructions should work for any version of R-Pi 3 but I have only tested on my Raspberry Pi 3B+.
Download the ARM64 image for the Raspberry Pi 3 as instructed on the Ubuntu Wiki. The download link as of August 2019 is Ubuntu Server image for Raspberry Pi 3 (440MB compressed). This is an R-Pi image that needs to be written to the Micro SD Card – as usual. It is important to read the install directions on the wiki!
Note that you might see key-exchanges going on at first boot. The file system also auto-expands – so give it some time for first boot. The login/password is ubuntu/ubuntu. You will be prompted to change. “raspi-config” does NOT work! I am using the ethernet connection so no network configuration is required. WiFi is supported under Ubuntu Server 18.04 but is not the easiest to setup — and is beyond the scope of this post — read the docs π
After a successful boot, make sure your OS is up to date:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Here are my versions of name, kernel & OS info:
$ uname -a
Linux ubuntu 4.15.0-1041-raspi2 #44-Ubuntu SMP PREEMPT Wed Jul 3 15:45:20 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
OK, let’s install the MongoDB Community Server and utilities.
Import the public key for the Package Management System:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Recent MongoDB docs (August 2019) say to use this method to get key, though either way should work:
wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -
Add a MongoDB list file from the “xenial” branch as MongoDB 4 is not yet in the “bionic” branch. Update the packages list. Install any updates and then install MongoDB. Note that “lincurl4” replaced “libcurl3” in Ubuntu 18.04. We need to revert to “libcurl3” for MongoDB 4.0 to install correctly. A simple “apt-get install” will do the trick.
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libcurl3
sudo apt-get install -y mongodb-org
You can check versions installed:
mongod --version
db version v4.0.11
git version: 417d1a712e9f040d54beca8e4943edce218e9a8c
OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1604
distarch: aarch64
target_arch: aarch64
mongo --version
MongoDB shell version v4.0.11
git version: 417d1a712e9f040d54beca8e4943edce218e9a8c
OpenSSL version: OpenSSL 1.0.2n 7 Dec 2017
allocator: tcmalloc
modules: none
build environment:
distmod: ubuntu1604
distarch: aarch64
target_arch: aarch64
Before running MongoDB, I add 2GB system swap space. This can slow things down considerably but I have, on occasion, had issues with some utilities such as “mongoimport” if I did not add space. Most of the time, swap space is not used and doesn’t impose a performance penalty. You could try running MongoDB (mongod, mongo) without swap but be aware of this swap option if things seem to hang.
sudo dd if=/dev/zero of=/swapfile.img bs=1M count=2048
sudo mkswap /swapfile.img
sudo swapon /swapfile.img
cat /proc/swaps
You can start MongoDB and check its status:
sudo service mongod start
sudo service mongod status
Run the MongoDB shell:
mongo
I have run much of the MongoDB Javascript Test Suite as found on GitHub without errors or issues. This does not mean this write-up will work for you. This install and configuration works for me BUT I do regular backups/exports (dumps and JSON) that I could migrate to another system – if ever needed. As always, your mileage may vary! Please LMK in comments if you have questions or issues…
Hey, is this version of unbuntu terminal only.
Also, am I able to somehow get a gui or if not can I open multiple terminals?
The R-Pi 64-bit version currently available on the Ubuntu Wiki is a *server* (no GUI) image. I connect “multiple terminal” sessions by using “ssh” to login via another computer — with multiple windows.
— Andy
Hi,
Thanks for the great post. Quick question. Why would you not recommend running this in a Prod environment ? Is the the configuration or the actual Mongo 64bit implementation ?
Much appreciated
MongoDB has released MongoDB community edition (4.0.9) for Ubuntu 16.04. Ubuntu 18.04.2 is a server-only release for ARM64. You also need to downgrade a library: libcurl3. AFAIK, everything works fine but I want to warn folks that there *may* be issues and/or some releases from MongoDB or Ubuntu may change and cause issues — an unexpected library update in Ubuntu 18.04, for example.
Thank you so much! I’ve been struggling with this installation for 2 days.
This tutorial works on Raspberry Pi 3 Model B, with Ubuntu MATE Bionic (18.04) as the OS.
so waiting ubuntu for rpi 4? γ½(βΒ° )δΊΊ( Β°β)γ
or, maybe a 64-bit Debian Buster π
Much Thanx for this guide
d(^.^)b
pi@raspberrypi:~ $ sudo apt-get install -y mongodb-org
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package mongodb-org
Hmmm – I checked again. Ensure you have added “public key” and “list server” per the blog post AND that you have done the “sudo apt-get update” after doing this? You might also check out what packages are available with a “sudo apt-cache search mongodb”
– Andy
I am having the same issue as Paulo.
Paulo, Nick, I just did a new install of Ubuntu Server on my R-Pi 3 and installed MongoDB 4.0.11 – from scratch – per my instructions above. Please try again? Note that the latest version of MongoDB for ARM64 is now 4.0.11.
Hi,
Do you try to install/compile mongodb 4.0/4.2 on raspberry pi 4 running with Debian buster? Thanks beforehand for answer.
MongoDB 4.x requires a 64-bit OS. Raspbian Buster is 32-bit. I think we’ll see some 64-bit ARM Linux variants for R-Pi 4, soon π
Everything went perfect until the last line…
The response was
sudo apt-get install -y mongodb-org
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package mongodb-org
Any ideas?
Is there already a solution for unable to locate package mongodb-org?
Hi – you can now install Ubuntu 18.04 and MongoDB 4.2 on the R-Pi 3. Check out the blog entry update. LMK how it goes π
hey Andy, I tried this yesterday, but than I get……… N: Skipping acquire of configured file ‘multiverse/binary-armhf/Packages’ as repository ‘http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 InRelease’ doesn’t support architecture ‘armhf’
ubuntu@ubuntu:~$ sudo apt-get install mongodb-org
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Unable to locate package mongodb-org
Do you know a fix?
/Henk
Henk, Check that you have installed 64-bit Ubuntu – for arm64 (NOT armhf). On Ubuntu Wiki: 18.04 LTS: ubuntu-18.04.3-preinstalled-server-arm64+raspi3.img.xz (4G image, 441MB compressed) Check that you have added the correct MongoDB repository before the “apt-get install”. Get Community Server – version 4.2.2 for “Ubuntu 18.04 Linux 64-bit ARM 64” from MongoDB: https://www.mongodb.com/download-center/community Make sure you have installed the correct repository public key: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/
My linux version on a RPI3……. E: Unable to locate package mongodb-org
ubuntu@ubuntu:~$ ^C
ubuntu@ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
ubuntu@ubuntu:~$ cat /etc/os-release
NAME=”Ubuntu”
VERSION=”18.04.3 LTS (Bionic Beaver)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 18.04.3 LTS”
VERSION_ID=”18.04″
HOME_URL=”https://www.ubuntu.com/”
SUPPORT_URL=”https://help.ubuntu.com/”
BUG_REPORT_URL=”https://bugs.launchpad.net/ubuntu/”
PRIVACY_POLICY_URL=”https://www.ubuntu.com/legal/terms-and-policies/privacy-policy”
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
ubuntu@ubuntu:~$ ^C
ubuntu@ubuntu:~$ hostnamectl
Static hostname: ubuntu
Icon name: computer
Machine ID: 6e10edb20ed548d49a26d948245e22f4
Boot ID: 904e32c5d76d42c4bd65ec6d2e8bce28
Operating System: Ubuntu 18.04.3 LTS
Kernel: Linux 4.15.0-1052-raspi2
Architecture: arm
Hey Andy, thanks a lot for your help and indeed I installed the wrong Ubuntu version and now, after I installed the right one, it worked fine just following your instructions π