mysql主从同步配置文件正常,状态正常、日志正常,但是数据不同步

  • Post author:
  • Post category:mysql


版本5.6.33

现象:

1、Master能看到slave在连接,show processlist也能看到在dump binlog

mysql> show slave hosts;
+-----------+------+------+-----------+--------------------------------------+
| Server_id | Host | Port | Master_id | Slave_UUID                           |
+-----------+------+------+-----------+--------------------------------------+
|   1001098 |      | 3306 |   1001096 | 879ae869-e653-11e8-9f15-f4e9d4b21f90 |
|   1001097 |      | 3306 |   1001096 | 3baf55ed-e652-11e8-bb68-f4e9d4b677d0 |
+-----------+------+------+-----------+--------------------------------------+
2 rows in set (0.00 sec)

master 配置:

#开启binlog
log-bin = mysql-bin
binlog_format=row
server_id=1001096
#开始配置主主同步
#96自增步长2 97为1避免自增主键冲突
auto_increment_increment=2
auto_increment_offset=1
#忽略binlog的表
binlog-ignore=mysql
binlog-ignore=information_schema
binlog-ignore=performance_schema
character_set_server=utf8
#函数同步
log-bin-trust-function-creators=1
sync_binlog=1

2、slave状态

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

slave配置


#开启binlog
log-bin = mysql-bin
binlog_format=row
server_id=1001098



binlog-ignore-db=information_schema
binlog-ignore-db=performance_schema
binlog-ignore-db=mysql
replicate-do-db=oshop
replicate-ignore-db=performance_schema
replicate-ignore-db=information_schema
replicate-ignore-db=mysql
log-slave-updates
slave-skip-errors=all
slave-net-timeout=6


数据改变后从库未发生改变

根据现象判断,主从网络是通的,并且从库的logfile以及postion也跟着主库在变,日志也没有任何错误信息。

处理办法:

在主库配置上增加

binlog-do-db=dbname

重启主库,同步开始生效。



版权声明:本文为woshishui6501原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。