V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
moell
V2EX  ›  MySQL

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

  •  
  •   moell · 2021-09-16 13:52:22 +08:00 · 1937 次点击
    这是一个创建于 924 天前的主题,其中的信息可能已经有所发展或是发生改变。
    正常运行了两年的从库,早上主从断掉了,然后同事直接跳过了错误信息(错误信息当时没注意,我目前不知道什么原因造成的),start slave 之后 ,Slave_IO_Running: Yes Slave_SQL_Running: Yes 显示正常,但是就是不同步数据。

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

    MySQL:5.7.24
    6 条回复    2021-09-16 14:59:07 +08:00
    ice2016
        1
    ice2016  
       2021-09-16 13:59:36 +08:00
    贴 log
    moell
        2
    moell  
    OP
       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
        3
    dot2017  
       2021-09-16 14:42:51 +08:00
    主要问题:error connecting to master 从连不上主。检查端口和防火墙
    次要问题:1. 同步参数不对,--relay-log 参数检查下 2. 主从的用户名密码直接写配置里了?不关心安全就无所谓了 3. 现在主从位置已经错乱了,等你网络通了,把主库完整覆盖到从库,再起同步
    moell
        4
    moell  
    OP
       2021-09-16 14:49:40 +08:00
    @dot2017 谢谢,网络应该没问题,如刚网络有问题的话,show slave status 应该会显示吧。次要问题.3 中, 是不是我现在就只有用 mysqldump 类似工具,导入到从库然后再起同步了。
    dot2017
        5
    dot2017  
       2021-09-16 14:53:51 +08:00
    @moell 搜 MySQL error code 2003,一个个排查

    另外导入后你要关注下主库导出完那个时刻的 position id,同步时以这个 id 开始。否则从追不全主的日志
    moell
        6
    moell  
    OP
       2021-09-16 14:59:07 +08:00
    @dot2017 👍 我试试看。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1197 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:12 · PVG 07:12 · LAX 16:12 · JFK 19:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.