Skip to content

Mongodb pi3

MongoDB on a Raspberry Pi 3

MongoDB requires a 64-bit Raspberry Pi (version 3 or greater) and MondoDB versions strictly at or above 4.4.15.

Newer versions are unsupported in this hardware, and older versions are incompatible with client libraries (e.g. pymongo and mongoose).

These instructions have worked for the Raspberry Pi 3 and older versions of Raspberry Pi OS (e.g. Trixie / Debian 12) on a Raspberry Pi 4.

  1. Install the MongoDB 4.4 GPG key.

Note: Warnings may appear around apt-key, but if an error occurs try this alternative instead: https://itsfoss.com/apt-key-deprecated/

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
  1. Add the source location for the MongoDB packages.
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
  1. Download details of the MongoDB packages.
sudo apt update
Troubleshooting: invalid signatures

The apt update command can fail with an error similar to the following:

The following signatures were invalid: EXPKEYSIG 656408E390CFB1F5 MongoDB 4.4 Release Signing Key <packaging@mongodb.com>

This is due expired GPG keys from Mongo. The issue can be solved by re-importing the key, as shown above.

  1. Install the correct version.
sudo apt install -y mongodb-org=4.4.15 mongodb-org-server=4.4.15 mongodb-org-shell=4.4.15 mongodb-org-mongos=4.4.15 mongodb-org-tools=4.4.15
Downgrading MongoDB

If you have installed a more recent version of Mongo, it may not work. To downgrade, add the --allow-downgrades flag to the command above.

A more recent version of MongoDB may be installed inadvertedly when running apt upgrade, to update system packages.

  1. Verify the installed version.
mongod --version  # Should print 4.4.15
Troubleshooting: Illegal instruction

If you get an error saying Illegal instruction (core dumped), then your MongoDB version is incompatible with your OS.

Make sure that the version you installed is at most 4.4.15, and downgrade if needed (i.e. add --allow-downgrades to the command above and run it again).

  1. Start and enable the MongoDB service at boot.
sudo systemctl daemon-reload
sudo systemctl start mongod.service
sudo systemctl enable mongod.service
sudo systemctl status mongod.service
  1. Hold updates of these packages.
# Prevent automatic updates.
# Otherwise, an update to, for example, `v4.4.30` will break the mongo installation and lead to "Illegal instruction" errors.
sudo apt-mark hold mongodb-org mongodb-org-server mongodb-org-shell mongodb-org-mongos mongodb-org-tools

# Check that the packages are on hold and current version is correct.
dpkg -l $(apt-mark showhold) | grep ^hi