欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

MySQL5.1主从同步出现Relay log read failure错误解决方法

程序员文章站 2024-03-01 21:03:04
众所周知mysql5.1的replication是比较烂的。mysql的每一个版本更新关于同步方面每次都是可以看到一大堆。但mysql 5.1性能是比较突出的。所以经不住诱...

众所周知mysql5.1的replication是比较烂的。mysql的每一个版本更新关于同步方面每次都是可以看到一大堆。但mysql 5.1性能是比较突出的。所以经不住诱惑使用mysql 5.1。所以也要经常遇到一些bug。如:

复制代码 代码如下:

mysql> show slave status\g
*************************** 1. row ***************************
               slave_io_state: waiting for master to send event
                  master_host: 192.168.10.118
                  master_user: repl_wu
                  master_port: 3306
                connect_retry: 30
              master_log_file: mysql-bin.005121
          read_master_log_pos: 64337286
               relay_log_file: relay-bin.003995
                relay_log_pos: 18446697137031827760
        relay_master_log_file: mysql-bin.005121
             slave_io_running: yes
            slave_sql_running: no
              replicate_do_db:
          replicate_ignore_db:
           replicate_do_table:
       replicate_ignore_table:
      replicate_wild_do_table:
  replicate_wild_ignore_table:
                   last_errno: 1594
                   last_error: relay log read failure: could not parse relay log event entry. the possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's mysql code. if you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'show slave status' on this slave.
                 skip_counter: 0
          exec_master_log_pos: 4
              relay_log_space: 64337901
              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: 1594
               last_sql_error: relay log read failure: could not parse relay log event entry. the possible reasons are: the master's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (you can check this by running 'mysqlbinlog' on the relay log), a network problem, or a bug in the master's or slave's mysql code. if you want to check the master's binary log or slave's relay log, you will be able to know their names by issuing 'show slave status' on this slave.
1 row in set (0.00 sec)

从上面可以看到是中继日值或是master上的日值出问题了。

首先如果是中继日值坏掉,那只需要找到同步的时间点,然后重新同步,这样就可以有新的中继日值了。如果master上的日值坏了就麻烦了。

从经验来看,这是中继日值出问题了。处理方法:

需要找到同步的点。

日值为:master_log_file: mysql-bin.005121,relay_master_log_file: mysql-bin.005121以relay_master_log_file为准,master_log_file为参考。

日值执行时间点:

复制代码 代码如下:
exec_master_log_pos: 4

那么现在就可以:

复制代码 代码如下:

mysql>stop slave;
 
mysql>change master to master_log_file='mysql-bin.005121', master_log_pos=4;
  
mysql>start slave;
 
mysql>show slave status\g;

进行确认。

建议:

在使用mysql-5.1.36以下的版本的同学,请尽快升级到mysql-5.1.40 & mysql-5.1.37sp1