MySQL 主从连接正常,但是不同步数据该怎么排查

2021-09-16 13:52:22 +08:00
 moell
正常运行了两年的从库,早上主从断掉了,然后同事直接跳过了错误信息(错误信息当时没注意,我目前不知道什么原因造成的),start slave 之后 ,Slave_IO_Running: Yes Slave_SQL_Running: Yes 显示正常,但是就是不同步数据。

存储空间没问题,mysqld.log 也没有异常信息 ,各位大佬指点一二,我该怎么去排查呀!谢谢各位了

MySQL:5.7.24
1988 次点击
所在节点    MySQL
6 条回复
ice2016
2021-09-16 13:59:36 +08:00
贴 log
moell
2021-09-16 14:34:46 +08:00
@ice2016 不好意思,现在看是有错误日志的。我尝试过从 bin_log 文件的第一个位置开始同步,和最新的主库的位置开始同步都没成功 。
[Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--relay-log=localhost-relay-bin' to avoid this problem.
[Warning] Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[ERROR] Slave I/O for channel '': error connecting to master '' - retry-time: 60 retries: 1, Error_code: 2003
[Warning] Slave SQL for channel '': If a crash happens this configuration does not guarantee that the relay log info will be consistent, Error_code: 0
[Note] Slave SQL thread for channel '' initialized, starting replication in log 'bin_log13.000001' at position 23289168, relay log './localhost-relay-bin.000004' position: 101377
[Note] Event Scheduler: Loaded 0 events
[Note] /usr/local/mysql/bin/mysqld: ready for connections.
dot2017
2021-09-16 14:42:51 +08:00
主要问题:error connecting to master 从连不上主。检查端口和防火墙
次要问题:1. 同步参数不对,--relay-log 参数检查下 2. 主从的用户名密码直接写配置里了?不关心安全就无所谓了 3. 现在主从位置已经错乱了,等你网络通了,把主库完整覆盖到从库,再起同步
moell
2021-09-16 14:49:40 +08:00
@dot2017 谢谢,网络应该没问题,如刚网络有问题的话,show slave status 应该会显示吧。次要问题.3 中, 是不是我现在就只有用 mysqldump 类似工具,导入到从库然后再起同步了。
dot2017
2021-09-16 14:53:51 +08:00
@moell 搜 MySQL error code 2003,一个个排查

另外导入后你要关注下主库导出完那个时刻的 position id,同步时以这个 id 开始。否则从追不全主的日志
moell
2021-09-16 14:59:07 +08:00
@dot2017 👍 我试试看。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/802277

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX