Add MongoDB 4.2 ARM64 builds for Raspberry Pi OS 64 bit (Debian Buster)

Raspberry Pi OS now has an ARM64 version
https://downloads.raspberrypi.org/raspios_arm64/images/
more info: https://raspberrypi.stackexchange.com/questions/113047/run-64-bit-raspberry-pi-os-beta-test-version

I would love to run MongoDB 4.2 on RaspberryPi OS (arm64) 64 bit.
Raspberry Pi OS is based on Debian.

Currently MongoDB is only building ARM64 for older versions of Ubuntu. Ubuntu is a beginner focused OS, while more experienced Linux users generally use Debian.
http://repo.mongodb.org/apt/ubuntu/dists/bionic/mongodb-org/4.2/multiverse/

Please add MongoDB 4.2 ARM64 builds for Debian 10 Buster (that will work on Raspberry Pi OS 64 bit)
http://repo.mongodb.org/apt/debian/dists/buster/mongodb-org/4.2/main/

Having builds for ARM64 Debian 10 Buster will make it easier for Raspberry Pi OS industrial engineers and students to deploy MongoDB applications on RbPi and focus on MongoDB applications.
Currently there’s additional friction in that we’d have to manually build MongoDB on Debian 10 ARM64, every time there’s an update. Also the uncertainty regarding whether it will work or not further discourages MongoDB adoption.

A lot of companies focus on students, because they’re the next generations of engineers. RaspberryPi OS is based on Debian and is the OS recommended by the RaspberryPi Foundation. They renamed it from Raspbian (a play on the words Raspberry and Debian) to “Raspberry Pi OS” to make it obvious that it’s the main (most supported, recommended/updated etc) OS. MongoDB would be wise to add builds for this!

MongoDB 4.2 ARM 64 builds for Debian 10 Buster that works on Raspberry Pi OS 64 bit, come on, let’s go!

1 Like

Hi @Joshua_Maserow -

Adding a new officially supported platform is a fairly significant undertaking for us. We typically only add new platforms in new releases, so we are very unlikely to add support for Debian 10 ARM64 for v4.2. We don’t currently have Debian 10 ARM64 on the v4.4 roadmap either, and given that v4.4 is coming soon, I don’t expect that to change.

I have flagged your request as we consider the roadmap for the next version of MongoDB. That though is unlikely to improve the situation on Raspberry Pi in the near term, unless that results in a further decision to backport that support to v4.4, which I think is unlikely.

In your post you said that there was additional friction to manually build MongoDB on Debian for ARM64. Is that due to the performance of the Raspberry PI as a build host? Would it be helpful if we provided some instructions on how to do a Debian 10 ARM64 targeted build on a Debian 10 x86_64 system?

Thanks,
Andrew

1 Like

I would be very interested in some instructions for a Debian 10 ARM64 targeted build to get mongodb 4.2+ running on my Raspberry Pi 4.

@Kristof_Moors - Are you interested in doing a native build on the RPi4, or a cross build from a Debian 10 x86_64 machine?

@Kristof_Moors (and CC @Joshua_Maserow) -

Here are instructions for doing a Debian 10 ARM build of MongoDB Community v4.2.8 for RPi4 from a Debian 10 x86-64 machine. Note that since this is built from the community sources, no enterprise features will be available:

$ sudo apt-get install gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu
$ sudo dpkg --add-architecture arm64
$ sudo apt-get update
$ sudo apt-get install libssl-dev:arm64 libcurl4-openssl-dev:arm64

$ git clone -b r4.2.8 https://github.com/mongodb/mongo.git
$ cd mongo

# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt

$ python3 buildscripts/scons.py --ssl CC=/usr/bin/aarch64-linux-gnu-gcc-8 CXX=/usr/bin/aarch64-linux-gnu-g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" ./mongo{,s,d}

The above build took about 25 minutes for me on a 16 vCPU Debian 10 x86_64 machine, so be prepared to wait a little while. By default it will use all cores to build, so if you want to not saturate your machine, you can add an explicit -j N argument to limit to N cores.

If the build completes OK, you will find mongo, mongod, and mongos binaries in the root of the tree. The binaries will be very large because they are unstripped, but you can strip them if you want. You can then transfer what you need to the RPi4. I don’t have one to test on, so I can’t promise the binaries work: please try them out and let us know.

If you want to try building on the RPi4 itself as a native build, you can simplify the above instructions to something like the following, which is untested:

$ sudo apt-get install gcc-8 g++-8
$ sudo apt-get install libssl-dev libcurl4-openssl-dev

$ git clone -b r4.2.8 https://github.com/mongodb/mongo.git
$ cd mongo

# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt

$ python3 buildscripts/scons.py --ssl CC=gcc-8 CXX=g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" ./mongo{,s,d}

But I have no idea how long that will take to build, and I don’t have an RPi4 on which to try it out.

Hope this helps,
Andrew

PS Any reason you want v4.2 not the newly released v4.4? The v4.4 release has some build improvements that can make the process a little simpler. Please let me know if you want v4.4 specific instructions.

2 Likes

I would like to do a native build, if possible.

@Kristof_Moors - OK, I included instructions for that in my most recent reply as well. I don’t have an RPi4, so I can’t actually test it, but it looks pretty reasonable. Please give it a try and let me know if it works for you. Note that depending on the speed and parallelism of the RPi4 it may take a long long time.

Thank you for the instructions. I don’t want 4.2 specifically, but I would like to run something on my RPi4 that requires v4.2 or higher. If you could share instructions for 4.4, I would be happy to try it. Do you have an estimate for the total file size of the (native) build?

The instructions for v4.4 would be very similar, so I’m just manually making adjustments here and apologies in advance for any errors, but the cross build would look like:

sudo apt-get install gcc-8-aarch64-linux-gnu g++-8-aarch64-linux-gnu
$ sudo dpkg --add-architecture arm64
$ sudo apt-get update
$ sudo apt-get install libssl-dev:arm64 libcurl4-openssl-dev:arm64

$ git clone -b r4.4.0 https://github.com/mongodb/mongo.git
$ cd mongo

# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt

$ python3 buildscripts/scons.py --ssl CC=/usr/bin/aarch64-linux-gnu-gcc-8 CXX=/usr/bin/aarch64-linux-gnu-g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" --install-mode=hygienic --install-action=hardlink --separate-debug archive-core{,-debug}

And the native build would look like:

sudo apt-get install gcc-8 g++-8
$ sudo apt-get install libssl-dev libcurl4-openssl-dev

$ git clone -b r4.4.0 https://github.com/mongodb/mongo.git
$ cd mongo

# Consider using a virtualenv for this
$ python3 -m pip install --user -r etc/pip/compile-requirements.txt

$ python3 buildscripts/scons.py --ssl CC=gcc-8 CXX=g++-8 CCFLAGS="-march=armv8-a+crc -mtune=cortex-a72" --install-mode=hygienic --install-action=hardlink --separate-debug archive-core{,-debug}

The only real changes here in, in both cases, are to the build system flags on the last step. The new flags are as follows:

  • --install-mode=hygienic: Uses an autoconf like layout. You can control where files are installed to with the DESTDIR and PREFIX arguments to SCons. So scons ... DESTDIR=$HOME/tmp PREFIX=/usr/local ... would do what you expect.

  • --install-action=hardlink: Uses hardlinks when installing files to DESTDIR/PREFIX to avoid extra time spent copying.

  • --separate-debug: Enables automatically stripping debug information out into separate .debug files and packaging them into -debug tarballs.

Then the new target names archive-core and archive-core-debug will produce tgz files under the build directory containing the server and shell binaries and .debug files respectively. There are several different targets depending on what you want to build. Generally, they look like [install|archive]-x[-debug] for x in shell (the mongo shell), mongod (just the mongod server), mongos (just the mongos server), servers (both mongod and mongos), and core (servers and shell).

Regarding binary size, the binary packages probably aren’t that large, but the debug info packages can be several gigabytes. So you are going to need some space, probably 10-20 GB for the whole build. This is one of the reasons I’m suggesting a cross build might be a good idea.

You could also experiment with the --link-model=dynamic flag which might result in a somewhat smaller footprint. Note that builds made with this flag are not production quality - they are primarily used for testing. But Debian 10 ARM / RPi4 isn’t a supported platform anyway.

3 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.