I have a server with a service that uses mariadb database. This machine is remote and the database is far away in a Galera cluster of two servers.
Currently, this server is connected using an ssh tunnel to one of two clustered servers using the mariadb tcp port.
This service reads from one tableA and write to another tableB, and there are no link or foreign keys between these two tables. So I it is acceptable that tableA can have an older version of tableB or vice versa because as I said there is not link between these data.
I faced a connection issue between this server and my cluster and of course the service was completely down and I was wondering if I can improve the consistency of this service using a local database.
Questions
- Can I set up a slave replication to this remote server even with a galera master?
- Does a slave server accepts writes and synchronize them as soon as possible?
My idea is to have a local database with an asynchronous synchronization.
The service will read from tableA and writes to tableB locally and then its local database will keep tableA synchronized with remote galera Cluster and propagates writes to tableB to galera Cluster. However if the connection between servers fails, I expect the service will keep working with its local copy, accumulate data writes in tableB and restore all sync as soon as the connection comes back.
It is possible? Do I have any other option in my scenario?
A BIT MORE CONTEXT
Just to clarify the scenario, this is why I need this synchronization.
The Galera Cluster is a database for the main application and many application servers work with it with live transactions.
The remote server with its local database to be synchronized, uses the user table of database to authenticate users to specific services, for example there is an exim instance as mail exchange that authenticates users. Moreover this exim stores in a table of local database some logs of received messages.
This is an example why it doesn't care too much if the local database loses sync with the main Galera database. The worst case is that a fresh user just added to Galera database doesn't work with exim service because the user table is not synchronized, but it will work as soon as the sync comes back. The same for email logs, if there is not sync, the main application will not see last logs from exim.
As I said there is no write or fk conflict risk because one table (email log table) is read by Galera and written by remote server and another one (user table) is written by Galera cluster and read by the remote server.
With my current solution (mysql port direct to Galera using ssh tunnel), if the ssh tunnel goes down, exim doesn't work at all because it cannot access the database.