问题大概是这样的:mysql主从复制,配置好之后,查看从表状态正常:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
然后在主表插入数据,从表未同步,状态异常:
Slave_IO_Running: Yes
Slave_SQL_Running: No
具体情况如下:
主库在windows上,从库在虚拟机上;
主库配置 my.ini
[mysqld]
# 主从配置
# 日志文件名以“mysql-bin”作为前缀
log-bin=mysql-bin
server-id=1
binlog-do-db=blog
从库配置 my.cfg
[mysqld]
server-id = 2
port = 3306
log-bin=mysql-bin
binlog_format=mixed
windows执行show master status;显示如下
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000035 | 1253 | blog | | |
+------------------+----------+--------------+------------------+-------------------+
虚拟机执行
stop slave;
CHANGE MASTER TO MASTER_HOST='192.168.1.110',
MASTER_USER='root',
MASTER_PASSWORD='root',
MASTER_LOG_FILE='mysql-bin.000035',
MASTER_LOG_POS=1253;
start slave;
show slave status \G;
显示如下
红色部分这里看着是没问题的
然后在主表执行一条insert语句之后,再执行show slave status \G;命令后,
主表数据插入成功,从表未同步,且状态异常:
Slave_IO_Running: Yes
Slave_SQL_Running: No
last error 信息
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.
使用 mysqlbinlog relay-log.info查看日志看到如下错误
ERROR: File is not a binary log file.
请问可能是哪里出了问题?