1

I need to implement a mysql multisource replication using mysql >=5.7.11, there are already a certain number of mysql servers running which will become masters for the single slave which is going to be installed soon. The main problem is that each master has same db name and I would like to avoid conflicts in slave and keep each db replica separated. Is there a way to configure the slave to, for example, put master name as prefix of its dbname? I mean something like this : master1.db master2.db

Or do I really need to choose one of the following : - Change db name on masters - Install one slave server for each master ?

Thanks in advance Best regards magowiz

UPDATE : As described in comments, in short :

I also tried something like that, using a solution borrowed by mariadb that I discovered it's not compatible with mysql : mariadb.com/blog/… . I write something like :

[mysqld] 
master1.replicate_rewrite_db=db->db1 
master2.replicate_rewrite_db=db->db2 

with master1 and master2 the two replication channels but it didn't work , I only obtain replication of first instance db to db1 . Is there a way to use replicate_rewrite_db directive on channel/master base ?

The answer I gave to myself it is NO , you can set up multisource replication, you can rename every replicated db on slave specify the mapping but this directive cannot be related to channel, so you need to have unique db names across all masters in order to make multisource replication work.

Currently it seems that mariadb implements this and mysql not.

  • I have question about MySQL version, please provide specific version(s) – Ahmad Abuhasna Jun 26 '16 at 7:58
  • Masters are 5.7.11, slave is 5.7.13 – magowiz Jun 26 '16 at 9:26
  • this link may help you stackoverflow.com/questions/1587896/… – Ahmad Abuhasna Jun 26 '16 at 11:23
  • Yes I already read that link before and also the documentation of the flags proposed but I don't know if you can specify also db master name. In short I have 10 masters, on each master there is one db named foo, they have the same structure and table names, with replication without renaming the 10 db became 1 db on slave, maybe conflicting keys and mixing data. My fear is that if I use the flag you proposed is that I can rename foo to bar on slave but I still have 1 db with mixed data. – magowiz Jun 26 '16 at 11:42
  • I also tried something like that, using a solution borrowed by mariadb that I discovered it's not compatible with mysql : mariadb.com/blog/… . I write something like : [mysqld] master1.replicate_rewrite_db=db->db1 master2.replicate_rewrite_db=db->db2 with master1 and master2 the two replication channels but it didn't work , I only obtain replication of first instance db to db1 . Is there a way to use replicate_rewrite_db directive on channel/master base ? – magowiz Jun 28 '16 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.