三个MariaDB服务器-server1 <---> server2和server2 <---> server3之间的多主-主复制设置中重复的入口键错误

时间:2019-02-01 22:00:18

标签: mariadb database-replication multi-master-replication

我们有两个服务器server1和server2。 Server1上有两个数据库DB01和DB02,而Server2上有四个数据库DB01,DB02,DB03,DB04。 SERVER 1和SERVER被配置为主 - 主为DB01&DB02。

我添加了复制所有四个数据库的从服务器2的第三服务器。到目前为止,服务器1和2之间的主-主以及服务器2和3之间的主-从都很好-

如果我现在配置服务器2服务器3作为实现服务器2和3,复制符之间主 - 主与重复输入键错误服务器2的从设备。

(未使用GTID配置复制。)

writes to                       writes to
db01, db02                      db03, db04                   No writes
+---------+                     +---------+                 +---------+
| server1 |  <-----mm----->     | server2 | >---slave--->   | server3 |
| ------- |                     | ------- |                 | ------- |
| db01 -m |                     | db01 -s |                 |  db01   |
| db02 -m |                     | db02 -s |                 |  db02   |
+---------+                     | db03 -m |                 |  db03   |
auto_increment_increment=3      | db04 -m |                 |  db04   |
auto_increment_offset=2         +---------+                 +---------+
log_slave_updates=1             replicate-do-db=db01        replicate-do-db=db01
replicate-do-db=db01            replicate-do-db=db02        replicate-do-db=db02
replicate-do-db=db02            auto_increment_increment=3  replicate-do-db=db03
                                auto_increment_offset=1     replicate-do-db=db04
                                log_slave_updates=1         auto_increment_increment=3
                                replicate-do-db=db03        auto_increment_offset=3
                                replicate-do-db=db04        log_slave_updates=1



If I now configure server2  as slave of server3 to achieve master-master between
server2 and 3, replication breaks on server2 with duplicate entry key error.


+---------+                     +---------+                 +---------+
| server1 | <------mm----->     | server2 | >--slave--> ok  | server3 |
| ------- |                     | ------- |                 | ------- |
|  db01   |                     |  db01   | <--slave--< x   |  db01   |
|  db02   |                     |  db02   |                 |  db02   |
+---------+                     |  db03   |                 |  db03   |
                                |  db04   |                 |  db04   |
                                +---------+                 +---------+


This is the error on server2:

MariaDB [(none)]> show all slaves status \G
*************************** 1. row ***************************
              Connection_name: mm-01-to-04b
              Slave_SQL_State: 
               Slave_IO_State: Waiting for master to send event
                  Master_Host: server3
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000099
          Read_Master_Log_Pos: 70417544
               Relay_Log_File: mysql-relay-bin-mm@002d01@002dto@002d04b.000002
                Relay_Log_Pos: 2021
        Relay_Master_Log_File: mysql-bin.000099
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB: db03,db04,db01,db02
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 1062
                   Last_Error: Error 'Duplicate entry '1758321014' for key 'PRIMARY'' on query. Default database: 'db01'. Query: 'INSERT INTO item SET itemClass_DbId = 12058, user_DbId = 45392036, view_DbId = 15'
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 64342511
              Relay_Log_Space: 3288379
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 1062
               Last_SQL_Error: Error 'Duplicate entry '1758321014' for key 'PRIMARY'' on query. Default database: 'db01'. Query: 'INSERT INTO item SET itemClass_DbId = 12058, user_DbId = 45392036, view_DbId = 15'
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 10214311
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: 
         Retried_transactions: 0
           Max_relay_log_size: 1073741824
         Executed_log_entries: 38
    Slave_received_heartbeats: 1
       Slave_heartbeat_period: 30.000
               Gtid_Slave_Pos: 0-10214212-1893552590
*************************** 2. row ***************************
              Connection_name: dbs-01-02
              Slave_SQL_State: Slave has read all relay log; waiting for the slave I/O thread to update it
               Slave_IO_State: Waiting for master to send event
                  Master_Host: server1
                  Master_User: replicator
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000586
          Read_Master_Log_Pos: 657757085
               Relay_Log_File: mysql-relay-bin-dbs@002d01@002d02.000202
                Relay_Log_Pos: 417827599
        Relay_Master_Log_File: mysql-bin.000586
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
              Replicate_Do_DB: db03,db04,db01,db02
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 657757085
              Relay_Log_Space: 417827929
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error: 
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 10214211
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
                   Using_Gtid: No
                  Gtid_IO_Pos: 
      Replicate_Do_Domain_Ids: 
  Replicate_Ignore_Domain_Ids: 
                Parallel_Mode: conservative
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
         Retried_transactions: 0
           Max_relay_log_size: 1073741824
         Executed_log_entries: 3800382
    Slave_received_heartbeats: 0
       Slave_heartbeat_period: 30.000
               Gtid_Slave_Pos: 0-10214212-1893552590
2 rows in set (0.00 sec)



我期望主-主复制可以在server2的任何一侧进行。然而,似乎在server1插入件被复制到服务器2经由服务器3,然后返回到服务器2。

时这种设置的在所有可能的,而无需使用GTID?

仅供参考,所有三个服务器正在运行Linux的亚马逊和201703 10.2.8 MariaDB的

谢谢。

0 个答案:

没有答案