简体   繁体   English

MySQL复制大师-大师

[英]MySQL Replication master - master

I have two servers (A & B), with MySQL Enterprise Edition 5.7.21, and RHEL 7.4 version. 我有两台服务器(A和B),分别为MySQL Enterprise Edition 5.7.21和RHEL 7.4版本。 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: 我想从服务器A复制一个表,并使用与服务器B不同的名称。同时,我希望服务器B的另一个表复制到服务器A的另一个表,例如两个主从服务器:

masterA -> SlaveB masterA-> SlaveB

masterB -> SlaveA 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 ServerA:用户:myschema表:t1,t2

ServerB: User: myschema tables: t3, t4 ServerB:用户:myschema表: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) 我要复制:myschema.t1 => myschema.t3(主服务器A,从属服务器B)和myschema.t4 => myschema.t2(主服务器B,从属服务器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 --serverA:从t1联合中选择*从t2中选择*

is equal to 等于

--ServerB: select * from t3 union select * from t4. --ServerB:从t3联合中选择*,从t4中选择*。

Info about my.cnf in both servers, for only one replicate. 两台服务器中有关my.cnf的信息,仅可复制一次。

ServerA: master ServerA:

  • server-id=1 服务器ID = 1
  • log_bin=/storage/mysql/mysql-repl.log log_bin = /存储/mysql/mysql-repl.log
  • relay-log=/storage/mysql/mysql-relay-repl.log relay-log = /存储/mysql/mysql-relay-repl.log
  • binlog_do_db=test binlog_do_db =测试
  • replicate-do-db=test binlog-ignore-db=information_schema 复制数据库=测试binlog-ignore-db = information_schema
  • replicate-ignore-db=information_schema auto-increment-increment=2 复制-忽略-db = information_schema自动增量-增量= 2
  • auto-increment-offset=1 自动增量偏移量= 1
  • bind-address=10.124.xxx.xx 绑定地址= 10.124.xxx.xx

ServerB: slave ServerB: 从属

  • server-id=2 服务器ID = 2
  • log_bin=/storage/mysql/mysql-repl.log log_bin = /存储/mysql/mysql-repl.log
  • binlog_do_db=test binlog_do_db =测试
  • replicate-do-db=test 复制数据库-测试
  • replicate-do-table=test.t1 复制表格= test.t1
  • binlog-ignore-db=information_schema binlog-ignore-db = information_schema
  • replicate-ignore-db=information_schema 复制-忽略-db = information_schema
  • auto-increment-increment=2 auto-increment-increment = 2
  • auto-increment-offset=2 自动增量偏移量= 2
  • bind-address=10.124.xxx.xx 绑定地址= 10.124.xxx.xx

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? 既然您似乎要同时写入这两个服务器并写入不同的表,那么为什么不同时在两个服务器上都有表t1和t2,并让应用程序将t1数据写入一台服务器,将t2数据写入另一台服务器并复制主-主?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM