在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Linux  數(shù)據(jù)庫(kù)/ 求教,mysql主從復(fù)制,主表插入數(shù)據(jù)后,從表未同步,且狀態(tài)異常

求教,mysql主從復(fù)制,主表插入數(shù)據(jù)后,從表未同步,且狀態(tài)異常

問題大概是這樣的:mysql主從復(fù)制,配置好之后,查看從表狀態(tài)正常:
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
然后在主表插入數(shù)據(jù),從表未同步,狀態(tài)異常:
Slave_IO_Running: Yes
Slave_SQL_Running: No

具體情況如下:
主庫(kù)在windows上,從庫(kù)在虛擬機(jī)上;
主庫(kù)配置 my.ini

[mysqld] 
# 主從配置
# 日志文件名以“mysql-bin”作為前綴
log-bin=mysql-bin
server-id=1
binlog-do-db=blog

從庫(kù)配置 my.cfg

[mysqld]
server-id = 2
port = 3306
log-bin=mysql-bin
binlog_format=mixed

windows執(zhí)行show master status;顯示如下

+------------------+----------+--------------+------------------+-------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000035 |     1253 | blog         |                  |                   |
+------------------+----------+--------------+------------------+-------------------+

虛擬機(jī)執(zhí)行

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;

顯示如下

clipboard.png

紅色部分這里看著是沒問題的

然后在主表執(zhí)行一條insert語(yǔ)句之后,再執(zhí)行show slave status \G;命令后,
主表數(shù)據(jù)插入成功,從表未同步,且狀態(tài)異常:
Slave_IO_Running: Yes
Slave_SQL_Running: No

clipboard.png

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查看日志看到如下錯(cuò)誤
ERROR: File is not a binary log file.
請(qǐng)問可能是哪里出了問題?

回答
編輯回答
話寡

error意思是binlog不是二進(jìn)制文件,你還是都用windows吧,從庫(kù)也在windows上好了。
或者都用docker,配起來快:repl,這個(gè)庫(kù)里我就放了一主一從。

2017年11月16日 12:57
編輯回答
浪蕩不羈

主庫(kù)是windows,從庫(kù)是Linux嗎?

2018年7月27日 09:30
編輯回答
悶騷型

修改你從庫(kù)的binlog_format=mixed改成row格式,mixed造成的問題比較多,因?yàn)闆]看到你的版本和主庫(kù)的binlog_format信息,所以如果主庫(kù)的binlog格式也是mixed或者statment格式,建議都改成row格式。
ps:推薦還是使用linux下的mysql。

2017年7月14日 01:50
編輯回答
負(fù)我心

解決了,是因?yàn)閙ysql版本不一致造成的,主庫(kù)是windows的5.7版本,從庫(kù)是centos的5.5。
我判斷是因?yàn)閺膸?kù)mysql的mysqlbinlog版本太低,無(wú)法讀取主庫(kù)的binlog日志,導(dǎo)致無(wú)法同步

2017年1月4日 04:08