1
votes

I have two servers (A & B), with MySQL Enterprise Edition 5.7.21, and RHEL 7.4 version. I want to replicate one table from Server A with a table with different name to Server B. In same time i want another table from Server B to replicate to an another table to Server A, like two master-slave:

masterA -> SlaveB

masterB -> SlaveA

I know how create replication. My Question is if i can replicate one table to another table name. For Example:

ServerA: User: myschema tables: t1, t2

ServerB: User: myschema tables: t3, t4

I want to replicate: myschema.t1 => myschema.t3 (master Server A, Slave Server B) and myschema.t4 => myschema.t2 (master Server B, Slave Server A)

Is that possible?

I want the result to be the same data in a combination of tables:

--serverA: select * from t1 union select * from t2

is equal to

--ServerB: select * from t3 union select * from t4.

Info about my.cnf in both servers, for only one replicate.

ServerA: master

  • server-id=1
  • log_bin=/storage/mysql/mysql-repl.log
  • relay-log=/storage/mysql/mysql-relay-repl.log
  • binlog_do_db=test
  • replicate-do-db=test binlog-ignore-db=information_schema
  • replicate-ignore-db=information_schema auto-increment-increment=2
  • auto-increment-offset=1
  • bind-address=10.124.xxx.xx

ServerB: slave

  • server-id=2
  • log_bin=/storage/mysql/mysql-repl.log
  • binlog_do_db=test
  • replicate-do-db=test
  • replicate-do-table=test.t1
  • binlog-ignore-db=information_schema
  • replicate-ignore-db=information_schema
  • auto-increment-increment=2
  • auto-increment-offset=2
  • bind-address=10.124.xxx.xx
1
For what purpose? Would a VIEW suffice?ceejayoz

1 Answers

1
votes

No it's not possible, you always replicate between tables with the same name because you are replaying the log from one server on it's slave.

Since you seem to be writing to both servers and into different tables, why don't you just have tables t1 and t2 on both and have your application write t1 data to one server and t2 data to the other server and replicate master-master?