0

我已将 MariaDB 从 10.1.38 升级到 10.1.41 版本,并在另一个分支中并行升级到 10.2.18 到 10.2.26,这在数据库复制启动期间导致了以下问题。关于 MariaDB 安装没有其他更改

Last_IO_Errno: 1236 Last_IO_Error: 从二进制日志中读取数据时从主服务器收到致命错误 1236:'错误:连接从服务器请求从 GTID 0-1-1 开始,这不在主服务器的二进制日志中。由于 master 的 binlog 包含更高序列号的 GTID,这可能意味着 slave 由于执行了额外的错误事务而发生了分歧'

在早期版本中,它工作正常。是否有任何与复制相关的更改,我们需要在安装期间明确调整?

MariaDB [(none)]> show slave status\G;
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 10.99.32.8
                  Master_User: repl
                  Master_Port: 3307
                Connect_Retry: 60
              Master_Log_File:
          Read_Master_Log_Pos: 4
               Relay_Log_File: mysql-1-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File:
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB: mysql
           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: 4
              Relay_Log_Space: 256
              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: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Error: connecting slave requested to start from GTID 0-1-1, which is not in the master's binlog. Since the master's binlog contains GTIDs with higher sequence numbers, it probably means that the slave has diverged due to executing extra erroneous transactions'
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 2
               Master_SSL_Crl:
           Master_SSL_Crlpath:
                   Using_Gtid: Current_Pos
                  Gtid_IO_Pos: 0-1-1
      Replicate_Do_Domain_Ids:
  Replicate_Ignore_Domain_Ids:
                Parallel_Mode: optimistic
                    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

二进制日志详细信息

MariaDB [(none)]> show binlog events in 'binary-log.000001';
Log_name        Pos     Event_type      Server_id       End_log_pos     Info
binary-log.000001       4       Format_desc     1       256     Server ver: 10.2.26-MariaDB-log, Binlog ver: 4
binary-log.000001       256     Gtid_list       1       285     []
binary-log.000001       285     Binlog_checkpoint       1       329     binary-log.000001
binary-log.000001       329     Gtid    1       371     GTID 0-1-1
binary-log.000001       371     Query   1       473     create database if not exists test;
binary-log.000001       473     Stop    1       496
MariaDB [(none)]> show binlog events in 'binary-log.000002';
Log_name        Pos     Event_type      Server_id       End_log_pos     Info
binary-log.000002       4       Format_desc     1       256     Server ver: 10.2.26-MariaDB-log, Binlog ver: 4
binary-log.000002       256     Gtid_list       1       299     [0-1-1]
binary-log.000002       299     Binlog_checkpoint       1       343     binary-log.000002
binary-log.000002       343     Stop    1       366
MariaDB [(none)]> show binlog events in 'binary-log.000003';
Log_name        Pos     Event_type      Server_id       End_log_pos     Info
binary-log.000003       4       Format_desc     1       256     Server ver: 10.2.26-MariaDB-log, Binlog ver: 4
binary-log.000003       256     Gtid_list       1       299     [0-1-1]
binary-log.000003       299     Binlog_checkpoint       1       343     binary-log.000003

4

1 回答 1

0

经过分析,能够发现上述问题是由于主从之间的 GTID 差异导致创建以下查询。

MariaDB:https ://jira.mariadb.org/browse/MDEV-20990

Stackoverflow:MariaDB 版本之间的 Gtid 位置差异

通过 MariaDB 的注释,我们可以看到 GTID 位置 0-1-1 已随着安装期间发生的 DDL 事务而更改。

已解决:在 my.cnf 文件中使用以下属性添加了用于复制忽略的测试数据库

***binlog-ignore-db = test***
于 2020-03-25T06:43:22.073 回答