I
I
Igor Vedenov2021-08-18 14:13:41
MySQL
Igor Vedenov, 2021-08-18 14:13:41

How to synchronize two mysql databases?

There are 2 servers. On one, the application is deployed and writes everything in mysql, there is one plate in the database with logs. It is necessary to unilaterally synchronize this plate with another server where self-written analytics is spinning. The tablet on the first server has a rotation of 1 month and after that the old one is deleted, on the 2nd server you need to keep the log for at least a year (indefinitely shorter). How to set it all up? As far as I understand, one-way synchronization is needed. It is optimal to make the schedule even more (enough once a day at night).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Slava Rozhnev, 2021-08-18
@rozhnev

Write a script in any programming language you know and run it on a schedule

L
Lazy @BojackHorseman MySQL, 2021-08-18
Tag

statement based master slave replica.
on the slave triggers are prohibited from deleting.
after a year, the slave is cleaned by hand.
I can't understand one. why remove something from production at all.

A
Akina, 2021-08-18
@Akina

If both MySQL servers are mutually accessible, then the FEDERATED Storage Engine can be used to solve the problem .
On "another server where self-written analytics is running", restart MySQL by enabling the FEDERATED Engine. Next, create a connection ( CREATE SERVER ), create a copy of the remote table on this server - and simply copy records from it for the last month. Or without a server - right when creating a table, specify the connection parameters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question