mysql多线程同步时出现的问题

测试淘宝的mysql transfer多线程主从同步,使用mysqld替换的方式

同步时出现如下错误:
              Master_Log_File: mysql-bin.000016
          Read_Master_Log_Pos: 84222245

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.


查看mysql的错误日志:
121127 17:48:47 [ERROR] Slave SQL: Relay log read failure: Could not parse relay log event entry. The possible reasons are: the mast
er's binary log is corrupted (you can check this by running 'mysqlbinlog' on the binary log), the slave's relay log is corrupted (yo
u 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 y
ou 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' o
n this slave. Error_code: 1594
121127 17:48:47 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE
 START". We stopped at log 'mysql-bin.000001' position 50265953
121127 17:48:47 [Note] Slave I/O thread: connected to master '[email protected]:3306',replication started in log 'FIRST' at pos
ition 4
121127 17:49:17 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000020', position 30470398


解决方法:
mysqlbinlog -j 84222245 mysql-bin.000016 | less
找到下一个POS
然后
slave stop;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000016', MASTER_LOG_POS=84222429;
slave start;

主从又正常同步了


同步过程中又再出现错误:
show slave status \G
              Master_Log_File: mysql-bin.000045
          Read_Master_Log_Pos: 1166139603
               Relay_Log_File: localhost-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000045
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
        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: 'Client requested master to start replication from impossible position'

使用上面的方法,改变pos的位置,错误依旧,仍然是报错
slave stop;
CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000045', MASTER_LOG_POS=1166139603;
slave start;

shell> mysqlbinlog --start-position=1166139603 mysql-bin.000045
/*!40019 SET @@session.max_insert_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#121101 17:31:14 server id 1  end_log_pos 106   Start: binlog v 4, server v 5.1.55-log created 121101 17:31:14
# Warning: this binlog is either in use or was not closed properly.
BINLOG '
YkGSUA8BAAAAZgAAAGoAAAABAAQANS4xLjU1LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

没有看到pos的位置,把日志文件dump出来,也没有看到相应的pos位置的纪录
没有办法用change master 的方法来指定日志和位置

最后,把数据库停了,删了数据目录里面相关的几个文件
ibdata1 ib_logfile0 ib_logfile1 master.info relay-log.info
再重启数据库,OK,可以正常同步了


你可能感兴趣的:(mysql,主从,同步错误)