Search code examples
databasecentosmariadbreplicationmaster-slave

Multiple masters to single slave replication


I'm trying to set up replication from multiple clients servers with the same databases(MariaDB 10.3 on centos 7.0, same tables, different content) to a single host server. What are the best practices to do this and what's the easiest way to accomplish that? Should I have multiple MySQL instances on my host machine? or maybe if I have a database called

employees

on the clients, I should save 3 databases named

${hostname}employees 

on my host machine?

Thanks for helping!


Solution

  • You can use replication-rewrite-db=old_name->new_name to write changes to a certain database to a different database on the slave side:

    https://mariadb.com/kb/en/library/replication-filters/#replicate_rewrite_db

    This is also possible on a per-mater basis with multi source replication:

    https://mariadb.com/kb/en/library/multi-source-replication/#replicate-variables

    See also this detailed description of such a multi source rewrite setup:

    https://mariadb.com/resources/blog/multisource-replication-how-to-resolve-the-schema-name-conflicts/