Redundant mirroring of two mongodb servers I have built a laravel web application for a client of mine which runs on a dedicated server.

The system is a booking system, and the client needs access to this at any time during the work day. So he came to me with "What happends when I loose my internet connection?".

The solution I am going to implement for my client is that I will set up a Raspberry Pi that will run the same web application locally at their shop. So if the loose their internet connection, they can access the web application served from the Raspberry instead.

However, what I now need, is that the Raspberry at all times when it has internet connection, syncs up with the latest information about booked appointments from the live server. And when the internet connection goes down and they use the local web application to book new appointments, then I need the raspberry to tell the live application about those new hours that are booked when the internet connection comes back on.

I have been looking at replication-sets, but it looks like I need a third server to be a judge here for the system to work in such a way that the slave gets writing capabilities to its mongdb server.

Can anyone help me out with any ideas here?

Thanks.
You'll need to find a different approach as there are a few major assumptions that won't work.


  The solution I am going to implement for my client is that I will set up a Raspberry Pi that will run the same web application locally at their shop


Raspberry Pi 1/2 (with 32-bit ARM CPU) is not an officially supported platform for MongoDB, nor is it likely to be. The MMAP storage engine (which is the only 32-bit storage engine available for MongoDB) also has a limitation of ~2GB of data on 32-bit deployments as per the underlying MMAP API. There are some community builds which might be passable for development use, but I wouldn't recommend for client/production work.

There is progress toward experimental 64-bit ARM support in the MongoDB 3.3 development branch, so support for Raspberry Pi 3 or newer is an eventual possibility. If you want to run a full-featured web application with minimal compatibility hassle, a small form factor 64-bit x86 computer is a better bet for current deployments.


  So basically, I need the Pi to be a slave, which becomes master when no inet, and writes to the master when the inet is back up


This isn't a supported replication model as at MongoDB 3.2; a replica set can only have a single primary which accepts writes. An offline/disconnected secondary would be read-only.


  "What happens when I lose my internet connection?".


Some other approaches to consider:


Set up a backup internet connection. This will minimise complexity since you don't have to worry about conflicting versions of data or applications.
Look into a different local storage solution for offline writes which is also more suited for embedded / low power devices (for example, SQLite). You'll have to work out how to resolve data editing conflicts between local &amp; web data, though.