How to install a MongoDB replica set, across several Raspberry Pis ?


This tutorial describes a process used to install a MongoDB replica set on two Raspberry Pi devices. It can also be used for installing on three or more devices.
The choices made here are not the only ones possible. Feel free to try different options.

I will set two data bearing nodes on each Pi (i.e. Raspberry Pi), one attached to each USB3 port. In other words, one mongod server will handle the storage device plugged on one USB3 port. I also set one arbiter node, alongside one of the data bearing node on one of the Pis. This arbiter node will have its own mongod server but will not have a storage device. On the communication level, I run the data bearing nodes on ports 22330 and 22331 and the arbiter on port 22332.

I use two devices, of the same model: Raspberry Pi 4 Model B 2GB RAM.

Here is the procedure to prepare each machine.

Let us start by choosing the operating system we want to use. This tutorial offers two options, both with a 64 bit OS. Click according to your preference.