9 TroubleShooting
9.1 出现slave连不上master的情况,也就是IO线程一直处于connecting状态,由于现实环境中各种防火墙,各种限制等,所以你最好在你的slave机器上用你的replication账号真正的登录一下master试一下,看是否能连上。
mysql -ubackup -p -h master_host_name
9.2 Got fatal error 1236 from master when reading data from binary log: 'Slave can not handle replication events with the checksum that master is configured to log;
可以尝试下述三种方法:
第一种,因为上面的原因说是checksum不对,所以估计是你的master和slave的mysql版本不一样,mysql5.6的binlog_checksum默认设置的是crc32。 而MySQL5.5 或者更早的版本默认值是None,所以可以将两个服务器的校验都设为none,或者crc32。
binlog_checksum =none;
如果还不行,尝试第二种,在master上执行:
flush logs;
show master status;
记下binlog_A和postion_B。
在slave上,执行:
stop slave;
CHANGE MASTER TO MASTER_LOG_FILE='binlog_A',MASTER_LOG_POS=postion_B;
start slave;
show slave status;
如果还不行,再试试第三种,在master上执行:mysqlbinlog /data/mysql/binlog/mysql-bin.000008
若出现:mysqlbinlog: [ERROR] unknown variable 'default-character-set=utf8mb4'
则可使用mysqlbinlog --no-defaults /data/mysql/binlog/mysql-bin.000008
找到最后一个end_log_pos后面的数字。
9.3 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遇到这种情况你可以show slave status看一下,
如果IO thread正常,证明binlog正常,没有corrupted,如果SQL线程状态为No,则证明relay log corrupted了。
那就需要找到同步的点了,show slave status, 以Relay_Master_Log_File为准,Master_Log_File为参考。
以Exec_Master_Log_Pos作为pos。
stop slave;
change master to Master_Log_File='mysql-bin.000010',Master_Log_Pos=1234;
start slave;
show slave status;
官方说master的版本低于slave的版本没什么问题,但是反过来就会有很多问题。原因是比如新版本有一些功能老版本不支持,然后master上执行了这些操作,同步到slave上就会有问题。
http://stackoverflow.com/questions/36150992/mysql-5-6-to-5-1-replication
9.4 如果遇到slave_IO_running是Yes,但是slave_SQL_running是No,这时候你会看到
Read_Master_Log_Pos会大于Exec_Master_Log_Pos,这就是说当slave遇到问题时,会暂停同步。然后你就需要看具体看是什么问题了,可以看last_error和last_sql_error,一般你就知道是什么问题,解决了问题之后,重新启动slave; start slave;9.5 如果出现:
error connecting to master 'replica_account@151.221.147.118:3306' - retry-time: 60 retries: 86400可以先在master上执行:
show grants for 'replica_account'@'%';
确保的确有此账户。
然后在slave机器上先手动的用此账户进行登录,看是否能够登录:
mysql -ureplica_account -h 151.221.147.118 -p
如果出现:ERROR 2003 (HY000): Can't connect to MySQL server on '' (110)
原文:http://blog.youkuaiyun.com/hongchangfirst/article/details/52121596
作者:hongchangfirst
hongchangfirst的主页:http://blog.youkuaiyun.com/hongchangfirst