Mysql数据库突然不同步数据了查看slave的状态 show slave status\G 查看日志2019-03-11 18:40:03 10283 [ERROR] Slave sql: Erro
show slave status\G
查看日志
2019-03-11 18:40:03 10283 [ERROR] Slave sql: Error 'Duplicate entry '39' for key 'PRIMARY'' on query. Default database: 'db_jd'. Query: 'insert into tb_Goods values (null,'ty','10.45','27','')', Error_code: 1062
2019-03-11 18:40:03 10283 [Warning] Slave: Duplicate entry '39' for key 'PRIMARY' Error_code: 1062
2019-03-11 18:40:03 10283 [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.000003' position 10743.
网上说是可能在slave里进行了写操作
解决办法是
mysql> stop slave ;
mysql> set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;
mysql> start slave ;
发现还是不行,对了我的数据库是双主模型 slave当然可以写了
又看到网上说是binlog的格式不对 然后检查了my.cnf
发现确实少了几条,红框里的内容是原来没有的,后来添加上去的
然后重启mysql
查看日志
又有报错
2019-03-11 19:34:36 454 [ERROR] Slave SQL: Slave failed to initialize relay log info structure from the repository, Err or_code: 1872
网上说是由之前的残留文件,于是删除了这两个文件
rm -rf slave-relay-bin.index
rm -rf relay-log.info
再重启mysql
然后重新配置一下mysql同步进入mysql1
mysql> stop slave;
Query OK, 0 rows affected (0.05 sec)
在mysql2上查看mysql-bin和position
mysql> show master status;
mysql> change master to master_host='192.168.255.57',master_port=3306,master_user='zhangsan',master_passWord='123456',m aster_log_file='mysql-bin.000006',master_log_pos=120;
Query OK, 0 rows affected, 2 warnings (0.41 sec)
mysql> start slave;
Query OK, 0 rows affected (0.05 sec)
mysql> show slave status\G;
mysql2也重新配置
mysql> stop slave;
Query OK, 0 rows affected (0.05 sec)
在mysql1上查看mysql-bin和position
mysql> show master status;
mysql> change master to master_host='192.168.255.52',master_port=3306,master_user='zhangsan',master_password='123456',m aster_log_file='mysql-bin.000008',master_log_pos=120;
Query OK, 0 rows affected, 2 warnings (0.30 sec)
mysql> start slave;
Query OK, 0 rows affected (0.03 sec)
mysql> show slave status\G;
然后向数据库里插入数据就可以同步了~~
--结束END--
本文标题: mysql数据不同步
本文链接: https://lsjlt.com/news/36949.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0